|
|
|
@@ -11,13 +11,13 @@ const style=loc=>loc.evaluate(e=>{const s=getComputedStyle(e),r=e.getBoundingCli
|
|
|
|
|
const sessions=(await Promise.all([api('/api/agent/sessions'),...registry.map(a=>api('/api/agent/sessions?agent_key='+a.key))])).flat().sort((a,b)=>b.updated_at.localeCompare(a.updated_at));
|
|
|
|
|
const b=await chromium.launch({args:['--no-sandbox','--disable-dev-shm-usage']});
|
|
|
|
|
const server=http.createServer((req,res)=>{res.setHeader('Content-Type','text/html;charset=utf-8');res.end(fs.readFileSync('../evidence/reference/夜片场-多主题交互样本.html'))});await new Promise(r=>server.listen(0,'127.0.0.1',r));
|
|
|
|
|
const rows=[],operations=[];
|
|
|
|
|
const rows=[],originalRows=[],operations=[];
|
|
|
|
|
try{
|
|
|
|
|
for(const [width,height] of [[1440,900],[1366,768],[1280,720]])for(const theme of ['night','day','grade','bluehour']){
|
|
|
|
|
const c=await b.newContext({viewport:{width,height}}),a=await c.newPage(),s=await c.newPage();
|
|
|
|
|
await a.goto(WEB+'/agents');await a.locator('.roster .acard').first().waitFor();await a.evaluate(t=>{document.documentElement.dataset.theme=t;localStorage.setItem('aigc-theme',t);document.documentElement.dataset.reduce='0'},theme);
|
|
|
|
|
await s.goto('http://127.0.0.1:'+server.address().port);await s.evaluate(({theme,registry,skills,results,sessions,board})=>{
|
|
|
|
|
go('agents');document.documentElement.dataset.theme=theme;
|
|
|
|
|
go('agents');document.documentElement.dataset.theme=theme;document.querySelectorAll('#p-agents .seg button').forEach((e,i)=>e.classList.toggle('on',i===1));
|
|
|
|
|
const clear=e=>{while(e.firstChild)e.removeChild(e.firstChild)};
|
|
|
|
|
for(const id of ['taskList','taskList2']){const list=document.getElementById(id);clear(list);for(const task of sessions){const item=document.createElement('div');item.className='titem'+(id==='taskList2'&&task.id===board?' on':'');const title=document.createElement('b');title.className='ellipsis';title.textContent=task.title;const meta=document.createElement('div');meta.className='meta';const dot=document.createElement('span');dot.className='dot';dot.style.background='var(--sc-agent)';const grow=document.createElement('span');grow.className='grow';meta.append(dot,({returned:'已带回项目',awaiting_confirm:'待你确认',ready:'未开始'}[task.task_status]||task.task_status||'未开始'),grow,task.project?.title||'沙盒');item.append(title,meta);list.append(item);}}
|
|
|
|
|
const chips=document.querySelector('#p-agents .big-input .row').querySelectorAll('.chip');chips[0].querySelector('b').textContent='沙盒';chips[1].querySelector('b').textContent='reference-test';chips[2].querySelector('b').textContent='不指定';
|
|
|
|
@@ -28,23 +28,27 @@ const style=loc=>loc.evaluate(e=>{const s=getComputedStyle(e),r=e.getBoundingCli
|
|
|
|
|
const outs=document.querySelector('#agentOuts');clear(outs);for(const r of results.slice(0,4)){const card=document.createElement('div');card.className='outcard';const thumb=document.createElement('div');thumb.className='t';const data=document.createElement('div');data.className='d';const title=document.createElement('b');title.textContent=r.title;const sub=document.createElement('span');sub.className='dim';sub.textContent=({script:'剧本创作',storyboard:'分镜设计'}[r.stage_key]||r.stage_key)+' · 草稿 v'+r.revision;data.append(title,sub);card.append(thumb,data);outs.append(card);}
|
|
|
|
|
const input=document.querySelector('#p-agents .big-input textarea');input.placeholder='描述你的创作想法、目标与要求…';document.querySelector('#p-agents .big-input .primary').disabled=true;
|
|
|
|
|
},{theme,registry,skills,results,sessions,board:state.board});
|
|
|
|
|
await a.screenshot({path:`${out}/home-${theme}-${width}-actual.png`,animations:'disabled'});await s.screenshot({path:`${out}/home-${theme}-${width}-reference-content.png`,animations:'disabled'});
|
|
|
|
|
await s.screenshot({path:`${out}/home-${theme}-${width}-original-content.png`,animations:'disabled'});
|
|
|
|
|
for(const selector of ['.ahero','.big-input','.big-input .primary'])originalRows.push({theme,width,height,selector,style:await style(s.locator(selector).first())});
|
|
|
|
|
await s.locator('.ahero').evaluate(e=>e.style.flexShrink='0');
|
|
|
|
|
await a.screenshot({path:`${out}/home-${theme}-${width}-actual.png`,animations:'disabled'});await s.screenshot({path:`${out}/home-${theme}-${width}-approved-content.png`,animations:'disabled'});
|
|
|
|
|
for(const [name,actual,ref] of [['hero','.ahero','.ahero'],['title','.ahero h2','.ahero h2'],['assistant','.roster .acard','.roster .acard'],['input','.big-input','.big-input'],['tasklist','.tasklist','.tasklist'],['primary','.big-input .primary','.big-input .primary']])rows.push({theme,width,height,page:'home',name,actual:await style(a.locator(actual).first()),sample:await style(s.locator(ref).first())});
|
|
|
|
|
await a.goto(WEB+'/agents?session='+state.board);await a.locator('.shot-copy textarea').first().waitFor();await s.evaluate(({shots,session})=>{
|
|
|
|
|
await a.goto(WEB+'/agents?session='+state.board);await a.locator('.shot-copy textarea').first().waitFor();const thumbnails=await a.locator('.shot .th').evaluateAll(es=>es.map(e=>e.querySelector('img')?.src||''));await s.evaluate(({shots,session,thumbnails})=>{
|
|
|
|
|
go('agent-task');document.querySelector('#p-agent-task .crumb b').textContent=session.title;document.querySelector('#p-agent-task .ph>.tag').textContent='已带回项目';document.querySelector('#p-agent-task .art-h .row>.dim').textContent=shots.length+' 镜 · '+shots.reduce((sum,s)=>sum+(Number(s.duration_sec)||0),0)+'s';
|
|
|
|
|
const list=document.querySelector('#shotList');const originals=Array.from(list.children);list.replaceChildren();for(const [i,shot]of shots.entries()){const el=originals[i].cloneNode(true);el.querySelector('.th').style.backgroundImage='none';el.querySelector('[contenteditable]').textContent=shot.description;el.querySelector('.tag.mono').textContent=shot.duration_sec+'s';list.append(el);}
|
|
|
|
|
},{shots,session});
|
|
|
|
|
const list=document.querySelector('#shotList');const originals=Array.from(list.children);list.replaceChildren();for(const [i,shot]of shots.entries()){const el=originals[i].cloneNode(true);el.querySelector('.th').style.backgroundImage=thumbnails[i]?`url("${thumbnails[i]}")`:'none';el.querySelector('[contenteditable]').textContent=shot.description;el.querySelector('.tag.mono').textContent=shot.duration_sec+'s';list.append(el);}
|
|
|
|
|
},{shots,session,thumbnails});
|
|
|
|
|
await a.screenshot({path:`${out}/task-${theme}-${width}-actual.png`,animations:'disabled'});await s.screenshot({path:`${out}/task-${theme}-${width}-reference-content.png`,animations:'disabled'});
|
|
|
|
|
for(const [name,actual,ref] of [['columns','.atask','.atask'],['artifact','.artifact','.artifact'],['header','.art-h','.art-h'],['footer','.art-f','.art-f'],['shot','.shot','.shot'],['save','.art-f .secondary','.art-f .btn:not(.primary)'],['primary','.art-f .primary','.art-f .primary']])rows.push({theme,width,height,page:'task',name,actual:await style(a.locator(actual).first()),sample:await style(s.locator(ref).first())});
|
|
|
|
|
if(width===1440&&theme==='night'){
|
|
|
|
|
await a.getByLabel('镜头 b4-shot-1 描述').fill('主题切换保持未保存编辑');await a.evaluate(async()=>{const {setTheme}=await import('/src/lib/theme.ts');setTheme('day')});await a.waitForFunction(()=>document.documentElement.dataset.theme==='day');assert.equal(await a.getByLabel('镜头 b4-shot-1 描述').inputValue(),'主题切换保持未保存编辑');operations.push('切换主题保持未保存成果文本');await a.screenshot({path:out+'/operation-theme-edit-preserved.png'});
|
|
|
|
|
await a.getByRole('button',{name:'原文',exact:true}).click();assert((await a.getByLabel('成果草稿').inputValue()).includes('主题切换保持未保存编辑'));operations.push('逐镜编辑与原文视图同步');await a.screenshot({path:out+'/operation-raw-edit.png'});
|
|
|
|
|
await a.getByRole('button',{name:'原文',exact:true}).click();await a.waitForFunction(()=>document.querySelector('[aria-label=成果草稿]')?.value.includes('主题切换保持未保存编辑'));assert((await a.getByLabel('成果草稿').inputValue()).includes('主题切换保持未保存编辑'));operations.push('逐镜编辑与原文视图同步');await a.screenshot({path:out+'/operation-raw-edit.png'});
|
|
|
|
|
await a.reload();await a.locator('.shot-copy textarea').first().waitFor();await a.getByRole('button',{name:'对比上一版',exact:true}).click();await a.getByRole('dialog').waitFor();await a.screenshot({path:out+'/operation-version-comparison.png'});await a.keyboard.press('Escape');
|
|
|
|
|
const tool=a.locator('.tool-card .head').first();await tool.click();await a.locator('.tool-card .body').first().waitFor();operations.push('工具详情真实参数与返回值可展开');await a.screenshot({path:out+'/operation-tool-expanded.png'});
|
|
|
|
|
await a.evaluate(()=>document.documentElement.dataset.reduce='1');assert.equal(await a.locator('.b4 .aurora').evaluate(e=>getComputedStyle(e).display),'none');operations.push('减少动效隐藏本页装饰光晕与粒子');
|
|
|
|
|
}
|
|
|
|
|
await c.close();
|
|
|
|
|
}
|
|
|
|
|
fs.writeFileSync(out+'/original-style-values.json',JSON.stringify(originalRows,null,2));
|
|
|
|
|
fs.writeFileSync(out+'/style-values.json',JSON.stringify(rows,null,2));
|
|
|
|
|
const compareKeys=['x','y','width','height','padding','borderRadius','fontSize','fontWeight','letterSpacing','filter','backgroundColor','backgroundImage','boxShadow','gridTemplateColumns'];const differences=rows.flatMap(r=>compareKeys.filter(k=>r.actual[k]!==r.sample[k]).map(k=>({theme:r.theme,width:r.width,page:r.page,name:r.name,property:k,actual:r.actual[k],sample:r.sample[k]})));fs.writeFileSync(out+'/measured-differences.json',JSON.stringify(differences,null,2));assert.deepEqual(differences,[],'Measured sample differences must be corrected');fs.writeFileSync(out+'/operations.json',JSON.stringify(operations,null,2));console.log('PASS normalized visual pairs: 24; measured selector pairs:',rows.length,'operations:',operations.length);
|
|
|
|
|
}finally{await b.close();await new Promise(r=>server.close(r));}
|
|
|
|
|