This commit is contained in:
2026-11-05 09:57:11 -05:00
parent d34388bf2c
commit 89e392cc2e
81 changed files with 12410 additions and 1135 deletions
+22 -5
View File
@@ -56,8 +56,8 @@ local function harness()
end
test("factory exports fresh defaults and exact independent option lists", function()
local h = harness(); local C = h.C
local counts = {body=3,skin=6,face=4,eyes=5,hair=7,hairColor=6,beard=5,garment=4,cloth=8,
trousers=4,boots=3,accent=5,accentColor=8,detail=4}
local counts = {body=5,skin=6,face=5,eyes=5,hair=10,hairColor=6,beard=7,garment=7,cloth=8,
trousers=4,boots=3,accent=9,accentColor=8,detail=5}
for k,n in pairs(counts) do assert(#C.options()[k]==n,k) end
local d, o = C.defaults(), C.options(); d.skin="BAD"; o.skin[1]="BAD"
assert(C.defaults().skin=="sand" and C.options().skin[1]=="porcelain" and C.VERSION==1)
@@ -88,7 +88,7 @@ end)
test("preview exactly follows opaque skin face eyes clothing accent hair beard detail order", function()
local C=harness().C; local mesh,texture=C.preview(C.defaults())
assert(mesh=="hearth_person.b3d")
assert(texture=="hearth_char_skin_sand.png^hearth_char_face_calm.png^hearth_char_eyes_hazel.png^hearth_char_garment_tunic_teal.png^hearth_char_trousers_earth.png^hearth_char_boots_walnut.png^hearth_char_accent_scarf_sage.png^hearth_char_hair_sidepart_chestnut.png^hearth_char_beard_none_chestnut.png^hearth_char_detail_none.png")
assert(texture=="hearth_char_skin_sand.png^hearth_char_face_calm.png^hearth_char_eyes_hazel.png^hearth_char_garment_tunic_teal.png^hearth_char_trousers_earth.png^hearth_char_boots_walnut.png^hearth_char_hair_sidepart_chestnut.png^hearth_char_beard_none_chestnut.png^hearth_char_accent_scarf_sage.png^hearth_char_detail_none.png")
assert(not C.preview({}))
end)
test("bounded silent JSON roundtrip refuses malformed oversize nested and invalid data", function()
@@ -157,6 +157,14 @@ test("draft tabs and rotations never publish player properties or metadata", fun
assert(h.C.state(p).draft.skin=="ebony" and h.C.state(p).draft.hair=="long")
assert(#h.props==before and m.writes==0)
end)
test("two-digit dropdown indices select the expanded cosmetic catalogue safely", function()
local h=harness(); local p=h.player(); h.C.show(p)
assert(#h.C.options().hair==10)
assert(h.C.handle(p,{tab_2=true}))
assert(h.C.handle(p,{pick_hair="10",pick_hairColor="6",pick_beard="7"}))
assert(h.C.state(p).draft.hair=="undercut" and h.C.state(p).draft.beard=="braided_beard")
assert(not h.C.handle(p,{pick_hair="00"}))
end)
test("cancel and Escape discard draft preserving saved appearance and persistence", function()
for _,field in ipairs({"cancel","quit"}) do
local h=harness(); local p,m=h.player(); h.C.show(p); local old=p.properties.textures[1]
@@ -169,7 +177,7 @@ test("apply writes first then publishes and saved data survives a new session",
local h=harness(); local p,m=h.player(); h.C.show(p)
local original=p.set_properties
p.set_properties=function(self,props) assert(m.writes==1 and h.C.decode(m.raw).skin=="ebony"); original(self,props) end
assert(h.C.handle(p,{pick_skin="6",pick_body="3",apply=true}))
assert(h.C.handle(p,{pick_skin="6",pick_body="4",apply=true}))
assert(m.writes==1 and not h.C.state(p).draft and p.properties.mesh=="hearth_person_broad.b3d")
p.set_properties=original; h.sessions.alice={}; h.C.on_join(p)
assert(h.C.state(p).saved.skin=="ebony" and m.writes==1 and not h.C.state(p).warning)
@@ -212,5 +220,14 @@ test("stale sessions reconnects closed drafts and disconnected objects cannot sa
h.C.show(p); h.connected.alice=nil; assert(not h.C.handle(p,{apply=true}))
h.connected.alice=p; h.C.show(p); h.C.handle(p,{cancel=true}); assert(not h.C.handle(p,{apply=true}))
end)
assert(total==18,"Unexpected character test count")
test("creator tooltip text passes through escaping without changing model semantics",function()
local h=harness(); local p=h.player(); local seen={}
local escape=h.api.formspec_escape
h.api.formspec_escape=function(s) seen[s]=true; return escape(s) end
h.C.show(p)
local text="Drag to turn the preview. Only this model rotates."
assert(seen[text] and h.screens[#h.screens].spec:find("tooltip[traveler;"..escape(text).."]",1,true))
assert(h.screens[#h.screens].spec:find(";0,180;true;true;0,19;12]",1,true))
end)
assert(total==20,"Unexpected character test count")
print("PASS " .. total .. " character creator tests")