const {test}=require('node:test'); const assert=require('node:assert/strict'); const {workspaceFixture,html}=require('./workspace_fixture.cjs'); function fixture() { const f=workspaceFixture(); const start=html.indexOf('// ---- Read-only game storage ----'); f.run(html.slice(start,html.indexOf('// ---- Backup and recovery kit',start))); const size=html.indexOf('function sizeText('); f.run(html.slice(size,html.indexOf('const backupKinds',size))); return f; } const sample={home:{state:'ok',total:1000,free:200,used:700},discovery:'permission-denied',libraries:[{ path:'',capacity:{state:'missing'},state:'partial',gameBytes:10,toolBytes:0, recordedBytes:10,unknownSizes:1,issues:[{file:'bad.acf',state:'invalid-metadata'}], apps:[{appid:'1',name:'',bytes:null,kind:'game'},{appid:'2',name:'Zero',bytes:0,kind:'game'}]}]}; test('navigation reaches storage and refresh runs once per visit',()=>{ const f=fixture();let calls=0;f.context.loadStorage=()=>calls++; f.navigate('#storage');assert.equal(f.activePage,'tools');assert.equal(f.el('storage').hidden,false); assert.equal(f.el('storage').parentNode,f.el('toolWorkspace'));assert.equal(calls,1); }); test('unknown, shared capacity, partial discovery and untrusted names remain explicit',()=>{ const f=fixture();f.context.sample=sample;const out=f.run('renderStorage(sample)'); assert.match(out,/Permission denied/);assert.match(out,/Missing or disconnected/); assert.match(out,/Unknown/);assert.match(out,/0 bytes/);assert.match(out,/Partial inventory/); assert.match(out,/must not be added/);assert.match(out,/Other usage is unmeasured/); assert.match(out,/<script>/);assert.doesNotMatch(out,/