4. Replace tests/smoke.luau
luastra/media · live media_state events · about 20 minutesvalid event + malformed state rejection
The smoke test drives the same media_state path as the host without pretending to play audio in the isolated test VM.
When to use it
Replace the generated smoke test so state admission and rejection are verified independently of browser audio policy.
Focused example
--!strict
local app = require("app/main")
local Media = require("luastra/media")
local ready = table.concat({
"v=1",
"artist=Luastra",
"background=false",
"bufferedMs=1000",
"durationMs=8000",
"errorCode=",
"errorMessage=",
"interruption=none",
"itemId=focus",
"positionMs=0",
"queueCount=1",
"queueIndex=0",
"revision=1",
"route=default",
"status=ready",
"title=Focus%20sample",
}, "&")
local decoded = Media.decodeState(ready)
assert(decoded.success and decoded.state.title == "Focus sample")
app.handle("media_state", "player", ready)
local current = app.snapshot()
assert(current.status == "ready" and current.title == "Focus sample")
app.handle("media_state", "player", "v=2&status=playing")
local rejected = app.snapshot()
assert(rejected.status == "ready")
assert(rejected.message == "Rejected media state: invalid_wire")
assert(app.render().type == "Screen")
return true