z_delete_reply_09_filetest.gno
1.40 Kb · 47 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_delete_reply_09_filetest
2
3// Hard-deleting a childless DIRECT thread reply removes it from the thread's
4// direct-children list (not just the flat AllReplies index), so the threaded
5// view doesn't render a ghost comment and the reply count stays accurate.
6package z_delete_reply_09_filetest
7
8import (
9 "strings"
10 "testing"
11
12 "gno.land/p/gnoland/boards"
13
14 boards2 "gno.land/r/gnoland/boards2/v1"
15)
16
17const owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
18
19var (
20 bid boards.ID
21 tid boards.ID
22 rb 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 boards2.CreateReply(cross(cur), bid, tid, 0, "reply-A") // #2, direct, leaf
30 rb = boards2.CreateReply(cross(cur), bid, tid, 0, "reply-B") // #3, direct, leaf
31 boards2.CreateReply(cross(cur), bid, tid, 0, "reply-C") // #4, direct, leaf
32}
33
34func main(cur realm) {
35 testing.SetRealm(testing.NewUserRealm(owner))
36 boards2.DeleteReply(cross(cur), bid, tid, rb) // hard delete the leaf
37
38 out := boards2.Render("test-board/1")
39 // A and C remain; B must be fully gone (no ghost) from the threaded view.
40 ok := strings.Contains(out, "reply-A") &&
41 strings.Contains(out, "reply-C") &&
42 !strings.Contains(out, "reply-B")
43 println(ok)
44}
45
46// Output:
47// true