4. Replace tests/smoke.luau
luastra/assets · UI.Image · UI.Shape · about 15 minutesasset identity + render semantics + interaction
The test verifies the typed asset contract, image accessibility, decorative geometry, meaningful geometry, and fit toggle.
When to use it
Replace the generated smoke test so the recipe proves both static asset wiring and its visible state transition.
Focused example
--!strict
local app = require("app/main")
local Assets = require("luastra/assets")
local function find(node: any, id: string): any?
if node.id == id then return node end
for _, child in node.children or {} do
local result = find(child, id)
if result ~= nil then return result end
end
return nil
end
local reference = Assets.image("image/luastra-mark")
assert(reference.kind == "image")
assert(reference.id == "image/luastra-mark")
assert(Assets.uri(reference) == "asset:image/luastra-mark")
local initial = app.render()
local image = find(initial, "visuals/mark") :: any
assert(image.properties.source == "asset:image/luastra-mark")
assert(image.properties.label == "Luastra orbit mark")
assert(string.find(tostring(image.properties.className), "luastra-fit-contain", 1, true) ~= nil)
assert((find(initial, "visuals/decoration") :: any).properties.label == "")
assert((find(initial, "visuals/featured") :: any).properties.label == "Featured visual")
app.handle("visuals.toggle-fit", "visuals/toggle-fit", "")
assert(app.snapshot().cover == true)
local changedImage = find(app.render(), "visuals/mark") :: any
assert(string.find(tostring(changedImage.properties.className), "luastra-fit-cover", 1, true) ~= nil)
return true