test: align agent comparison content with real task events (HEL-732)
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
+14
-1
@@ -34,7 +34,20 @@ const style=loc=>loc.evaluate(e=>{const s=getComputedStyle(e),r=e.getBoundingCli
|
||||
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();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';
|
||||
go('agent-task');
|
||||
// Align real message/event state using the sample's own message/tool templates, never application DOM/CSS.
|
||||
const page=document.querySelector('#p-agent-task'),body=page.querySelector('.convo-b');
|
||||
const userTemplate=body.querySelector('.msg.me').cloneNode(true),avatar=body.querySelector('.msg:not(.me) .av').cloneNode(true),toolTemplate=body.querySelector('details.tool').cloneNode(true);
|
||||
body.replaceChildren();
|
||||
for(const m of session.messages){
|
||||
if((m.role==='user'||m.role==='assistant')&&m.content){const row=userTemplate.cloneNode(true);row.classList.toggle('me',m.role==='user');if(m.role==='assistant')row.querySelector('.av').replaceWith(avatar.cloneNode(true));row.querySelector('.bub').textContent=m.content;body.append(row);}
|
||||
else if(m.role==='tool'){const tool=toolTemplate.cloneNode(true);tool.querySelector('code').textContent=m.tool_name;tool.querySelector('.dim')?.remove();tool.querySelector('.tag').textContent='完成';tool.querySelector('pre').textContent=JSON.stringify(m.tool_result,null,2);body.append(tool);}
|
||||
}
|
||||
page.querySelector('.ph .chip b').textContent='reference-test';page.querySelectorAll('.ph .chip')[1]?.remove();
|
||||
page.querySelector('.art-h .row>b').textContent='分镜设计 · 草稿';page.querySelector('.art-h .seg').querySelectorAll('button')[2].textContent='原文';
|
||||
page.querySelector('.art-f .chip b').textContent=session.project?.title||'沙盒';
|
||||
page.querySelector('.convo-in textarea').placeholder='向智能体提问,或用 @ 提及技能…';page.querySelector('.convo-in .ghost')?.remove();page.querySelector('.convo-in .primary').disabled=true;
|
||||
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=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'});
|
||||
|
||||
Reference in New Issue
Block a user