z_flag_reply_07_filetest.gno
1.85 Kb · 62 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_flag_reply_07_filetest
2
3package z_flag_reply_07_filetest
4
5import (
6 "testing"
7
8 "gno.land/p/gnoland/boards"
9
10 boards2 "gno.land/r/gnoland/boards2/v1"
11)
12
13const (
14 owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
15 moderator address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
16)
17
18var (
19 bid boards.ID
20 rid, tid boards.ID
21)
22
23func init(cur realm) {
24 // Created a board with flagging threshold greater than 1
25 testing.SetRealm(testing.NewUserRealm(owner))
26 bid = boards2.CreateBoard(cross(cur), "test-board", false, false)
27 boards2.SetFlaggingThreshold(cross(cur), bid, 2)
28
29 // Create a reply so the realm owner can flag and hide it with a single flag
30 tid = boards2.CreateThread(cross(cur), bid, "Foo", "bar")
31 rid = boards2.CreateReply(cross(cur), bid, tid, 0, "body")
32 // Also freeze board to make sure that realm owner can still flag the reply
33 boards2.FreezeBoard(cross(cur), bid)
34}
35
36func main(cur realm) {
37 testing.SetRealm(testing.NewUserRealm(owner))
38
39 boards2.FlagReply(cross(cur), bid, tid, rid, "Reason")
40
41 // Render content must contain a message about the hidden reply
42 println(boards2.Render("test-board/1/2"))
43}
44
45// Output:
46// ## Foo
47//
48// **[g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh](/u/g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh)** `owner` · 2009-02-13 11:31pm UTC
49//
50//
51// <gno-foreign>
52// bar
53// </gno-foreign>
54//
55//
56//
57// ↳ [Flag](/r/gnoland/boards2/v1:test-board/1/flag) • [Repost](/r/gnoland/boards2/v1:test-board/1/repost) • [Show all Replies](/r/gnoland/boards2/v1:test-board/1)
58//
59//
60// >
61// > **[g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh](/u/g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh)** `owner` · 2009-02-13 11:31pm UTC [\#2](/r/gnoland/boards2/v1:test-board/1/2)
62// > ⚠ Reply is hidden as it has been flagged as [inappropriate](/r/gnoland/boards2/v1:test-board/1/2/flagging-reasons)