Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_edit_reply_08_filetest.gno

1.12 Kb · 39 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_edit_reply_08_filetest
 2
 3// Editing a reply to contain a <gno-form> is now accepted: the
 4// write-time blacklist relaxation applies to edits too (EditReply shares
 5// the validator). The body renders inside a <gno-foreign> sandbox.
 6package z_edit_reply_08_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 bid, tid, rid boards.ID
20
21func init(cur realm) {
22	testing.SetRealm(testing.NewUserRealm(owner))
23	bid = boards2.CreateBoard(cross(cur), "test-board", false, false)
24	tid = boards2.CreateThread(cross(cur), bid, "Foo", "bar")
25	rid = boards2.CreateReply(cross(cur), bid, tid, 0, "body")
26}
27
28func main(cur realm) {
29	testing.SetRealm(testing.NewUserRealm(owner))
30
31	// Previously rejected on edit ("forms are not allowed in replies").
32	boards2.EditReply(cross(cur), bid, tid, rid, "<gno-form><gno-select name=\"foo\" value=\"\" /></gno-form>")
33
34	content := boards2.Render("test-board/1")
35	println(strings.Contains(content, "<gno-foreign>"))
36}
37
38// Output:
39// true