Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_flag_thread_07_filetest.gno

1.12 Kb · 42 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_flag_thread_07_filetest
 2
 3package z_flag_thread_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 owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
14
15var (
16	bid boards.ID
17	pid boards.ID
18)
19
20func init(cur realm) {
21	// Created a board with flagging threshold greater than 1
22	testing.SetRealm(testing.NewUserRealm(owner))
23	bid = boards2.CreateBoard(cross(cur), "test-board", false, false)
24	boards2.SetFlaggingThreshold(cross(cur), bid, 2)
25
26	// Create a thread so the realm owner can flag and hide it with a single flag
27	pid = boards2.CreateThread(cross(cur), bid, "Foo", "bar")
28	// Also freeze board to make sure that realm owner can still flag the thread
29	boards2.FreezeBoard(cross(cur), bid)
30}
31
32func main(cur realm) {
33	testing.SetRealm(testing.NewUserRealm(owner))
34
35	boards2.FlagThread(cross(cur), bid, pid, "Reason")
36
37	// Ensure that original thread content not visible
38	println(boards2.Render("test-board/1"))
39}
40
41// Output:
42// ⚠ Thread has been flagged as [inappropriate](/r/gnoland/boards2/v1:test-board/1/flagging-reasons)