const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); const page = fs.readFileSync(new URL('../index.html', `file://${__filename}`), 'utf8'); test('admin can select a searched account before opening its conversations', () => { assert.match(page, /Välj konto att följa/); assert.match(page, /chooserSelect\.value\);/); assert.match(page, /\/api\/admin\/players\?q=/); }); test('conversation transcript exposes player and narrator messages as expandable replies', () => { assert.match(page, /function renderAdminConversations/); assert.match(page, /payload\.player_message/); assert.match(page, /payload\.reply \|\| payload\.npc_reply/); assert.match(page, /aria-expanded/); assert.match(page, /renderDecisionProvenance\(group, event, detail\)/); }); test('selected replies reveal AI, Luau and Rust provenance without injecting HTML', () => { assert.match(page, /function renderDecisionProvenance/); assert.match(page, /interaction\.prompt_yaml/); assert.match(page, /interaction\.external_call/); assert.match(page, /details\.luau_trace/); assert.match(page, /details\.rust_validation/); assert.match(page, /element\.textContent = text/); }); test('account trace can be paged until all stored turns are loaded', () => { assert.match(page, /Visa äldre samtalsturer/); assert.match(page, /query AdminPlayerTrace\(\$accountId: String, \$limit: Int!, \$offset: Int!\)/); assert.match(page, /getAdminTrace\(accountId, trace\.limit \|\| 200, adminTraceOffset\)/); }); test('admin can switch to a storyteller-only reading view and return to diagnostics', () => { assert.match(page, /Lättläst konversation/); assert.match(page, /Visa felsökningsspår/); assert.match(page, /root\.classList\.toggle\('admin-simple-conversation', adminSimpleConversation\)/); assert.match(page, /playerLine\.className = 'admin-story-player'/); assert.match(page, /story\.className = 'admin-story-reply'/); assert.match(page, /article > :not\(\.admin-story-player\):not\(\.admin-story-reply\)/); assert.match(page, /article > \.admin-story-player,\s*#admin-content \.admin-simple-conversation article > \.admin-story-reply/); }); test('admin JSON responses are readable as accessible collapsible trees', () => { assert.match(page, /function renderJsonTree/); assert.match(page, /nested\.className = 'json-node'/); assert.match(page, /const nodeValues = new WeakMap\(\)/); assert.match(page, /nodeValues\.set\(nested, child\)/); assert.match(page, /groupSummary/); assert.match(page, /Lista · \$\{item\.length\}/); assert.match(page, /Objekt · \$\{Object\.keys\(item\)\.length\} fält/); assert.match(page, /Öppna alla block/); assert.match(page, /Fäll ihop nästlade block/); assert.match(page, /setAttribute\('aria-label', 'Utfällbart JSON-svar'\)/); assert.match(page, /json-value-string/); assert.match(page, /json-value-number/); assert.match(page, /json-value-boolean/); assert.match(page, /json-value-null/); assert.match(page, /renderJsonTree\(json, group\)/); assert.match(page, /rawSummary\.textContent = 'Visa hela spårdata'/); assert.match(page, /JSON\.stringify\(npc\.profile, null, '\\t'\)/); assert.doesNotMatch(page, /jsnview|cdn\.jsdelivr/); });