z_13_g_filetest.gno
1.07 Kb · 44 lines
1package main
2
3import (
4 "strings"
5 "testing"
6
7 "gno.land/p/gnoland/boards"
8
9 boards2 "gno.land/r/gnoland/boards2/v1"
10 "gno.land/r/gnoland/boards2/v1/permissions"
11)
12
13const (
14 owner address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq" // @devx
15 moderator address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
16)
17
18var (
19 bid boards.ID
20 rid, tid boards.ID
21)
22
23func init() {
24 testing.SetRealm(testing.NewUserRealm(owner))
25 bid = boards2.CreateBoard(cross, "test-board", false, false)
26 tid = boards2.CreateThread(cross, bid, "Foo", "bar")
27 rid = boards2.CreateReply(cross, bid, tid, 0, "body")
28
29 // Invite a member using a role with permission to flag replies
30 boards2.InviteMember(cross, bid, moderator, permissions.RoleModerator)
31}
32
33func main() {
34 testing.SetRealm(testing.NewUserRealm(moderator))
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, "\n> *⚠ Reply is hidden as it has been flagged as inappropriate*\n"))
41}
42
43// Output:
44// true