1package craft23import (4 "strings"5 "testing"67 "gno.land/p/nt/uassert/v0"8)910func TestRenderRecipeLookup(cur realm, t *testing.T) {11 setupCraftTest(cross(cur), t)12 testing.SetOriginCaller(craftTest.Admin)13 testing.SetRealm(testing.NewUserRealm(craftTest.Admin))14 SetRecipe(cross(cur), "0001|craft-render-item:01", 1200)1516 output := Render("recipe?recipe=0001%7Ccraft-render-item%3A1")17 uassert.True(t, strings.Contains(output, "Item ID**: 1200"), "should render the mapped item ID")18 uassert.True(t, strings.Contains(output, "`0001|0:craft-render-item:1`"), "should render the canonical recipe as a code span")19 uassert.False(t, strings.Contains(output, `\|`), "recipe code span should keep pipes literal")20}2122func TestRenderRecipeErrors(cur realm, t *testing.T) {23 setupCraftTest(cross(cur), t)2425 empty := Render("recipe")26 uassert.True(t, strings.Contains(empty, "Recipe is required"), "should require a recipe")2728 invalid := Render("recipe?recipe=bad")29 uassert.True(t, strings.Contains(invalid, "Invalid recipe"), "should reject an invalid recipe")3031 missing := Render("recipe?recipe=0001%7Ccraft-missing-item%3A1")32 uassert.True(t, strings.Contains(missing, "Recipe not found"), "should report a missing recipe")3334 unknown := Render("unknown")35 uassert.True(t, strings.Contains(unknown, "Not found"), "should reject an unknown route")36}3738func TestRenderRecipeHomeAndList(cur realm, t *testing.T) {39 setupCraftTest(cross(cur), t)40 home := Render("")41 uassert.True(t, strings.Contains(home, `<gno-form path="recipe">`), "should render the recipe lookup form")42 uassert.True(t, strings.Contains(home, `name="recipe"`), "should render the recipe input")43 uassert.True(t, strings.Contains(home, `./craft:recipes`), "should link to the recipe list")44 uassert.True(t, strings.Contains(home, "1000000ugnot"), "should render the default craft fee")4546 emptyList := Render("recipes")47 uassert.True(t, strings.Contains(emptyList, "No recipes stored yet"), "should render an empty list")4849 testing.SetOriginCaller(craftTest.Admin)50 testing.SetRealm(testing.NewUserRealm(craftTest.Admin))51 SetRecipe(cross(cur), "0001|craft-list-render:1", 1300)5253 listed := Render("recipes")54 uassert.True(t, strings.Contains(listed, "1300"), "should render stored item IDs")55 uassert.True(t, strings.Contains(listed, "`0001|0:craft-list-render:1`"), "should render listed recipes as a code span")56 uassert.False(t, strings.Contains(listed, `\|`), "listed recipe code span should keep pipes literal")57}58Craft(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, recipe string) uint64
DeleteRecipe(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, recipe string)
DeleteRecipes(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, recipesCSV string)
GetCraftFee() int64
GetListLimit() int
GetRecipe(recipe string) uint32
GetRecipeCount() int
HasRecipe(recipe string) bool
ListRecipes(page int, count int) []map[string]string
Render(iURL string) string
SetCraftFee(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, fee int64)
SetListLimit(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, limit int)
SetRecipe(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, recipe string, itemID uint32)
SetRecipes(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, recipesCSV string, itemIDsCSV string)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.