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_thread_12_filetest.gno

1.62 Kb · 53 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_ui_thread_12_filetest
 2
 3// When the render budget is exhausted mid-page in the threaded view, the
 4// offset page-picker would offer a "next page" that jumps past the replies
 5// that were skipped when the budget ran out. Instead the picker is suppressed
 6// and the reader is funneled to the complete, reachable flat view.
 7package z_ui_thread_12_filetest
 8
 9import (
10	"strings"
11	"testing"
12
13	"gno.land/p/gnoland/boards/v0"
14
15	boards2 "gno.land/r/gnoland/boards2/v0"
16)
17
18const owner address = "g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"
19
20var (
21	bid boards.ID
22	tid boards.ID
23)
24
25func init(cur realm) {
26	testing.SetRealm(testing.NewUserRealm(owner))
27	bid = boards2.CreateBoard(cross(cur), "test-board", false, false)
28	tid = boards2.CreateThread(cross(cur), bid, "Foo", "OP body")
29
30	// First top-level reply carries a deep chain that alone exhausts the
31	// render budget (maxRenderedBodies, 246) on page 1.
32	prev := boards2.CreateReply(cross(cur), bid, tid, 0, "top-deep")
33	for i := 0; i < 250; i++ {
34		prev = boards2.CreateReply(cross(cur), bid, tid, prev, "chain")
35	}
36	// Plus enough more top-level replies that the thread spans 2 pages, so a
37	// picker WOULD render absent the suppression.
38	for i := 0; i < 12; i++ {
39		boards2.CreateReply(cross(cur), bid, tid, 0, "top-more")
40	}
41}
42
43func main(cur realm) {
44	out := boards2.Render("test-board/1")
45	// Budget truncated page 1: the flat "view all comments" link is shown,
46	// and the content-skipping page picker ("page 1 of N") is suppressed.
47	ok := strings.Contains(out, "view all comments") &&
48		!strings.Contains(out, "page 1 of")
49	println(ok)
50}
51
52// Output:
53// true