z_13_g_filetest.gno

1.01 Kb · 42 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	testing.SetRealm(std.NewUserRealm(owner))
23	bid = boards2.CreateBoard(cross, "test-board", false)
24	tid = boards2.CreateThread(cross, bid, "Foo", "bar")
25	rid = boards2.CreateReply(cross, bid, tid, 0, "body")
26
27	// Invite a member using a role with permission to flag replies
28	boards2.InviteMember(cross, bid, moderator, boards2.RoleModerator)
29}
30
31func main() {
32	testing.SetRealm(std.NewUserRealm(moderator))
33
34	boards2.FlagReply(cross, bid, tid, rid, "")
35
36	// Render content must contain a message about the hidden reply
37	content := boards2.Render("test-board/1/2")
38	println(strings.Contains(content, "\n> *⚠ Reply is hidden as it has been flagged as inappropriate*\n"))
39}
40
41// Output:
42// true