Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

z_ui_reply_04_filetest.gno

1.23 Kb · 35 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_ui_reply_04_filetest
 2
 3// Re-rooting at a depth-2 reply renders its parent as context with a
 4// "Continue this thread →" drill-up link (the parent is itself a reply with
 5// children), instead of a "View Thread" jump to the thread root.
 6package z_ui_reply_04_filetest
 7
 8import (
 9	"strings"
10	"testing"
11
12	boards2 "gno.land/r/gnoland/boards2/v0"
13)
14
15const owner address = "g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"
16
17func init(cur realm) {
18	testing.SetRealm(testing.NewUserRealm(owner))
19	bid := boards2.CreateBoard(cross(cur), "test-board", false, false)
20	tid := boards2.CreateThread(cross(cur), bid, "Foo", "OP body")
21	aid := boards2.CreateReply(cross(cur), bid, tid, 0, "comment A") // #2, parent = thread
22	boards2.CreateReply(cross(cur), bid, tid, aid, "reply B")        // #3, parent = A
23}
24
25func main(cur realm) {
26	// Re-root at reply #3 (B); its parent #2 (A) renders as context and, being
27	// a reply with children, links "Continue this thread →" (to A's re-root).
28	out := boards2.Render("test-board/1/3")
29	ok := strings.Contains(out, "Continue this thread →") &&
30		strings.Contains(out, "/r/gnoland/boards2/v0:test-board/1/2") // → A's re-root, not the thread root
31	println(ok)
32}
33
34// Output:
35// true