test: align agent comparison content with real task events (HEL-732)

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-10-22 16:09:33 +08:00
co-authored by multica-agent
parent 37cb6ec209
commit dca216e2c7
2 changed files with 15 additions and 2 deletions
@@ -49,7 +49,7 @@ HEL-732 / B4:智能体任务、可编辑成果与显式存入项目草稿
真实选择器的额外 `max-width:90px` 把 `reference-test` 截短,改变 flex spacer 是否换行,导致 1280 下**首页开始任务** x=390、原样本 x=760。它不是成果栏按钮偏移。改为统一 token `--agent-input-select-max:none`,保留 field-sizing 与原 spacer,让真实文字按样本自然宽度参与排版;当前 1280 开始按钮 x=760、1366 x=398、1440 x=920,均与内容对齐的参考一致。成果回流的 `.art-f .primary` 在三尺寸分别 x=1047.171875/1133.171875/1207.171875,原位置未修改;实际项目与阶段 select 保留,并单独测量、聚焦,未伪造样本中不存在的 select。
`e2e/hel732-visual.cjs` 保留未改 CSS 的原样本图与数值,在独立浏览器参考页仅施加已批准的 flex-shrink:0,另存批准版截图;参考页只按真实测试状态替换内容/选中状态/真实缩略图,原 HTML 文件哈希始终为 `0473d80d22b90194375f3566c1b8ca30dbd7433581b18f60956eabca252242a4`。三者清楚标注,未经修改的原演示状态也保留。24 组首页/任务对照、156 组实际选择器测量通过;这只覆盖指定选择器,不冒充全像素相同或独立审核。
`e2e/hel732-visual.cjs` 保留未改 CSS 的原样本图与数值,在独立浏览器参考页仅施加已批准的 flex-shrink:0,另存批准版截图;参考页只按真实测试状态替换内容/选中状态/真实缩略图;任务聊天用样本原有气泡/工具模板填入真实消息序列,不复制应用 DOM/CSS,不保留虚假的演示计划/运行态,原 HTML 文件哈希始终为 `0473d80d22b90194375f3566c1b8ca30dbd7433581b18f60956eabca252242a4`。三者清楚标注,未经修改的原演示状态也保留。24 组首页/任务对照、156 组实际选择器测量通过;这只覆盖指定选择器,不冒充全像素相同或独立审核。
新增 `e2e/hel732-layout.cjs` 通过真实应用与隔离假模型,在四主题×三窗口中验证:输入和焦点、正常点击开始任务并产生持久化成果、滚动到下面的最近成果/技能、无横向溢出、真实项目/阶段选择器和保存/回流按钮完整可见且可聚焦。截图测量脚本等待原文视图的异步渲染后再读取内容,避免旧 DOM 值造成误报。B4 功能链路与 B3 相关布局/确认/恢复回归重新通过,前端干净安装、lint/check(0错0警告)、test、build 通过。
+14 -1
View File
@@ -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'});