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