HEL-733: align approved motion and audit remaining sample gaps

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-10-23 12:43:05 +08:00
co-authored by multica-agent
parent 2952af42b6
commit 1f6c2d2a6b
21 changed files with 836 additions and 173 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ const style=loc=>loc.evaluate(e=>{const s=getComputedStyle(e),r=e.getBoundingCli
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.getByLabel('镜头 b4-shot-1 描述').fill('主题切换保持未保存编辑');await a.locator('.sidebar-bottom button[title="主题"]').click();await a.locator('.choices.compact .choice').filter({hasText:'日光棚'}).click();await a.keyboard.press('Escape');await a.waitForTimeout(600);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();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'});
+114
View File
@@ -0,0 +1,114 @@
// Foreground static-build audit. All API reads use labelled, isolated inputs;
// all non-local requests and all product mutations are blocked.
import fs from 'node:fs/promises';
import http from 'node:http';
import path from 'node:path';
const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright');
const out = process.env.HEL733_OUT || '../evidence/hel733/before';
await fs.mkdir(out, { recursive: true });
const fixture = JSON.parse(await fs.readFile('../evidence/hel733/fixtures.json'));
const sample = await fs.readFile('../materials/夜片场-多主题交互样本.html');
const log = { errors: [], blocked: [], rows: [], requests: [] };
const server = http.createServer(async (req, res) => {
try {
const p = decodeURIComponent(new URL(req.url, 'http://local').pathname);
if (p === '/sample') { res.setHeader('Content-Type','text/html;charset=utf-8'); return res.end(sample); }
let file = path.join('calliope-web/build', p);
if (!path.extname(file)) file = 'calliope-web/build/index.html';
res.setHeader('Content-Type', file.endsWith('.js') ? 'text/javascript' : file.endsWith('.css') ? 'text/css' : 'text/html');
res.end(await fs.readFile(file));
} catch { res.writeHead(404); res.end(); }
});
await new Promise(r => server.listen(0,'127.0.0.1',r));
const base = `http://127.0.0.1:${server.address().port}`;
const browser = await chromium.launch({args:['--no-sandbox']});
const measure = (p, selectors) => p.evaluate(selectors => Object.fromEntries(Object.entries(selectors).map(([key,sel]) => {
const e=document.querySelector(sel); if(!e) return [key,null];
const r=e.getBoundingClientRect(),c=getComputedStyle(e);
return [key,{x:r.x,y:r.y,width:r.width,height:r.height,...Object.fromEntries(['fontSize','fontWeight','lineHeight','letterSpacing','backgroundColor','backgroundImage','borderRadius','color','padding','boxSizing','animationName','animationDuration'].map(k=>[k,c[k]]))}];
})),selectors);
try {
const c=await browser.newContext();
await c.addInitScript(()=>{
localStorage.setItem('aigc-lang','zh');localStorage.setItem('aigc-reduce-motion','1');
window.__sse=[];window.EventSource=class{constructor(){window.__sse.push(this);setTimeout(()=>this.onopen?.(),0)}addEventListener(t,f){(this.handlers??={})[t]=f}close(){}};
});
await c.route('**/*',async route=>{
const req=route.request(),u=new URL(req.url());
if(['data:','blob:'].includes(u.protocol))return route.continue();
if(u.origin!==base){log.blocked.push(req.url());return route.abort()}
if(!u.pathname.startsWith('/api/'))return route.continue();
log.requests.push([req.method(),u.pathname]);
if(req.method()!=='GET')return route.fulfill({status:403,body:'Isolated audit blocks mutations'});
const p=u.pathname;let body=[];
if(p==='/api/settings')body={comfyui_endpoints:[],llm_profiles:[],queue_concurrency:2,queue_poll_timeout_sec:1800,queue_poll_interval_sec:1,queue_max_retries:1,data_dir:'HEL733 isolated audit',dry_run:false};
if(p==='/api/jobs')body=u.searchParams.get('empty')?[]:fixture.jobs;
if(p==='/api/workflows')body=fixture.workflows;
if(p==='/api/projects')body=[{id:1,title:'雾港来信'}];
if(p==='/api/jobs/queue-status')body={paused:false};
if(p==='/api/comfyui/endpoints')body={endpoints:[],active_id:null};
if(p==='/api/agent/sessions')body=[];
if(p==='/api/agent/agents')body=[];
if(/^\/api\/workflows\/\d+$/.test(p))body={...fixture.workflows.find(x=>x.id===+p.split('/').pop()),workflow_json:{}};
if(p==='/api/file')return route.fulfill({status:404,body:'No audit media'});
return route.fulfill({json:body});
});
const a=await c.newPage(),s=await c.newPage();a.on('pageerror',e=>log.errors.push(e.message));
await s.goto(base+'/sample');await s.evaluate(()=>document.documentElement.classList.add('capture','reduce'));
const pages=process.env.HEL733_CREATE_ONLY ? [['create','create']] : process.env.HEL733_POP_ONLY ? [['settings','settings']] : process.env.HEL733_TASKS_ONLY ? [['tasks','tasks']] : [['','studio'],['create','create'],['agents','agents'],['workflows','workflows'],['connections','models'],['tasks','tasks'],['library','library'],['settings','settings']];
for(const [width,height] of [[1440,900],[1366,768],[1280,720]])for(const theme of ['night','day','grade','bluehour'])for(const [route,ref] of pages){
await a.setViewportSize({width,height});await s.setViewportSize({width,height});
await a.goto(base+'/'+route);await a.locator('aside.sidebar').waitFor();
await a.evaluate(t=>{document.documentElement.dataset.theme=t;window.dispatchEvent(new StorageEvent('storage',{key:'aigc-theme',newValue:t}));for(const es of window.__sse)for(const [id,progress] of [[1,62],[2,35]])es.handlers?.['job.progress']?.({data:JSON.stringify({type:'job.progress',data:{job_id:id,progress}})})},theme);
await s.evaluate(({ref,theme})=>{go(ref);renderTasks();document.documentElement.dataset.theme=theme;document.querySelector('#motionBtn span').textContent='动效关'},{ref,theme});
await a.waitForTimeout(400);
const as={rail:'aside.sidebar',brand:'aside.sidebar .brand',nav:'aside.sidebar nav a',divider:'aside.sidebar hr',queue:'.queue-dot',theme:'.sidebar-bottom button',settings:'.sidebar-bottom a[href="/settings"]',header:'.management-header, .studio-header, .studio-heading, .desk-head, .topbar',progress:'.task-progress',fill:'.task-progress i'};
const ss={rail:'.rail',brand:'.rail .brand',nav:'.rail>.nav',divider:'.rail hr',queue:'.rail .queue-dot',theme:'#themeBtn',settings:'.rail [data-go="settings"]',header:`#p-${ref} .ph`,progress:'#taskTable .bar',fill:'#taskTable .bar i'};
if(route==='create'){
Object.assign(as,{title:'.model-selector',primary:'.dock .gen',prompt:'#desk-prompt',workspace:'.reference-desk'});
Object.assign(ss,{title:'#hdName',primary:'#genBtn',prompt:'#posTa',workspace:'#p-create .create'});
}else if(route==='agents'){
Object.assign(as,{title:'.ahero h2',primary:'.big-input .primary',prompt:'.big-input textarea'});
Object.assign(ss,{title:'#p-agents .ahero h2',primary:'#p-agents .big-input .primary',prompt:'#p-agents .big-input textarea'});
}else if(['workflows','connections','tasks','library','settings'].includes(route)){
Object.assign(as,{title:'.management-header > b',primary:'.management-header .a-btn, .a-btn.primary',search:'.mg-search',input:'.mg-input, .field-input'});
Object.assign(ss,{title:`#p-${ref} .ph b`,primary:`#p-${ref} .ph .btn, #p-${ref} .btn.primary`,search:`#p-${ref} .ph .input`,input:`#p-${ref} .input`});
}
const name=`${route||'studio'}-${theme}-${width}`;
const row={route:route||'studio',ref,theme,width,height,actual:await measure(a,as),sample:await measure(s,ss)};
if(route==='tasks'){
row.actualTable=await a.locator('.task-table table').evaluate(e=>({columns:[...e.rows[1].cells].map(c=>({text:c.innerText,width:c.getBoundingClientRect().width,x:c.getBoundingClientRect().x,style:getComputedStyle(c).cssText})),html:e.outerHTML}));
row.sampleTable=await s.locator('#p-tasks table').evaluate(e=>({columns:[...e.rows[1].cells].map(c=>({text:c.innerText,width:c.getBoundingClientRect().width,x:c.getBoundingClientRect().x})),html:e.outerHTML}));
}
if(route==='tasks'){
const sources=await a.locator('.task-table tbody tr td:nth-child(3)').allTextContents();
await s.evaluate(sources=>{document.querySelectorAll('#taskTable tr').forEach((r,i)=>r.cells[2].textContent=sources[i])},sources);
row.sameSourceSample=await measure(s,{progress:'#taskTable .bar',fill:'#taskTable .bar i'});
}
log.rows.push(row);
if(route==='create') {
await a.evaluate(()=>document.documentElement.dataset.reduce='0');await s.evaluate(()=>document.documentElement.classList.remove('reduce'));
await a.locator('.workflow-row').first().hover({position:{x:40,y:20}});
await s.locator('#wfList .wfi').first().hover({position:{x:40,y:20}});
const pointer=await a.locator('.workflow-row').first().evaluate(e=>({x:e.style.getPropertyValue('--pointer-x'),y:e.style.getPropertyValue('--pointer-y')}));
await s.locator('#wfList .wfi').first().evaluate((e,p)=>{e.style.setProperty('--mx',p.x);e.style.setProperty('--my',p.y)},pointer);
row.hoverInput={mode:'full',pointer};
await a.waitForTimeout(350);
const pseudo=(p,sel,which)=>p.locator(sel).first().evaluate((e,which)=>{const c=getComputedStyle(e,which);return Object.fromEntries(['backgroundImage','maskImage','opacity','transitionDuration','transitionTimingFunction','zIndex'].map(k=>[k,c[k]]))},which);
row.hoverActual=await pseudo(a,'.workflow-row','::after');row.hoverSample=await pseudo(s,'#wfList .wfi','::before');
await a.mouse.move(0,0);await s.mouse.move(0,0);await a.waitForTimeout(350);await a.evaluate(()=>document.documentElement.dataset.reduce='1');await s.evaluate(()=>document.documentElement.classList.add('reduce'));
}
if(route==='settings') {
await a.locator('.sidebar-bottom button[title="主题"]').click();
await s.evaluate(()=>document.querySelector('#themePop').classList.add('on'));
await a.waitForTimeout(400);
row.themePopActual=await measure(a,{panel:'.modal-panel',row:'.choices.compact .choice',preview:'.choices.compact .preview'});
row.themePopSample=await measure(s,{panel:'#themePop',row:'.topt',preview:'.topt .tprev'});
await a.screenshot({path:`${out}/${name}-theme-pop-actual.png`});await s.screenshot({path:`${out}/${name}-theme-pop-sample.png`});
await a.keyboard.press('Escape');await s.evaluate(()=>document.querySelector('#themePop').classList.remove('on'));
}
await a.screenshot({path:`${out}/${name}-actual.png`,animations:'disabled'});await s.screenshot({path:`${out}/${name}-sample.png`,animations:'disabled'});
console.log(name);
}
await c.close();
}finally{await fs.writeFile(out+'/results.json',JSON.stringify(log,null,2));await browser.close();await new Promise(r=>server.close(r));}
+86
View File
@@ -0,0 +1,86 @@
// Real isolated API and fake ComfyUI; never connects to production.
const {chromium}=require(process.env.PLAYWRIGHT_MODULE_PATH||'playwright');
const fs=require('node:fs'),assert=require('node:assert/strict'),path=require('node:path');
const OUT='../evidence/hel733/live',WEB='http://127.0.0.1:5173',API='http://127.0.0.1:8247';
fs.mkdirSync(OUT,{recursive:true});
const checks=[],errors=[],ok=(name,value)=>{checks.push({name,pass:!!value});assert(value,name);console.log('PASS',name)};
const api=async p=>(await fetch(API+p)).json();
const wait=ms=>new Promise(r=>setTimeout(r,ms));
(async()=>{
const b=await chromium.launch({executablePath:process.env.CHROMIUM_EXECUTABLE_PATH,args:['--no-sandbox']});
try{
const f=JSON.parse(fs.readFileSync('e2e/shots/reference/fixtures.json'));
const state=JSON.parse(fs.readFileSync('e2e/shots/hel732/fixture-state.json'));
const c=await b.newContext({viewport:{width:1440,height:900},recordVideo:{dir:OUT+'/recordings'}});
await c.addInitScript(()=>{
window.mediaCalls=[];
for(const method of ['play','pause']){const original=HTMLMediaElement.prototype[method];HTMLMediaElement.prototype[method]=function(...args){window.mediaCalls.push({method,src:this.src,stack:new Error().stack});const result=original.apply(this,args);result?.catch?.(e=>window.mediaCalls.push({method,error:e.message}));return result}}
window.arrivalEvents=[];document.addEventListener('animationstart',e=>window.arrivalEvents.push({name:e.animationName,time:performance.now()}),true);
const clear=CanvasRenderingContext2D.prototype.clearRect;
window.particleFrames=0;CanvasRenderingContext2D.prototype.clearRect=function(...args){if(this.canvas.classList.contains('particles'))window.particleFrames++;return clear.apply(this,args)};
});
const p=await c.newPage();p.setDefaultTimeout(15000);p.on('pageerror',e=>errors.push(e.message));
for(const theme of (process.env.HEL733_SKIP_EFFECTS?[]:['night','day','grade','bluehour'])){
await p.goto(WEB+'/create?wf='+f.dual);
await p.locator('#desk-prompt').fill('HEL733 '+theme+' 状态保留与显影');
await p.evaluate(t=>{document.documentElement.dataset.theme=t;window.dispatchEvent(new StorageEvent('storage',{key:'aigc-theme',newValue:t}));localStorage.setItem('aigc-reduce-motion','0')},theme);
await wait(400);
ok(theme+' creative header starts at y=0 without duplicate global bar',await p.locator('.studio-heading').evaluate(e=>e.getBoundingClientRect().y===0));
fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode:'ok',delay_sec:4,unique_filename:true,image_file:path.resolve('calliope-web/static/refract/coast.jpg')}));
await p.locator('.gen').click();await p.locator('.a-scan-beam').waitFor();
const scan=await p.locator('.a-scan-beam').evaluate(e=>{const c=getComputedStyle(e);return [c.animationName,c.animationDuration]});
ok(theme+' scan 1.6s',scan[0]==='a-scan'&&scan[1]==='1.6s');await p.screenshot({path:OUT+'/'+theme+'-generating.png'});
try{await p.waitForFunction(()=>window.arrivalEvents.some(x=>x.name.startsWith('a-develop')),null,{timeout:30000})}catch(e){fs.writeFileSync(OUT+'/arrival-failure.json',JSON.stringify({theme,events:await p.evaluate(()=>window.arrivalEvents),jobs:await api('/api/playground/jobs'),dom:await p.locator('.preview-area').innerHTML()},null,2));throw e}
const events=await p.evaluate(()=>window.arrivalEvents);ok(theme+' correct development variant',events.some(x=>x.name===({day:'a-develop-day',grade:'a-develop-grade'}[theme]||'a-develop')));
await p.locator('.a-result-develop').first().dispatchEvent('pointerdown').catch(()=>{});await p.waitForTimeout(800);ok(theme+' development class clears after completion',await p.locator('.a-result-develop').count()===0);
const before=await p.locator('#desk-prompt').inputValue();
await p.locator('.sidebar-bottom button[title="主题"]').click();await p.locator('.choices .choice').filter({hasText:'日光棚'}).first().click();await wait(650);
ok(theme+' theme keeps prompt, workflow and result',(await p.locator('#desk-prompt').inputValue())===before&&(await p.locator('.print img').count())===1&&new URL(p.url()).searchParams.get('wf')===String(f.dual));
ok(theme+' theme does not replay result arrival',await p.locator('.a-result-develop').count()===0);await p.keyboard.press('Escape');
}
await p.goto(WEB+'/create?kind=video&wf='+f.h3);
await p.locator('#desk-prompt').fill('HEL733 video upload state');
await p.getByRole('button',{name:'管理素材',exact:true}).click();
for(const [label,file] of [['首帧','coast.jpg'],['尾帧','arch.jpg']]){
const slot=p.locator('.a-slot').filter({has:p.getByText(label,{exact:true})});
await slot.locator('input[type=file]').setInputFiles('calliope-web/static/refract/'+file);await slot.locator('img').waitFor();
}
await p.getByRole('button',{name:'完成',exact:true}).click();
await p.locator('#desk-prompt').evaluate(e=>window.hel733Editor=e);
const uploads=await p.locator('.media-token img').evaluateAll(es=>es.map(e=>e.src));
for(const name of ['夜片场','日光棚','调色间','蓝调时刻']){
await p.locator('.sidebar-bottom button[title="主题"]').click();await p.locator('.choices.compact .choice').filter({hasText:name}).click();await wait(600);await p.keyboard.press('Escape');
ok(name+' theme retains live editor, uploads and workflow',await p.locator('#desk-prompt').evaluate(e=>e===window.hel733Editor)&&JSON.stringify(await p.locator('.media-token img').evaluateAll(es=>es.map(e=>e.src)))===JSON.stringify(uploads)&&new URL(p.url()).searchParams.get('wf')===String(f.h3));
}
fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode:'ok',videos:true,delay_sec:1,unique_filename:true}));
await p.locator('.gen').click();const video=p.locator('.print video');await video.waitFor();await p.waitForFunction(()=>document.querySelector('.print video')?.readyState>=1);
ok('new video remains paused',await video.evaluate(e=>e.paused&&!e.autoplay));await video.evaluate(e=>{window.videoEvents=[];for(const name of ['play','playing','pause','error','ended'])e.addEventListener(name,()=>window.videoEvents.push({name,time:e.currentTime,error:e.error?.message}));});await p.locator('.big-play').click();await wait(500);fs.writeFileSync(OUT+'/video-diagnostics.json',JSON.stringify(await video.evaluate(e=>({events:window.videoEvents,calls:window.mediaCalls,src:e.src,paused:e.paused,ready:e.readyState,network:e.networkState,error:e.error?.message,codec:e.canPlayType('video/mp4; codecs="avc1.42E01E"')})),null,2));await p.waitForFunction(()=>!document.querySelector('.print video').paused);ok('video plays only on explicit action',await video.evaluate(e=>!e.paused));await video.evaluate(e=>e.pause());
if(process.env.HEL733_VIDEO_ONLY){await c.close();return}
await p.goto(WEB+'/agents?session='+state.board);await p.locator('.shot-copy textarea').first().fill('HEL733 unsaved session draft');
const sessionUrl=p.url();await p.locator('.sidebar-bottom button[title="主题"]').click();await p.locator('.choices.compact .choice').filter({hasText:'日光棚'}).click();await wait(600);await p.keyboard.press('Escape');
ok('theme keeps session and unsaved result',(await p.locator('.shot-copy textarea').first().inputValue())==='HEL733 unsaved session draft'&&p.url()===sessionUrl);
await p.goto(WEB+'/agents');await p.locator('canvas.particles').waitFor();await wait(150);
const full=await p.evaluate(()=>window.particleFrames);await wait(150);ok('particles advance in full mode',(await p.evaluate(()=>window.particleFrames))>full);
await p.locator('.sidebar-bottom button[title="主题"]').click();await p.locator('.theme-motion button').click();await wait(100);const reduced=await p.evaluate(()=>window.particleFrames);await wait(200);
ok('manual reduce stops particle rAF',(await p.evaluate(()=>window.particleFrames))===reduced);await p.keyboard.press('Escape');
await p.emulateMedia({reducedMotion:'reduce'});ok('system reduce is mirrored on root',await p.locator('html').getAttribute('data-reduce')==='1');
await p.goto(WEB+'/settings');await p.locator('.management-header').waitFor();ok('system reduce disables motion override',await p.locator('html').getAttribute('data-reduce')==='1');
await p.emulateMedia({reducedMotion:'no-preference'});
// All real API data / actual empty states. Reference equivalence is a separate audit.
for(const [width,height] of (process.env.HEL733_SKIP_SHOTS ? [] : [[1440,900],[1366,768],[1280,720]]))for(const theme of ['night','day','grade','bluehour'])for(const [name,route] of [['studio','/'],['image','/create?wf='+f.dual],['video','/create?kind=video'],['agents','/agents'],['agent-task','/agents?session='+state.board],['project','/workbench/'+state.project.id+'?stage=storyboard'],['workflows','/workflows'],['models','/model-connections'],['tasks','/tasks'],['library','/library'],['settings','/settings'],['canvas','/canvas']]){
await p.setViewportSize({width,height});await p.goto(WEB+route);await p.waitForTimeout(name==='canvas'?800:200);
await p.evaluate(t=>{document.documentElement.dataset.theme=t;window.dispatchEvent(new StorageEvent('storage',{key:'aigc-theme',newValue:t}))},theme);
await p.screenshot({path:`${OUT}/${name}-${theme}-${width}.png`});
ok(`${name} ${theme} ${width} body renders`,(await p.locator('body').innerText()).trim().length>0);
}
await c.close();
const blocked=await b.newContext({viewport:{width:1440,height:900}});
await blocked.addInitScript(()=>{Storage.prototype.getItem=()=>{throw new DOMException('blocked','SecurityError')};Storage.prototype.setItem=()=>{throw new DOMException('blocked','SecurityError')}});
const q=await blocked.newPage();q.on('pageerror',e=>errors.push(q.url()+' '+e.stack));
for(const route of ['/create?wf='+f.dual,'/agents','/settings','/canvas','/build-scene','/agents?legacy=1']){
await q.goto(WEB+route);await q.waitForTimeout(800);ok('storage blocked '+route+' remains usable',await q.locator('.refract-shell, .canvas-layout, .flow-canvas').count()>0||!(await q.locator('.redirect-error').count()));
}
await q.goto(WEB+'/settings');await q.locator('.choices.tiles .choice').filter({hasText:'日光棚'}).click();await wait(650);ok('storage blocked theme changes',await q.locator('html').getAttribute('data-theme')==='day');
await q.screenshot({path:OUT+'/storage-blocked.png'});await blocked.close();ok('no browser page errors',errors.length===0);
}finally{fs.writeFileSync(OUT+'/results.json',JSON.stringify({checks,errors},null,2));await b.close()}
})().catch(e=>{console.error(e);process.exitCode=1});
+57
View File
@@ -0,0 +1,57 @@
"""Run the isolated regression stack in the foreground and always stop children."""
import os, signal, socket, subprocess, time, urllib.request
from pathlib import Path
root=Path(__file__).resolve().parents[1]
os.chdir(root)
py=os.environ.get('HEL732_PYTHON', 'python3')
logs=root/'e2e/shots/hel732'; logs.mkdir(parents=True,exist_ok=True)
env=os.environ.copy()
env['PYTHONPATH']=str(root/'calliope-backend/src')
for port in [8247,5173,18188,18189]:
with socket.socket() as probe:
assert probe.connect_ex(('127.0.0.1',port)) != 0, f'Test port {port} is already in use'
# Every run gets fresh disposable state; retain prior evidence instead of deleting it.
reference=root/'e2e/shots/reference'
reuse_fixture=os.environ.get('HEL732_REUSE_FIXTURE')=='1'
if reference.exists() and not reuse_fixture:reference.rename(reference.with_name('reference.previous-'+str(time.time_ns())))
mode_path=root/'e2e/fake_mode.json'
saved_mode=mode_path.read_bytes() if mode_path.exists() else None
processes=[]; handles=[]
try:
for name,cmd in [('api',[py,'e2e/reference/server.py']),('comfy',[py,'e2e/fake_comfy.py']),('llm',[py,'e2e/fake_agent_b4.py']),('web',['npm','--prefix',os.environ.get('HEL732_WEB_DIR',os.environ.get('HEL729_WEB_DIR','calliope-web')),'run','preview','--','--host','127.0.0.1','--port','5173'])]:
h=open(logs/(name+'.log'),'w');handles.append(h);processes.append(subprocess.Popen(cmd,stdout=h,stderr=subprocess.STDOUT,env=env,start_new_session=True))
for url in ['http://127.0.0.1:8247/api/health','http://127.0.0.1:5173']:
for i in range(100):
try:
urllib.request.urlopen(url,timeout=2); break
except Exception:
if any(p.poll() is not None for p in processes): raise RuntimeError('A test service failed')
if i==99:raise
time.sleep(.2)
if not reuse_fixture:
for cmd in [[py,'e2e/seed.py'],[py,'e2e/reference/seed.py']]:subprocess.run(cmd,env=env,check=True)
failures=[]
scripts=os.environ.get('HEL733_TESTS','e2e/hel732.cjs,e2e/hel733-live.cjs').split(',')
for script in scripts:
print('RUN',script,flush=True)
result=subprocess.run(['node',script],env=env)
if result.returncode:failures.append(script)
print('FAILED SCRIPTS',failures,flush=True)
if failures:raise SystemExit(1)
finally:
import json
daemon_pid=json.loads(subprocess.check_output(['multica','daemon','status','--output','json']))['pid']
assert all(p.pid != daemon_pid for p in processes)
for p in processes:
if p.poll() is None:os.killpg(p.pid,signal.SIGTERM)
for p in processes:
try:p.wait(timeout=10)
except subprocess.TimeoutExpired:os.killpg(p.pid,signal.SIGKILL);p.wait()
print("STOPPED TEST CHILDREN", [{"pid":p.pid,"exit":p.returncode} for p in processes],flush=True)
for h in handles:h.close()
import shutil
if reference.exists():shutil.rmtree(reference)
if saved_mode is not None:mode_path.write_bytes(saved_mode)
elif mode_path.exists():mode_path.unlink()