z_ui_thread_12_filetest.gno
1.62 Kb · 53 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/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"
14
15 boards2 "gno.land/r/gnoland/boards2/v1"
16)
17
18const owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
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