z_13_h_filetest.gno

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