z_13_h_filetest.gno
1.15 Kb · 45 lines
1package main
2
3import (
4 "std"
5 "strings"
6 "testing"
7
8 boards2 "gno.land/r/gnoland/boards2/v1"
9)
10
11const (
12 owner = std.Address("g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq") // @devx
13 moderator = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
14)
15
16var (
17 bid boards2.BoardID
18 rid, tid boards2.PostID
19)
20
21func init() {
22 // Created a board with flagging threshold greater than 1
23 testing.SetRealm(std.NewUserRealm(owner))
24 bid = boards2.CreateBoard(cross, "test-board", false)
25 boards2.SetFlaggingThreshold(cross, bid, 2)
26
27 // Create a reply so the realm owner can flag and hide it with a single flag
28 tid = boards2.CreateThread(cross, bid, "Foo", "bar")
29 rid = boards2.CreateReply(cross, bid, tid, 0, "body")
30 // Also freeze board to make sure that realm owner can still flag the reply
31 boards2.FreezeBoard(cross, bid)
32}
33
34func main() {
35 testing.SetRealm(std.NewUserRealm(owner))
36
37 boards2.FlagReply(cross, bid, tid, rid, "")
38
39 // Render content must contain a message about the hidden reply
40 content := boards2.Render("test-board/1/2")
41 println(strings.Contains(content, "> *⚠ Reply is hidden as it has been flagged as inappropriate*"))
42}
43
44// Output:
45// true