z_ui_thread_11_filetest.gno
1.27 Kb · 40 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_ui_thread_11_filetest
2
3// A comment's inline children follow the page's ?order: newest-first when the
4// thread is sorted desc, oldest-first otherwise — not always oldest-first.
5package z_ui_thread_11_filetest
6
7import (
8 "strings"
9 "testing"
10
11 "gno.land/p/nt/ufmt/v0"
12
13 boards2 "gno.land/r/gnoland/boards2/v1"
14)
15
16const owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
17
18func init(cur realm) {
19 testing.SetRealm(testing.NewUserRealm(owner))
20 bid := boards2.CreateBoard(cross(cur), "test-board", false, false)
21 tid := boards2.CreateThread(cross(cur), bid, "Foo", "OP body")
22 cid := boards2.CreateReply(cross(cur), bid, tid, 0, "parent") // #2
23 for i := 0; i < 3; i++ {
24 boards2.CreateReply(cross(cur), bid, tid, cid, ufmt.Sprintf("child-%d", i)) // #3,#4,#5
25 }
26}
27
28func main(cur realm) {
29 desc := boards2.Render("test-board/1?order=desc")
30 asc := boards2.Render("test-board/1") // default = oldest first
31
32 // desc view: the comment's children render newest-first (child-2 before child-0).
33 descOK := strings.Index(desc, "child-2") < strings.Index(desc, "child-0")
34 // asc view: oldest-first (child-0 before child-2).
35 ascOK := strings.Index(asc, "child-0") < strings.Index(asc, "child-2")
36 println(descOK && ascOK)
37}
38
39// Output:
40// true