feat(target-lists): 新增黑白名单管理与实时告警功能

- rid-shared 新增 target_lists 模块,定义名单数据契约
- 地图适配器支持按名单类型着色渲染目标(白/黑/未知)
- 新增名单筛选器与目标目录过滤联动
- 实时详情面板支持加入/编辑白名单与黑名单操作
- 新增黑名单命中告警横幅与事件日志高亮
- 新增名单管理浮层(Manager 组件)与徽章展示
- 底图默认切换为影像图,相机初始俯仰角归零
- color-scheme 切换为 dark,新增 glass/workbench 样式
```
This commit is contained in:
2026-10-23 09:12:50 +08:00
parent 3cf50f2e8b
commit df9e8bdeb5
24 changed files with 1481 additions and 120 deletions
+12 -10
View File
@@ -21,7 +21,7 @@ let output='',child,browser;const errors=[],csp=[];
function start(){const previous=process.env.TIANDITU_TOKEN;delete process.env.TIANDITU_TOKEN;child=spawn(exe,['--data-root',root,'--simulation-api'],{env:{...process.env,PATH:'C:\\Windows\\System32',RID_TEST_PORT:'18890'},windowsHide:true,stdio:['ignore','pipe','pipe']});if(previous!==undefined)process.env.TIANDITU_TOKEN=previous;child.stdout.on('data',b=>output+=b);child.stderr.on('data',b=>output+=b);child.on('error',e=>output+=e.message);}
async function ready(){for(let i=0;i<150;i++){if(child.exitCode!==null)throw Error(output);try{if((await fetch(base+'/api/appearance')).ok)return;}catch{}await new Promise(r=>setTimeout(r,100));}throw Error('server timeout '+output);}
async function stop(){if(child&&child.exitCode===null){const done=new Promise(r=>child.once('exit',r));child.kill();await done;}}
let report={};let keepalive;let minimumOptionContrast=Infinity;
let report={};let keepalive;
const wait=ms=>new Promise(r=>setTimeout(r,ms));
const token=JSON.parse(await readFile(path.resolve('maps/config.json'),'utf8')).tianditu_token;
await mkdir(path.join(root,'maps'),{recursive:true});await writeFile(path.join(root,'maps/config.json'),JSON.stringify({tianditu_token:token}));
@@ -30,20 +30,22 @@ try {
for(const file of ['index.html','map-adapter.js','workspace-native.css']){const response=await fetch(base+'/'+(file==='index.html'?'realtime':file));assert.equal(response.status,200);const body=await response.text();assert.ok(body===await readFile(path.join('dist/web-ui',file),'utf8'),'stale embedded '+file);assert.ok(!body.includes(token),'credential in frontend');}
const initial=await(await fetch(base+'/api/maps/status')).json();assert.equal(initial.keyConfigured,true);assert.ok(!JSON.stringify(initial).includes(token));
browser=await chromium.launch({headless:true,executablePath:process.env.RID_BROWSER_PATH||'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'});
const context=await browser.newContext({viewport:{width:1600,height:1000}});const page=await context.newPage();const loaded=new Set();let credentialRequest=false;
const context=await browser.newContext({viewport:{width:1600,height:1000}});await context.addInitScript(()=>localStorage.setItem('rid.realtime.basemap.v1','road'));const page=await context.newPage();const loaded=new Set();let credentialRequest=false;
page.on('pageerror',e=>errors.push(e.message));page.on('console',m=>{if(/violates.*Content Security|Refused.*policy/i.test(m.text()))csp.push(m.text())});
page.on('request',r=>{if(r.url().includes(token)||r.url().includes('tianditu.gov.cn'))credentialRequest=true;});
page.on('response',r=>{const m=r.url().match(/\/api\/maps\/tile\/([^/]+)\//);if(m&&r.status()===200)loaded.add(m[1]);});
await page.goto(base+'/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();const picker=page.getByRole('combobox',{name:'底图类型'});assert.equal(await picker.inputValue(),'road');
await page.waitForFunction(()=>window.ridMap?.metrics().mapReady);await page.waitForFunction(()=>document.querySelector('.mc-map-infobar').textContent.includes('路网图')&&!document.querySelector('.mc-map-infobar').textContent.includes('暂无'),null,{timeout:45000});
await page.goto(base+'/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();assert.equal(await page.locator('.mc-map-toolstrip').count(),0);await page.waitForFunction(()=>{const m=window.ridMap?.metrics();return m?.mapReady&&m.baseTiles[0].includes('img_w')&&m.labelTiles[0].includes('cia_w')});await page.waitForFunction(()=>document.querySelector('.mc-map-infobar').textContent.includes('影像+路网')&&!document.querySelector('.mc-map-infobar').textContent.includes('暂无'),null,{timeout:45000});await page.screenshot({path:path.join(root,'hybrid-default.png')});await changeBasemap('road');
await page.waitForFunction(()=>window.ridMap?.metrics().mapReady);await page.waitForFunction(()=>window.ridMap.metrics().basemap==='road'&&!document.querySelector('.mc-map-infobar').textContent.includes('暂无'),null,{timeout:45000});
async function changeBasemap(value){await page.evaluate(v=>window.ridMap.setBasemap(v),value);}
assert.deepEqual(await page.evaluate(()=>{const {pitch,bearing}=window.ridMap.metrics().camera;return {pitch,bearing}}),{pitch:0,bearing:0});
async function ingest(sequence){const r=await fetch(base+'/api/realtime/ingest',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify([{target_id:'MAP-TEST-001',receiver_id:'MAP-TEST',source_epoch:1,sequence,longitude:120.1538,latitude:30.2874,altitude_m:120,heading_deg:42}])});assert.equal(r.status,200)}
let seq=1;await ingest(seq);keepalive=setInterval(()=>ingest(++seq).catch(()=>{}),5000);await page.getByRole('button',{name:'MAP-TEST-001',exact:true}).click();await wait(500);const camera=(await page.evaluate(()=>window.ridMap.metrics())).camera;
await page.screenshot({path:path.join(root,'road-live.png')});
await picker.selectOption('imagery');await page.waitForFunction(()=>window.ridMap.metrics().baseTiles[0].includes('img_w'));await page.waitForFunction(()=>document.querySelector('.mc-map-infobar').textContent.includes('影像图')&&!document.querySelector('.mc-map-infobar').textContent.includes('暂无'),null,{timeout:45000});await wait(1200);await page.screenshot({path:path.join(root,'imagery-live.png')});
for(let i=0;i<8;i++)await picker.selectOption(i%2?'imagery':'road');await wait(1200);
await changeBasemap('imagery');await page.waitForFunction(()=>window.ridMap.metrics().baseTiles[0].includes('img_w'));await page.waitForFunction(()=>document.querySelector('.mc-map-infobar').textContent.includes('影像+路网')&&!document.querySelector('.mc-map-infobar').textContent.includes('暂无'),null,{timeout:45000});await wait(1200);await page.screenshot({path:path.join(root,'imagery-live.png')});
for(let i=0;i<8;i++)await changeBasemap(i%2?'imagery':'road');await wait(1200);
const switched=await page.evaluate(()=>window.ridMap.metrics());assert.equal(switched.mapCreations,1);assert.equal(switched.targets,1);assert.deepEqual(switched.camera,camera);assert.ok(switched.labelTiles[0].includes('cia_w'));assert.ok(switched.selectedTrailPoints>0);
await page.reload();await picker.waitFor();assert.equal(await picker.inputValue(),'imagery');await page.waitForFunction(()=>window.ridMap?.metrics().mapReady);await wait(3500);
for(const [width,height]of [[1600,1000],[1280,720],[390,844],[360,740]]){await page.setViewportSize({width,height});await wait(250);for(const theme of ['graphite','blue','white']){await page.evaluate(t=>{document.body.classList.remove('theme-blue','theme-white');if(t!=='graphite')document.body.classList.add('theme-'+t)},theme);const clipped=await page.evaluate(()=>{const bar=document.querySelector('.mc-map-toolstrip').getBoundingClientRect();return [...document.querySelectorAll('.mc-map-toolstrip button,.mc-map-toolstrip select')].some(e=>{const r=e.getBoundingClientRect();return r.left<bar.left-1||r.right>bar.right+1||r.right>innerWidth||r.top<bar.top-1||r.bottom>bar.bottom+1})});assert.equal(clipped,false,JSON.stringify({width,height,theme}));assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);const contrast=await picker.locator('option').first().evaluate(e=>{const s=getComputedStyle(e);const lum=color=>{const rgb=color.match(/[\d.]+/g).slice(0,3).map(Number).map(v=>{v/=255;return v<=.04045?v/12.92:((v+.055)/1.055)**2.4});return rgb[0]*.2126+rgb[1]*.7152+rgb[2]*.0722};const a=lum(s.color),b=lum(s.backgroundColor);return (Math.max(a,b)+.05)/(Math.min(a,b)+.05)});minimumOptionContrast=Math.min(minimumOptionContrast,contrast);assert.ok(contrast>=4.5,'Basemap option contrast is insufficient in '+theme);}}
await page.reload();await page.waitForFunction(()=>window.ridMap?.metrics().basemap==='imagery');await page.waitForFunction(()=>window.ridMap?.metrics().mapReady);await wait(3500);
for(const [width,height]of [[1600,1000],[1280,720],[390,844],[360,740]]){await page.setViewportSize({width,height});await wait(250);assert.equal(await page.locator('.mc-map-toolstrip').count(),0);assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);assert.equal(await page.evaluate(()=>window.ridMap.metrics().camera.pitch),0);}
await page.setViewportSize({width:1600,height:1000});await page.evaluate(()=>document.body.classList.remove('theme-blue','theme-white'));await wait(250);
// Browser failure/recovery fixtures; backend outage/timeout/offline paths are tested with real local mock upstreams in Rust.
let fixture={provider:'tianditu',keyConfigured:true,mode:'offline',retryAfterMs:Date.now()+30000,layers:{img_w:{source:'missing',error:'key-or-permission'},cia_w:{source:'missing',error:'key-or-permission'}}};
@@ -53,7 +55,7 @@ try {
assert.deepEqual([...loaded].sort(),['cia_w','cva_w','img_w','vec_w']);assert.equal(credentialRequest,false);assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);
const status=await(await fetch(base+'/api/maps/status')).json();assert.ok(status.servedOnline>0);assert.ok(status.servedOffline>0);assert.equal((await(await fetch(base+'/api/realtime/status')).json()).clients,1);
assert.ok(!output.includes(token),'credential in server log');
await picker.selectOption('road');await wait(4000);await page.screenshot({path:path.join(root,'road-final.png')});await picker.selectOption('imagery');await wait(4000);await page.screenshot({path:path.join(root,'imagery-final.png')});
report={status:'PASS',root,exe,serverPid:child.pid,loadedLayers:[...loaded].sort(),servedOnline:status.servedOnline,servedOffline:status.servedOffline,mapCreations:switched.mapCreations,frames:12,minimumOptionContrast,checks:['real-road-and-labels','real-imagery-and-labels','same-camera-target-trail-on-switch','preference-after-reload','toolbar-four-sizes-three-themes','dropdown-text-contrast','credential-not-in-browser-or-log','error-and-recovery-ui-fixtures','one-worker-connection'],note:'Real TianDiTu tiles; isolated synthetic target. Actual upstream outage tests run in Rust, browser recovery uses provider-state fixtures.'};console.log(JSON.stringify(report));
await changeBasemap('road');await wait(4000);await page.screenshot({path:path.join(root,'road-final.png')});await changeBasemap('imagery');await wait(4000);await page.screenshot({path:path.join(root,'imagery-final.png')});
report={status:'PASS',root,exe,serverPid:child.pid,loadedLayers:[...loaded].sort(),servedOnline:status.servedOnline,servedOffline:status.servedOffline,mapCreations:switched.mapCreations,frames:12,checks:['legacy-road-preference-upgrades-to-hybrid-default','real-road-and-labels','real-imagery-and-labels','same-camera-target-trail-on-switch','preference-after-reload','removed-toolbar-four-sizes','topdown-default','credential-not-in-browser-or-log','error-and-recovery-ui-fixtures','one-worker-connection'],note:'Real TianDiTu tiles; isolated synthetic target. Actual upstream outage tests run in Rust, browser recovery uses provider-state fixtures.'};console.log(JSON.stringify(report));
}finally{clearInterval(keepalive);if(browser){if(report.status!=='PASS'){const p=browser.contexts()[0]?.pages()[0];if(p){await p.screenshot({path:path.join(root,'failure.png')}).catch(()=>{});console.log(JSON.stringify({root,errors,csp,diagnostic:await p.evaluate(()=>({label:document.querySelector('.mc-map-infobar')?.textContent,metrics:window.ridMap?.metrics()})).catch(()=>null)}));}}await browser.close();}await stop();for(const socket of sockets)socket.destroy();const closed=new Promise(r=>proxy.close(r));proxy.closeAllConnections();await closed;await writeFile(path.join(root,'server.log'),output);await writeFile(path.join(root,'maps-report.json'),JSON.stringify({...report,errors,csp},null,2));}
+25 -5
View File
@@ -24,6 +24,23 @@ async function ready(){for(let i=0;i<150;i++){if(child.exitCode!==null)throw Err
async function stop(){if(child&&child.exitCode===null){const done=new Promise(r=>child.once('exit',r));child.kill();await done;}}
async function preferences(){return (await fetch(base+'/api/appearance')).json();}
async function waitPref(predicate){for(let i=0;i<80;i++){const p=await preferences();if(predicate(p))return p;await new Promise(r=>setTimeout(r,100));}throw Error('preferences timeout');}
async function setLegacyTheme(page, theme) {
const screen = await page.locator("body").getAttribute("data-screen");
const query = await page.locator("#history-query").count() ? await page.locator("#history-query").inputValue() : "";
const current = await preferences();
const response = await fetch(base+'/api/appearance', {method:'PATCH', headers:{'content-type':'application/json'}, body:JSON.stringify({...current, theme})});
assert.equal(response.status, 200);
await page.reload();
await page.waitForFunction(t => document.body.dataset.theme === t, theme);
if (screen !== await page.locator("body").getAttribute("data-screen")) {
if (await page.locator("body").getAttribute("data-screen") !== "home") await page.getByRole("button",{name:"返回应用总览",exact:true}).click();
await page.locator("#home-app-"+screen).click();
}
if (query) { await page.locator("#history-query").fill(query); const total=(await (await fetch(base+"/api/records?page=1&q="+encodeURIComponent(query))).json()).total; await page.locator("#page-status").filter({hasText:"共 "+total+" 条"}).waitFor(); }
assert.equal(await page.locator('.theme-quick, .theme-cards').count(), 0);
assert.equal(await page.locator('body').evaluate(e => getComputedStyle(e).getPropertyValue('--work-panel').trim()), 'rgba(6, 18, 33, .40)');
}
try {
await new Promise((resolve,reject)=>{proxy.once('error',reject);proxy.listen(frontendPort,'127.0.0.1',resolve)});
@@ -67,6 +84,9 @@ try {
console.log('STAGE submit');
// Failure restores all controls and keeps draft + photos; busy navigation is blocked.
await page.locator('#serial-no').fill('B-NEW-001');await page.locator('#model-name').fill('验收新机');await page.locator('#owner-name').fill('原始快照');await choose('#photo-1','snapshot.png');await readyPhoto(0,'snapshot.png');
const draftPhoto=await page.locator('#slot-preview-0').getAttribute('src');
await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('#home-app-settings').click();await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('#home-app-register').click();
assert.equal(await page.locator('#serial-no').inputValue(),'B-NEW-001');assert.equal(await page.locator('#owner-name').inputValue(),'原始快照');assert.equal(await page.locator('#slot-preview-0').getAttribute('src'),draftPhoto);assert.equal(await page.evaluate(()=>window.ridPhotoUrls.size),1);
let requests=0;
await page.route('**/api/records',async route=>{if(route.request().method()==='POST'){requests++;assert.equal(route.request().postDataJSON().ownerName,'原始快照');await new Promise(r=>setTimeout(r,450));await route.fulfill({status:500,contentType:'application/json',body:JSON.stringify({error:'隔离验收失败'})})}else await route.continue()});
const sent=page.waitForRequest(r=>r.url().endsWith('/api/records')&&r.method()==='POST');await page.locator('#register-button').click();await sent;assert.equal(await page.locator('#serial-no').isDisabled(),true);assert.equal(await page.locator('#new-registration').isDisabled(),true);await page.getByRole('button',{name:'返回应用总览',exact:true}).click();assert.equal(await page.locator('body').getAttribute('data-screen'),'register');await page.locator('#register-form').evaluate(f=>{f.dispatchEvent(new Event('submit',{bubbles:true,cancelable:true}));f.dispatchEvent(new Event('submit',{bubbles:true,cancelable:true}))});
@@ -89,17 +109,17 @@ try {
await page.locator('#edit-owner').fill('不得保存');await page.locator('#edit-photo-1').setInputFiles({name:'bad.png',mimeType:'image/png',buffer:Buffer.from('bad')});await page.locator('#slot-status-2.error').waitFor();await page.locator('#edit-save').click();await page.locator('#edit-message').filter({hasText:'照片内容与格式不符'}).waitFor();assert.equal((await(await fetch(base+'/api/records?q=B-NEW-001')).json()).records[0].ownerName,'更新登记人');await page.locator('#edit-cancel').click();
await edit();await page.locator('#edit-owner').fill('修改后');await page.locator('#edit-delete-1').check();await choose('#edit-photo-2','replacement.png');await readyPhoto(3,'replacement.png');await page.locator('#edit-save').click();await page.locator('#edit-dialog').waitFor({state:'hidden'});await page.locator('#history-message').filter({hasText:'档案修改已保存'}).waitFor();records=(await(await fetch(base+'/api/records?q=B-NEW-001')).json()).records;assert.equal(records[0].photo1Url,null);assert.ok(records[0].photo2Url);assert.equal(records[0].ownerName,'修改后');
console.log('STAGE geometry');
// Three themes and viewport/zoom geometry, including the final helper and save button.
// Legacy theme preferences share one material; verify viewport/zoom geometry.
const cases=[];await page.locator('#new-registration').click();
for(const theme of ['graphite','blue','white']){await page.locator('.theme-quick [data-theme='+theme+']').click();await waitPref(p=>p.theme===theme);
for(const [width,height]of [[1600,1000],[1366,768],[1080,900],[390,844],[1366,600]]){await page.setViewportSize({width,height});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);await page.locator('.registration-photos').scrollIntoViewIfNeeded();await page.locator('#register-button').scrollIntoViewIfNeeded();const box=await page.locator('#register-button').boundingBox();assert.ok(box.x>=0&&box.x+box.width<=width&&box.y>=48&&box.y+box.height<=height+1);await page.locator('#register-form>.registry-group:last-of-type>.registry-help').scrollIntoViewIfNeeded();const overlap=await page.evaluate(()=>{const a=document.querySelector('#register-form>.registry-group:last-of-type>.registry-help').getBoundingClientRect(),b=document.querySelector('.registration-savebar').getBoundingClientRect();return a.bottom>b.top&&a.top<b.bottom});assert.equal(overlap,false);cases.push({theme,width,height});if(width===1600){await page.locator('.registration-heading').scrollIntoViewIfNeeded();await page.screenshot({path:path.join(root,'register-'+theme+'.png')})}}
for(const theme of ['graphite','blue','white']){await setLegacyTheme(page,theme);
for(const [width,height]of [[1600,1000],[1366,768],[1080,900],[390,844],[1366,600]]){await page.setViewportSize({width,height});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);await page.locator('.registration-photos').scrollIntoViewIfNeeded();await page.locator('#register-button').scrollIntoViewIfNeeded();const box=await page.locator('#register-button').boundingBox();assert.ok(box.x>=0&&box.x+box.width<=width&&box.y>=48&&box.y+box.height<=height+1);await page.locator('#register-form .registration-fields-scroll>.registry-group:last-of-type>.registry-help').scrollIntoViewIfNeeded();const overlap=await page.evaluate(()=>{const a=document.querySelector('#register-form .registration-fields-scroll>.registry-group:last-of-type>.registry-help').getBoundingClientRect(),b=document.querySelector('.registration-savebar').getBoundingClientRect();return a.bottom>b.top&&a.top<b.bottom});assert.equal(overlap,false);cases.push({theme,width,height});if(width===1600){await page.locator('.registration-heading').scrollIntoViewIfNeeded();await page.screenshot({path:path.join(root,'register-'+theme+'.png')})}}
}
await page.setViewportSize({width:1600,height:1000});await page.evaluate(()=>document.documentElement.style.zoom='2');assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);await page.locator('#register-button').scrollIntoViewIfNeeded();await page.screenshot({path:path.join(root,'register-zoom200.png')});await page.evaluate(()=>document.documentElement.style.zoom='');
await page.setViewportSize({width:390,height:844});await page.locator('#history-title').scrollIntoViewIfNeeded();const mobileBar=await page.locator('.registration-savebar').boundingBox();const mobileHistory=await page.locator('#history-title').boundingBox();assert.ok(mobileBar.y+mobileBar.height<=mobileHistory.y);await page.setViewportSize({width:1600,height:1000});
await page.setViewportSize({width:390,height:844});await page.locator('#history-title').scrollIntoViewIfNeeded();const mobileHistory=await page.locator('.history-panel').boundingBox();const mobileEditor=await page.locator('.registration-editor').boundingBox();assert.ok(mobileHistory.height<=280.5);assert.ok(mobileHistory.y+mobileHistory.height<=mobileEditor.y);await page.setViewportSize({width:1600,height:1000});
console.log('STAGE delete');
// Delete current result and preserve unrelated records.
await own.getByRole('button',{name:'查看档案 →',exact:true}).click();await own.locator('.archive-more').click();page.once('dialog',d=>d.accept());await own.getByRole('button',{name:'删除档案',exact:true}).click();await page.locator('#empty-result').waitFor();await page.locator('#page-status').filter({hasText:'共 0 条'}).waitFor();assert.equal((await(await fetch(base+'/api/records?page=1')).json()).total,21);
await page.locator('#history-query').fill('');await page.locator('#page-status').filter({hasText:'共 21 条'}).waitFor();await page.locator('#next-page').click();await page.locator('#page-status').filter({hasText:'第 2 / 2 页'}).waitFor();assert.equal(await page.locator('.archive-card').count(),1);
assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);
await writeFile(path.join(root,'report.json'),JSON.stringify({status:'PASS',root,errors,csp,cases,scenarios:['real Rust/Wasm registration B','validated photo preservation, cancel, replacement, reset, stale decode','immutable submit, failed save, duplicate suppression, busy navigation','draft/result separation, new confirmation','menu focus, selection redraw, current-page Excel and ZIP','duplicate SN, edit atomicity and delete current result','QR PNG and clipboard/archive links','three themes, 15 viewport cases, 200% zoom, mobile save boundary']},null,2));console.log(JSON.stringify({status:'PASS',root}));
await writeFile(path.join(root,'report.json'),JSON.stringify({status:'PASS',root,errors,csp,cases,scenarios:['real Rust/Wasm registration B','validated photo preservation, cancel, replacement, reset, stale decode','immutable submit, failed save, duplicate suppression, busy navigation','draft/result separation, new confirmation','menu focus, selection redraw, current-page Excel and ZIP','duplicate SN, edit atomicity and delete current result','QR PNG and clipboard/archive links','three legacy theme values, 15 viewport cases, 200% zoom, mobile save boundary']},null,2));console.log(JSON.stringify({status:'PASS',root}));
}catch(e){console.log('FAILED ROOT',root,e.stack);if(browser){const pages=browser.contexts().flatMap(c=>c.pages());if(pages[0])await pages[0].screenshot({path:path.join(root,'failed.png')}).catch(()=>{});}throw e;}finally{if(browser)await browser.close();await stop();for(const socket of sockets)socket.destroy();await new Promise(r=>proxy.close(r));await writeFile(path.join(root,'server.log'),output)}
+118 -15
View File
@@ -1,5 +1,5 @@
// Real Rust/Wasm acceptance in an isolated database. Never opens receiver transports.
import {mkdtemp,writeFile} from 'node:fs/promises';
import {mkdtemp,writeFile,readFile} from 'node:fs/promises';
import {tmpdir} from 'node:os';
import path from 'node:path';
import {spawn} from 'node:child_process';
@@ -8,6 +8,14 @@ import assert from 'node:assert/strict';
import http from 'node:http';
import net from 'node:net';
const {chromium}=createRequire(import.meta.url)('playwright');
const {PNG}=createRequire(import.meta.url)('pngjs');
const contrastCases=[];
async function contrast(page, label, selectors, required=true) {
const samples=await page.evaluate(selectors=>selectors.map(selector=>{const e=document.querySelector(selector),r=e.getBoundingClientRect();return {selector,color:getComputedStyle(e).color,x:Math.round(r.left+2),y:Math.round(r.top-2)}}),selectors);
const png=PNG.sync.read(await page.screenshot());
const lum=rgb=>rgb.map(v=>v/255).map(v=>v<=.04045?v/12.92:((v+.055)/1.055)**2.4).reduce((s,v,i)=>s+v*[.2126,.7152,.0722][i],0);
for(const sample of samples){const offset=(sample.y*png.width+sample.x)*4;const a=lum(sample.color.match(/[\d.]+/g).slice(0,3).map(Number)),b=lum([...png.data.subarray(offset,offset+3)]);const ratio=(Math.max(a,b)+.05)/(Math.min(a,b)+.05);contrastCases.push({label,selector:sample.selector,ratio});if(required)assert.ok(ratio>=4.5,JSON.stringify({label,...sample,ratio}));}
}
const root=await mkdtemp(path.join(tmpdir(),'RID-workspace-'));
const exe=process.argv[2]||'D:/Rust_Contact/util/target/Rid_Drone_Receivev/release/fpv-rid-registry-fullstack.exe';
const frontendPort=Number(process.env.RID_BROWSER_TEST_PORT||18787),backendPort=Number(process.env.RID_BACKEND_TEST_PORT||18788);
@@ -24,16 +32,35 @@ async function ready(){for(let i=0;i<150;i++){if(child.exitCode!==null)throw Err
async function stop(){if(child&&child.exitCode===null){const done=new Promise(r=>child.once('exit',r));child.kill();await done;}}
async function preferences(){return (await fetch(base+'/api/appearance')).json();}
async function waitPref(predicate){for(let i=0;i<80;i++){const p=await preferences();if(predicate(p))return p;await new Promise(r=>setTimeout(r,100));}throw Error('preferences timeout');}
async function setLegacyTheme(page, theme) {
const screen = await page.locator("body").getAttribute("data-screen");
const query = await page.locator("#history-query").count() ? await page.locator("#history-query").inputValue() : "";
const current = await preferences();
const response = await fetch(base+'/api/appearance', {method:'PATCH', headers:{'content-type':'application/json'}, body:JSON.stringify({...current, theme})});
assert.equal(response.status, 200);
await page.reload();
await page.waitForFunction(t => document.body.dataset.theme === t, theme);
if (screen !== await page.locator("body").getAttribute("data-screen")) {
if (await page.locator("body").getAttribute("data-screen") !== "home") await page.getByRole("button",{name:"返回应用总览",exact:true}).click();
await page.locator("#home-app-"+screen).click();
}
if (query) { await page.locator("#history-query").fill(query); const total=(await (await fetch(base+"/api/records?page=1&q="+encodeURIComponent(query))).json()).total; await page.locator("#page-status").filter({hasText:"共 "+total+" 条"}).waitFor(); }
assert.equal(await page.locator('.theme-quick, .theme-cards').count(), 0);
assert.equal(await page.locator('body').evaluate(e => getComputedStyle(e).getPropertyValue('--work-panel').trim()), 'rgba(6, 18, 33, .40)');
}
try{
await new Promise((resolve,reject)=>{proxy.once('error',reject);proxy.listen(frontendPort,'127.0.0.1',resolve)});start();await ready();browser=await chromium.launch({headless:true,executablePath:process.env.RID_BROWSER_PATH||'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'});
const context=await browser.newContext({viewport:{width:1600,height:1000},acceptDownloads:true});const page=await context.newPage();page.on('pageerror',e=>errors.push(e.message));page.on('console',m=>{if(/violates.*Content Security|Refused.*policy/i.test(m.text()))csp.push(m.text());});
for(const asset of ['glass.css','workbench.css'])assert.equal(await (await fetch(base+'/'+asset)).text(), await readFile('crates/web-ui/public/'+asset,'utf8'));
await page.goto(base);await page.locator('body[data-screen=home]').waitFor();
assert.equal((await preferences()).wallpaper,'B4');
assert.equal(await page.locator('.home-card').count(),3);
assert.equal(await page.locator('.reference-rail').isVisible(),false);
assert.equal(await page.locator('#toggle-menu').isVisible(),false);
assert.equal(await page.locator('#home-top').isVisible(),true);
await page.keyboard.press('Tab');assert.equal(await page.evaluate(()=>document.activeElement.id),'home-app-register');
assert.equal(await page.locator('.reference-rail').isVisible(),true);
assert.equal(await page.locator('#toggle-menu').isVisible(),true);
assert.equal(await page.locator('#home-top').count(),0);
await page.keyboard.press('Tab');assert.equal(await page.evaluate(()=>document.activeElement.id),'toggle-menu');
await page.locator('#home-app-register').focus();
await page.keyboard.press('Enter');await page.locator('body[data-screen=register]').waitFor();
assert.equal(await page.locator('.reference-rail').isVisible(),true);
await page.locator('#toggle-menu').click();assert.equal(await page.locator('.reference-rail').isVisible(),false);
@@ -44,37 +71,113 @@ try{
await page.keyboard.press('Space');await preferenceLoaded;await page.locator('#appearance-view').waitFor();
assert.equal(await page.locator('.reference-rail').isVisible(),false); // home did not reset the user's collapsed navigation.
await page.locator('#toggle-menu').click();assert.equal(await page.locator('.reference-rail').isVisible(),true);
const homeCases=[];
const homeCases=[],workbenchCases=[];
for(const theme of ['blue','white','graphite']){
await page.locator('.theme-quick [data-theme='+theme+']').click();await waitPref(p=>p.theme===theme);assert.equal(await page.locator('body').getAttribute('data-theme'),theme);await page.screenshot({path:path.join(root,'settings-'+theme+'.png')});
await setLegacyTheme(page,theme);assert.equal(await page.locator('body').getAttribute('data-theme'),theme);await page.screenshot({path:path.join(root,'settings-'+theme+'.png')});
await page.getByRole('button',{name:'返回应用总览',exact:true}).click();
assert.equal(await page.evaluate(()=>document.activeElement.id),'home-app-settings');
await page.waitForFunction(()=>[...document.querySelectorAll('.home-app-icon')].every(i=>i.complete&&i.naturalWidth>0));
for(const [width,height] of [[1600,1000],[1366,768],[1080,900],[390,844],[1366,600]]){
await page.setViewportSize({width,height});
assert.equal(await page.locator('.reference-rail').isVisible(),false);
const dimensions=await page.locator('.home-launcher').boundingBox();assert.equal(Math.round(dimensions.x),0);assert.equal(Math.round(dimensions.y),48);assert.equal(Math.round(dimensions.width),width);assert.equal(Math.round(dimensions.y+dimensions.height),height);
assert.equal(await page.locator('.reference-rail').isVisible(),true);
const dimensions=await page.locator('.home-launcher').boundingBox();const railWidth=width<=760?56:68;assert.equal(Math.round(dimensions.x),railWidth);assert.equal(Math.round(dimensions.y),48);assert.equal(Math.round(dimensions.width),width-railWidth);assert.equal(Math.round(dimensions.y+dimensions.height),height);
assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);
await page.locator('#home-app-settings').scrollIntoViewIfNeeded();
assert.equal(await page.locator('#home-app-settings').isVisible(),true);
homeCases.push({theme,width,height});
if(width===1600){await page.mouse.move(1550,20);await page.screenshot({path:path.join(root,'home-'+theme+'.png')});}
if(width===1600){await page.mouse.move(1550,20);await page.screenshot({path:path.join(root,'home-'+theme+'.png')});await contrast(page,'home-'+theme,['.home-heading p','.home-card-desc']);}
}
await page.setViewportSize({width:1600,height:1000});await page.locator('#home-app-settings').click();await page.locator('#appearance-view').waitFor();
}
await writeFile(path.join(root,'home-viewport-cases.json'),JSON.stringify(homeCases,null,2));
// Verify materials on both built-in reference wallpapers and a bright custom image.
for (const wall of ['B4','B1']) {
await page.locator('[data-wall='+wall+']').click();await waitPref(p=>p.wallpaper===wall);
await page.waitForFunction(w=>document.getElementById('appearance-wallpaper').src.includes(w+'-wallpaper'),wall);
for (const [width,height] of [[1600,1000],[1366,768],[390,844]]) {
await page.setViewportSize({width,height});
assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);
await page.screenshot({path:path.join(root,`settings-${wall}-${width}.png`)});
}
}
await page.setViewportSize({width:1600,height:1000});
// Verify the A workbench columns and all three panels at every breakpoint.
for(const [width,height] of [[1600,1000],[1366,600],[1080,900],[820,900],[390,844]]){
await page.setViewportSize({width,height});
for(const screen of ['settings','register']){
if(screen==='register')await page.locator('.reference-rail [data-open=register]').click();
const layoutRoot=page.locator(screen==='settings'?'.settings-layout':'.registry-workspace');
const available=await page.locator(screen==='settings'?'#appearance-view':'#workspace-content').evaluate(e=>e.clientWidth);
const columns=available>=1200?3:available>=768?2:1;
const actual=await layoutRoot.evaluate(e=>getComputedStyle(e).display==='flex'?1:getComputedStyle(e).gridTemplateColumns.split(' ').length);
assert.equal(actual,columns,JSON.stringify({screen,width,available,actual}));
assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);
if(screen==='settings'){
assert.equal(await page.locator('.settings-preview').isVisible(),true);
const sample=await page.locator('#desktop-sample').boundingBox();assert.equal(Math.round(sample.height),180);
await page.locator('#appearance-view').evaluate(e=>e.scrollTop=0);
}else{
assert.equal(await page.locator('#registration-result').isVisible(),true);
await page.locator('#register-button').scrollIntoViewIfNeeded();
const save=await page.locator('#register-button').boundingBox();assert.ok(save.y>=48&&save.y+save.height<=height+1);
await page.locator('#workspace-content').evaluate(e=>e.scrollTop=0);
}
await page.screenshot({path:path.join(root,`workbench-${screen}-${width}.png`)});
workbenchCases.push({screen,width,height,columns});
}
await page.locator('.reference-rail [data-open=settings]').click();
}
await page.setViewportSize({width:1600,height:1000});
const savedBeforeSection=await preferences();
await page.locator('[data-setting-section=appearance-display]').click();
assert.equal(await page.evaluate(()=>document.activeElement.id),'appearance-display');
assert.equal((await preferences()).revision,savedBeforeSection.revision);
await page.locator('[data-setting-section=appearance-wallpapers]').click();
let failAppearance=true;
await page.route('**/api/appearance',route=>{if(route.request().method()==='PATCH'&&failAppearance){failAppearance=false;return route.fulfill({status:503,contentType:'application/json',body:JSON.stringify({error:'隔离外观保存失败'})})}return route.continue()});
await page.locator('#dim').fill('35');await page.locator('#dim').dispatchEvent('input');
await page.locator('#wall-message.error').filter({hasText:'隔离外观保存失败'}).waitFor();
assert.equal((await preferences()).dim,savedBeforeSection.dim);
assert.equal(await page.locator('#appearance-dim-value').innerText(),savedBeforeSection.dim+'%');
await page.unroute('**/api/appearance');
await page.locator('[data-wall=B2]').click();await waitPref(p=>p.wallpaper==='B2');await page.locator('#dim').fill('28');await page.locator('#dim').dispatchEvent('input');await waitPref(p=>p.dim===28);
assert.equal(await page.locator('#appearance-dim-value').innerText(),'28%');
await page.locator('#blur').fill('3');await page.locator('#blur').dispatchEvent('input');await waitPref(p=>p.blur===3);
assert.equal(await page.locator('#appearance-blur-value').innerText(),'3 px');
assert.equal(await page.locator('#desktop-sample').evaluate(e=>e.style.getPropertyValue('--preview-blur')),'3px');
assert.equal(await page.locator('#desktop-sample').evaluate(e=>e.style.getPropertyValue('--preview-shade')),'0.28');
await page.locator('#fit').selectOption('contain');await waitPref(p=>p.fit==='contain');assert.equal(await page.locator('#appearance-fit-value').innerText(),'完整显示');
assert.equal(await page.locator('#appearance-wallpaper').evaluate(e=>getComputedStyle(e).objectFit),'contain');
await page.locator('#fit').selectOption('cover');await waitPref(p=>p.fit==='cover');
await page.locator('#blur').fill('0');await page.locator('#blur').dispatchEvent('input');await waitPref(p=>p.blur===0);
const picture=await page.screenshot();await page.locator('#custom-wallpaper').setInputFiles({name:'wallpaper.png',mimeType:'image/png',buffer:picture});const uploaded=await waitPref(p=>p.image?.startsWith('data:image/jpeg'));
const second=await browser.newContext();const other=await second.newPage();await other.goto(base);await other.waitForFunction(()=>document.querySelector('#workspace-wallpaper').src.startsWith('data:image/jpeg'));assert.equal(await other.locator('body').getAttribute('data-theme'),'graphite');await second.close();
const stale=await fetch(base+'/api/appearance',{method:'PATCH',headers:{'content-type':'application/json'},body:JSON.stringify({...uploaded,revision:0})});assert.equal(stale.status,400);
const invalid=await fetch(base+'/api/appearance',{method:'PATCH',headers:{'content-type':'application/json'},body:JSON.stringify({...uploaded,image:'data:image/png;base64,bm90LWEtcG5n'})});assert.equal(invalid.status,400);assert.equal((await preferences()).revision,uploaded.revision);
await page.locator('#custom-wallpaper').setInputFiles({name:'bad.txt',mimeType:'text/plain',buffer:Buffer.from('bad')});await page.locator('#wall-message.error').waitFor();assert.equal((await preferences()).revision,uploaded.revision);
const brightImage=Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC','base64');
await page.locator('#custom-wallpaper').setInputFiles({name:'bright.png',mimeType:'image/png',buffer:brightImage});
await waitPref(p=>p.image!==uploaded.image&&p.image?.startsWith('data:image/jpeg'));
await page.locator('#dim').fill('0');await page.locator('#dim').dispatchEvent('input');await waitPref(p=>p.dim===0);
await page.waitForFunction(()=>{const i=document.getElementById('workspace-wallpaper');return i.complete&&i.naturalWidth>0&&i.clientWidth===innerWidth&&i.clientHeight===innerHeight});
await page.screenshot({path:path.join(root,'settings-bright.png')});
await contrast(page,'white-wallpaper-dim0',['.micro','.section-caption span','.reference-local'],false);
await page.locator('#dim').fill('28');await page.locator('#dim').dispatchEvent('input');await waitPref(p=>p.dim===28);
await contrast(page,'white-wallpaper-dim28',['.micro','.section-caption span','.reference-local']);
await page.screenshot({path:path.join(root,'settings-bright-dim28.png')});
await page.getByRole('button',{name:'返回应用总览',exact:true}).click();
await page.screenshot({path:path.join(root,'home-bright.png')});
await contrast(page,'white-wallpaper-home-dim28',['.home-heading p','.home-card-desc']);
await page.locator('#home-app-register').click();
await page.screenshot({path:path.join(root,'registry-bright.png')});
await page.getByRole('button',{name:'返回应用总览',exact:true}).click();
await page.locator('#home-app-settings').click();
await page.locator('#reset-wallpaper').click();await waitPref(p=>p.image===null&&p.dim===14&&p.wallpaper==='B4');
await page.locator('.reference-rail [data-open=register]').click();await page.locator('#serial-no').fill('LIVE-UI-0001');await page.locator('#model-name').fill('验收机型');await page.locator('#owner-name').fill('隔离数据');await page.locator('#register-button').click();await page.locator('#form-message').filter({hasText:'登记成功'}).waitFor();await page.locator('#qr-stage svg').waitFor();assert.equal((await (await fetch(base+'/api/records?q=LIVE-UI-0001')).json()).records.length,1);
const card=page.locator('.archive-card').filter({has:page.getByRole('heading',{name:'LIVE-UI-0001',exact:true})});await card.locator('.archive-more').click();await card.getByRole('button',{name:'编辑资料 / 照片'}).click();await page.locator('#edit-owner').fill('已修改');await page.locator('#edit-save').click();await page.locator('#edit-dialog').waitFor({state:'hidden'});assert.equal((await (await fetch(base+'/api/records?q=LIVE-UI-0001')).json()).records[0].ownerName,'已修改');await page.locator('#new-registration').click();assert.equal(await page.locator('#serial-no').inputValue(),'');
await page.locator('.reference-rail [data-open=register]').click();await page.locator('#serial-no').fill('LIVE-UI-0001');await page.locator('#model-name').fill('验收机型');await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('#home-app-settings').click();await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('#home-app-register').click();assert.equal(await page.locator('#serial-no').inputValue(),'LIVE-UI-0001');assert.equal(await page.locator('#model-name').inputValue(),'验收机型');await page.locator('#owner-name').fill('隔离数据');await page.locator('#register-button').click();await page.locator('#form-message').filter({hasText:'登记成功'}).waitFor();await page.locator('#qr-stage svg').waitFor();assert.equal((await (await fetch(base+'/api/records?q=LIVE-UI-0001')).json()).records.length,1);
const card=page.locator('.archive-card').filter({has:page.getByRole('heading',{name:'LIVE-UI-0001',exact:true})});await card.locator('.archive-more').click();await card.getByRole('button',{name:'编辑资料 / 照片'}).click();await page.screenshot({path:path.join(root,'edit-dialog.png')});await page.locator('#edit-owner').fill('已修改');await page.locator('#edit-save').click();await page.locator('#edit-dialog').waitFor({state:'hidden'});assert.equal((await (await fetch(base+'/api/records?q=LIVE-UI-0001')).json()).records[0].ownerName,'已修改');await page.screenshot({path:path.join(root,'registry-saved.png')});await page.locator('#new-registration').click();assert.equal(await page.locator('#serial-no').inputValue(),'');
await page.locator('#selection-toggle').click();await page.check('#select-all');const download=page.waitForEvent('download');await page.locator('#export-toggle').click();await page.locator('#export-excel').click();await (await download).saveAs(path.join(root,'records.xlsx'));
await page.screenshot({path:path.join(root,'registry.png')});
await page.locator('.reference-rail [data-open=realtime]').click();await page.waitForURL('**/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();assert.equal(await page.locator('.rt-target').count(),0);assert.ok(await page.locator('.maplibregl-canvas').count());
await page.locator('.reference-rail [data-open=realtime]').click();await page.waitForURL('**/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();assert.equal(await page.locator('.mc-map-toolstrip').count(),0);await page.waitForFunction(()=>window.ridMap?.metrics().mapReady);assert.equal(await page.evaluate(()=>window.ridMap.metrics().camera.pitch),0);assert.equal(await page.evaluate(()=>window.ridMap.metrics().camera.bearing),0);assert.equal(await page.locator('.rt-target').count(),0);assert.ok(await page.locator('.maplibregl-canvas').count());
const frames=Array.from({length:3},(_,i)=>({target_id:i===0?'LIVE-UI-0001':'LIVE-TARGET-'+i,receiver_id:'TEST',source_epoch:1,sequence:1,longitude:120+i*.001,latitude:30+i*.001,altitude_m:45+i,heading_deg:85}));const response=await fetch(base+'/api/realtime/ingest',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(frames)});assert.equal(response.status,200);await page.locator('.rt-target').filter({hasText:'LIVE-UI-0001'}).click();await page.locator('.rt-details').filter({hasText:'已匹配本地登记档案'}).waitFor();await page.locator('.rt-details').filter({hasText:'120.000000'}).waitFor();
await page.getByTitle('收起目标目录',{exact:true}).click();assert.equal(await page.locator('.live-targets').isVisible(),false);await page.getByTitle('显示目标目录',{exact:true}).click();assert.equal(await page.locator('.live-targets').isVisible(),true);await page.getByRole('button',{name:'接收器与解码',exact:true}).click();await page.locator('.rt-receiver-body').waitFor();await page.getByRole('button',{name:'目标快照与事件',exact:true}).click();
await page.waitForFunction(()=>window.ridMap?.metrics().mapReady&&window.ridMap.metrics().targets===3).catch(async e=>{console.log('MAP_DIAGNOSTIC',await page.evaluate(()=>window.ridMap?.metrics()));await page.screenshot({path:path.join(root,'map-failed.png')});throw e});
@@ -84,8 +187,8 @@ try{
await writeFile(path.join(root,'map-metrics.json'),JSON.stringify(mapMetrics,null,2));
await page.screenshot({path:path.join(root,'realtime-B.png')});
await page.locator('.live-detail a').click();await page.waitForURL('**/?app=register&q=LIVE-UI-0001');await page.locator('#page-status').filter({hasText:'共 1 条'}).waitFor();assert.equal(await page.locator('#history-query').inputValue(),'LIVE-UI-0001');await page.locator('.reference-rail [data-open=realtime]').click();await page.waitForURL('**/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();
for(const[width,height]of [[1600,1000],[1366,768],[1080,900],[390,844]]){await page.setViewportSize({width,height});for(const theme of ['graphite','blue','white']){await page.locator('.theme-quick [data-theme='+theme+']').click();await waitPref(p=>p.theme===theme);const box=await page.locator('#workspace-content').boundingBox();assert.equal(Math.round(box.y),48);assert.equal(Math.round(box.x+box.width),width);assert.equal(Math.round(box.y+box.height),height);assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);}await page.screenshot({path:path.join(root,`realtime-${width}.png`)});}
for(const[width,height]of [[1600,1000],[1366,768],[1080,900],[390,844]]){await page.setViewportSize({width,height});for(const theme of ['graphite','blue','white']){await setLegacyTheme(page,theme);const box=await page.locator('#workspace-content').boundingBox();assert.equal(Math.round(box.y),48);assert.equal(Math.round(box.x+box.width),width);assert.equal(Math.round(box.y+box.height),height);assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);}await page.screenshot({path:path.join(root,`realtime-${width}.png`)});}
await page.setViewportSize({width:1600,height:1000});await page.locator('.reference-rail [data-open=settings]').click();await page.locator('[data-wall=B1]').click();await waitPref(p=>p.wallpaper==='B1');await stop();start();await ready();assert.equal((await preferences()).wallpaper,'B1');await page.reload();await page.waitForFunction(()=>document.getElementById('workspace-wallpaper').src.includes('B1-wallpaper'));
assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);
await writeFile(path.join(root,'report.json'),JSON.stringify({status:'PASS',root,errors,csp,scenarios:['B1 home: three accessible cards, keyboard activation and return focus','home hides navigation and preserves module collapse state','15 home viewport/theme cases','B4 first-use and reset default','real Rust/Wasm','three themes','application DB preferences across independent browser contexts and server restart','custom wallpaper and invalid file rollback','stale settings update rejected','register/edit/QR/XLSX','actual Worker websocket and synthetic ingress','no fabricated empty targets','real local registration matching','overlay collapse','receiver controls','four viewport sizes']},null,2));console.log(JSON.stringify({status:'PASS',root}));
await writeFile(path.join(root,'report.json'),JSON.stringify({status:'PASS',root,errors,csp,contrastCases,workbenchCases,scenarios:['B1 home: three accessible cards, keyboard activation and return focus','shared home navigation preserves menu state and return focus','15 home viewport/theme cases','B4 first-use and reset default','real Rust/Wasm','three legacy values share A+C material','application DB preferences across independent browser contexts and server restart','custom wallpaper and invalid file rollback','stale settings update rejected','register/edit/QR/XLSX','actual Worker websocket and synthetic ingress','no fabricated empty targets','real local registration matching','overlay collapse','receiver controls','four viewport sizes']},null,2));console.log(JSON.stringify({status:'PASS',root}));
}finally{if(browser)await browser.close();await stop();for(const socket of sockets)socket.destroy();await new Promise(r=>proxy.close(r));await writeFile(path.join(root,'server.log'),output);}