```
feat(target-lists): 新增黑白名单管理与实时告警功能 - rid-shared 新增 target_lists 模块,定义名单数据契约 - 地图适配器支持按名单类型着色渲染目标(白/黑/未知) - 新增名单筛选器与目标目录过滤联动 - 实时详情面板支持加入/编辑白名单与黑名单操作 - 新增黑名单命中告警横幅与事件日志高亮 - 新增名单管理浮层(Manager 组件)与徽章展示 - 底图默认切换为影像图,相机初始俯仰角归零 - color-scheme 切换为 dark,新增 glass/workbench 样式 ```
This commit is contained in:
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user