139 lines
26 KiB
JavaScript
139 lines
26 KiB
JavaScript
// Foreground real isolated API audit. Reference DOM changes only content, never CSS.
|
|
const {chromium}=require(process.env.PLAYWRIGHT_MODULE_PATH||'playwright');
|
|
const fs=require('node:fs'),http=require('node:http'),path=require('node:path'),assert=require('node:assert/strict');
|
|
const OUT=process.env.HEL806_OUT||'../evidence/hel806-final',WEB='http://127.0.0.1:5173',API='http://127.0.0.1:8247';
|
|
const result={rows:[],checks:[],errors:[],blocked:[],requests:[]};
|
|
const api=async(p,body,method)=>{const r=await fetch(API+p,{method:method||(body?'POST':'GET'),headers:{'Content-Type':'application/json'},body:body?JSON.stringify(body):undefined});if(!r.ok)throw Error(p+' '+await r.text());return r.json()};
|
|
const ok=(name,value)=>{assert(value,name);result.checks.push(name);console.log('PASS',name)};
|
|
const wait=ms=>new Promise(r=>setTimeout(r,ms));
|
|
const metrics=(p,sels)=>p.evaluate(sels=>Object.fromEntries(Object.entries(sels).map(([key,sel])=>{const e=document.querySelector(sel);if(!e)return[key,null];const r=e.getBoundingClientRect(),s=getComputedStyle(e);return[key,{x:r.x,y:r.y,width:r.width,height:r.height,...Object.fromEntries(['fontSize','fontWeight','lineHeight','borderRadius','borderTopWidth','borderTopColor','backgroundColor','backgroundImage','color','padding','boxShadow','animationDuration','animationTimingFunction'].map(k=>[k,s[k]]))}]})),sels);
|
|
(async()=>{
|
|
fs.mkdirSync(OUT+'/shots',{recursive:true});
|
|
const f=JSON.parse(fs.readFileSync('e2e/shots/reference/fixtures.json'));
|
|
const settings=await api('/api/settings');ok('database is disposable',settings.data_dir.includes('e2e/shots/reference'));
|
|
const base=(await api('/api/workflows/'+f.dual)).workflow_json;
|
|
const img={'class_type':'LoadImage',inputs:{image:''},_meta:{title:'(Input:image) 输入图'}};
|
|
const wf=async(name,kind,extra)=>api('/api/workflows',{name,kind,workflow_json:{...base,...extra}});
|
|
const edit=await wf('HEL806 · 图生图真实输入','image',{'5':img});
|
|
const mask=await wf('HEL806 · 遮罩真实输入','image',{'5':img,'6':{class_type:'LoadImageMask',inputs:{image:'',channel:'red'},_meta:{title:'(Input:mask) 遮罩'}}});
|
|
const ref=await wf('HEL806 · 视频参考真实输入','video',{'5':img,'9':{class_type:'VHS_VideoCombine',inputs:{},_meta:{title:'(Output:video) 视频输出'}}});
|
|
const long=await wf('HEL806 · 真实长文件名 · Qwen_Image_2_1_局部重绘_批量蒙版_参数映射_最终审核版本_20261023.json','image',{});
|
|
await api('/api/workflows/'+long.id,{is_enabled:false},'PATCH');await api('/api/workflows/'+ref.id,{usage:'ref2video',usage_source:'user',is_enabled:true},'PATCH');
|
|
await new Promise((resolve,reject)=>{const socket=require('node:net').connect(18187,'127.0.0.1');socket.on('connect',()=>{socket.destroy();reject(Error('Failure fixture port must be unused'))});socket.on('error',e=>e.code==='ECONNREFUSED'?resolve():reject(e));socket.setTimeout(1000,()=>{socket.destroy();reject(Error('Failure fixture probe timeout'))})});
|
|
await api('/api/comfyui/endpoints',{name:'HEL806 · 故意不可达的隔离连接',base_url:'http://127.0.0.1:18187',auth_type:'none'});
|
|
const sourceFile='4-视频生成/Minimax-h3/MiniMax_H3_音频MV_多参长视频分段_Selflift双采潜放大_Qwen3.8官方Skills自动提示词.json';
|
|
const sourceBytes=fs.readFileSync(path.join('example_ComfyUI_workflows',sourceFile));
|
|
const imported=await api('/api/workflows/import-batch',{files:[{source_path:sourceFile,workflow_json:JSON.parse(sourceBytes.toString('utf8').replace(/^\uFEFF/,''))}]});
|
|
ok('real long repository filename imported without generation',imported.imported===1);
|
|
await api('/api/workflows/'+imported.imported_ids[0],{name:'HEL806 · 真文件 · '+path.basename(sourceFile)},'PATCH');
|
|
fs.writeFileSync(OUT+'/import-report.json',JSON.stringify({sourceFile,source_sha256:require('node:crypto').createHash('sha256').update(sourceBytes).digest('hex'),imported,workflow:await api('/api/workflows/'+imported.imported_ids[0])},null,2));
|
|
const project=await api('/api/projects',{title:'HEL806 · 海岸来信',idea:'纸船带回一片树叶'});
|
|
const stages={script:{text:'第一场:清晨的海岸,女孩把一只纸船放入海水。她等候着父亲的归来。第二场:纸船带回一片树叶,女孩望向海平面,知道旅程才刚刚开始。'},style:{directions:[{id:'s1',name:'晨光',description:'柔和暖光',prompt:'warm'},{id:'s2',name:'蓝调',description:'冷光',prompt:'blue'}]},storyboard:{shots:Array.from({length:12},(_,i)=>({id:'b'+i,scene:'1',shot_size:'远景',camera:'固定',description:'女孩沿着海岸走向灯塔,纸船随海风起伏。',duration_sec:5,dialog:''}))},assets:{assets:[{id:'a1',kind:'character',name:'海边女孩',description:'隔离角色',prompt:'girl'}]},shot:{shots:[{id:'s1',shot_no:'S1',description:'女孩走向灯塔',prompt:'girl on coast',duration_sec:5}]}};
|
|
const stagePath=s=>`/api/workbench/projects/${project.id}/stages/${s}`;
|
|
for(const [s,content]of Object.entries(stages))await api(stagePath(s),{content},'PATCH');
|
|
await api(stagePath('storyboard')+'/confirm',{});
|
|
await api(stagePath('storyboard'),{content:{shots:stages.storyboard.shots.map((x,i)=>i?x:{...x,description:'等待确认的新草稿'})}},'PATCH');
|
|
fs.writeFileSync(OUT+'/inputs.json',JSON.stringify({f,edit:await api('/api/workflows/'+edit.id),mask:await api('/api/workflows/'+mask.id),ref:await api('/api/workflows/'+ref.id),long:await api('/api/workflows/'+long.id),project,stages},null,2));
|
|
if(process.env.HEL806_SEED_TASKS==='1'){
|
|
const seeded=[];for(const mode of ['ok','fail']){fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode,delay_sec:0,unique_filename:true,image_file:path.resolve('calliope-web/static/refract/coast.jpg')}));const created=await api('/api/playground/generate',{workflow_id:f.dual,source:'studio-image',input_values:{'1':'HEL806 isolated '+mode,'2':'模糊','3':42}});let job;for(let i=0;i<200;i++){job=await api('/api/jobs/'+created.job.id);if(!['running','pending'].includes(job.status))break;await wait(150)}assert.equal(job.status,mode==='ok'?'done':'failed');seeded.push(job)}fs.writeFileSync(OUT+'/seed-jobs.json',JSON.stringify(seeded,null,2));
|
|
}
|
|
if(process.env.HEL806_REAL_EMPTY==='1'){
|
|
assert.equal((await api('/api/jobs')).length,0,'empty-state run must start without jobs');const owned=await api('/api/projects');for(const project of owned){const r=await fetch(API+'/api/projects/'+project.id,{method:'DELETE'});assert(r.ok,'delete only disposable fixture project')};const after={projects:await api('/api/projects'),jobs:await api('/api/jobs')};assert.equal(after.projects.length,0);assert.equal(after.jobs.length,0);fs.writeFileSync(OUT+'/real-empty.json',JSON.stringify({removedFixtureIds:owned.map(p=>p.id),after},null,2));
|
|
}
|
|
const sample=http.createServer((req,res)=>{res.setHeader('Content-Type','text/html;charset=utf-8');res.end(fs.readFileSync('../materials/夜片场-多主题交互样本.html'))});await new Promise(r=>sample.listen(0,'127.0.0.1',r));
|
|
const browser=await chromium.launch({args:['--no-sandbox','--disable-dev-shm-usage']});
|
|
try{
|
|
const c=await browser.newContext({viewport:{width:1440,height:900},recordVideo:{dir:OUT+'/recordings'}});
|
|
await c.addInitScript(()=>{localStorage.setItem('aigc-lang','zh');localStorage.setItem('aigc-reduce-motion','1')});
|
|
await c.route('**/*',route=>{const u=new URL(route.request().url());if(['data:','blob:'].includes(u.protocol)||['127.0.0.1','localhost'].includes(u.hostname)){if(u.pathname.startsWith('/api/'))result.requests.push([route.request().method(),u.pathname]);return route.continue()}result.blocked.push(u.origin);return route.abort()});
|
|
const p=await c.newPage(),s=await c.newPage();p.setDefaultTimeout(12000);p.on('pageerror',e=>result.errors.push(e.message));p.on('dialog',d=>d.accept());
|
|
const goto=async route=>{await p.goto(WEB+route);await p.locator('aside.sidebar').first().waitFor();await wait(220)};
|
|
const upload=async()=>{await p.getByRole('button',{name:'管理素材',exact:true}).click();const inputs=p.locator('.a-slot input[type=file]');for(let i=0;i<await inputs.count();i++){await inputs.nth(i).setInputFiles('calliope-web/static/refract/coast.jpg');await wait(150)}await p.getByRole('button',{name:'完成',exact:true}).click()};
|
|
const creative=async(id,kind='image')=>{await goto('/create?kind='+kind+'&wf='+id);await p.locator('#desk-prompt').waitFor();const w=await api('/api/workflows/'+id);await p.locator('.rail-search input').fill(w.name);await wait(150)};
|
|
const emptyRoute=async(route,pattern,json)=>{await p.route(pattern,r=>r.fulfill({json}));await goto(route)};
|
|
const generate=async(id,kind)=>{fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode:'ok',delay_sec:0,unique_filename:true,videos:kind==='video',image_file:path.resolve('calliope-web/static/refract/coast.jpg')}));await creative(id,kind);await p.locator('#desk-prompt').fill('HEL806 successful isolated output');const before=Math.max(0,...(await api('/api/playground/jobs')).map(j=>j.id));await p.locator('.gen').click();let job;for(let i=0;i<200;i++){job=(await api('/api/playground/jobs')).find(j=>j.id>before&&j.workflow_id===id&&j.status==='done');if(job)break;await wait(150)}assert(job,'new successful isolated job');await p.locator('.result-title').filter({hasText:'第 '+job.id+' 次生成'}).waitFor();await p.locator(kind==='video'?'.print video':'.print img').waitFor({timeout:45000});await wait(800)};
|
|
const videoWf=(await api('/api/workflows')).find(x=>x.name==='文生视频·回归');
|
|
const cases=[
|
|
{name:'image-output',ref:'create',run:()=>generate(f.dual,'image'),creative:true},
|
|
{name:'video-output',ref:'create',run:()=>generate(videoWf.id,'video'),creative:true},
|
|
{name:'image-failed',ref:'create',run:async()=>{await creative(f.dual);await p.locator('#desk-prompt').fill('HEL806 fake failure');fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode:'fail',delay_sec:0}));await p.locator('.gen').click();await p.locator('.stage-empty').filter({hasText:'失败'}).waitFor({timeout:45000})},creative:true},
|
|
{name:'studio-real',ref:'studio',run:()=>goto('/'),basis:'approved-cover-exception'},
|
|
{name:'studio-empty',ref:'studio',run:async()=>{if(process.env.HEL806_REAL_EMPTY==='1')await goto('/');else{await p.route('**/api/jobs',r=>r.fulfill({json:[]}));await emptyRoute('/','**/api/projects',[])}},missing:'原件没有无项目空态'},
|
|
{name:'image-text-empty',ref:'create',run:async()=>{await p.route('**/api/playground/jobs',r=>r.fulfill({json:[]}));await creative(f.dual)},creative:true},
|
|
{name:'image-long-prompt',ref:'create',run:async()=>{await creative(f.dual);await p.locator('#desk-prompt').fill('海边女孩、晨光、纸船与灯塔,保持人物和空间连续。'.repeat(70));const btn=p.getByRole('button',{name:'展开提示词',exact:true});if(await btn.count())await btn.click()},creative:true},
|
|
{name:'image-edit-upload',ref:'create',run:async()=>{await creative(edit.id);await upload()},creative:true},
|
|
{name:'image-mask-upload',ref:'create',run:async()=>{await creative(mask.id);await upload()},creative:true},
|
|
{name:'video-first-last',ref:'create',run:async()=>{await creative(f.h3,'video');await upload()},creative:true},
|
|
{name:'video-reference',ref:'create',run:async()=>{await creative(ref.id,'video');await upload()},creative:true},
|
|
{name:'video-parameters',ref:'create',run:async()=>{await creative(f.h3,'video');await p.getByRole('button',{name:'创作设置⌄',exact:true}).first().click()},missing:'真实声明参数与原件固定参数内容不同;弹层公共框可比较'},
|
|
...Object.keys(stages).map(stage=>({name:'project-'+stage,ref:'project',run:async()=>{await goto('/workbench/'+project.id+'?stage='+stage);await p.locator('[data-testid=workbench-page]').waitFor()},projectStage:stage,...(stage==='storyboard'?{}:{missing:'原件renderProject切阶段后仍渲染同一分镜网格,无此阶段内容样本'})})),
|
|
{name:'project-compare',ref:'project',run:async()=>{await goto('/workbench/'+project.id+'?stage=storyboard');await p.getByRole('button',{name:'对比已确认版',exact:true}).click()},missing:'原件比较按钮没有比较弹窗实现'},
|
|
{name:'project-confirmed',ref:'project',run:async()=>{await api(stagePath('storyboard')+'/confirm',{});await goto('/workbench/'+project.id+'?stage=storyboard')},projectStage:'storyboard'},
|
|
{name:'workflows-long-disabled',ref:'workflows',run:async()=>{await goto('/workflows');await p.getByRole('textbox',{name:'搜索名称、文件名、模型…',exact:true}).fill('HEL806');await wait(100)},basis:'content-mapped-table'},
|
|
{name:'connections-probed',ref:'models',run:async()=>{await goto('/connections');await p.getByText('连接测试通过',{exact:false}).first().waitFor()},basis:'content-mapped-cards'},
|
|
{name:'connections-empty',ref:'models',run:()=>emptyRoute('/connections','**/api/settings',{...settings,comfyui_endpoints:[],comfyui_active_id:null}),missing:'原件没有无本地连接状态'},
|
|
{name:'connections-edit',ref:'models',run:async()=>{await goto('/connections');await p.getByRole('button',{name:'编辑',exact:true}).first().click()},missing:'原件编辑按钮没有编辑表单实现'},
|
|
{name:'models-llm',ref:'models',run:()=>goto('/connections?tab=llm'),missing:'原件大语言模型页签没有内容实现'},
|
|
{name:'models-cloud-image',ref:'models',run:()=>goto('/connections?tab=image'),basis:'cloud-card-subset'},
|
|
{name:'models-cloud-video',ref:'models',run:()=>goto('/connections?tab=video'),basis:'cloud-card-subset'},
|
|
{name:'tasks-real',ref:'tasks',run:()=>goto('/tasks'),basis:'content-mapped-table'},
|
|
{name:'tasks-empty',ref:'tasks',run:()=>emptyRoute('/tasks','**/api/jobs',[]),missing:'原件没有零任务空态'},
|
|
{name:'library-real',ref:'library',run:()=>goto('/library'),basis:'content-mapped-media'},
|
|
{name:'library-empty',ref:'library',run:()=>emptyRoute('/library','**/api/library/media',[]),missing:'原件没有零素材空态'},
|
|
{name:'settings',ref:'settings',run:()=>goto('/settings'),basis:'approved-real-settings'},
|
|
{name:'settings-invalid',ref:'settings',run:async()=>{await goto('/settings');await p.locator('input[type=number]').first().fill('0')},missing:'原件无数值校验提示的实现,保留真实字段校验界面'},
|
|
{name:'canvas-current',ref:'canvas',run:()=>goto('/canvas'),missing:'原件仅组织说明页,待总管另补样本'},
|
|
{name:'scene-current',ref:'canvas',run:async()=>{await goto('/build-scene');await p.locator('canvas').first().waitFor();await wait(1500)},missing:'原件仅组织说明页,待总管另补样本'}
|
|
];
|
|
for(const item of cases.filter(x=>!process.env.HEL806_CASES||process.env.HEL806_CASES==='*'||process.env.HEL806_CASES.split(',').includes(x.name))){
|
|
await p.unrouteAll({behavior:'wait'});await item.run();
|
|
for(const [width,height]of [[1440,900],[1366,768],[1280,720]])for(const theme of ['night','day','grade','bluehour']){
|
|
await p.setViewportSize({width,height});await s.setViewportSize({width,height});
|
|
await p.evaluate(t=>{document.documentElement.dataset.theme=t;window.dispatchEvent(new StorageEvent('storage',{key:'aigc-theme',newValue:t}))},theme);
|
|
await s.goto('http://127.0.0.1:'+sample.address().port);await s.evaluate(({ref,theme})=>{go(ref);document.documentElement.dataset.theme=theme;document.documentElement.classList.add('reduce');document.querySelector('#toasts').replaceChildren()}, {ref:item.ref,theme});
|
|
const prefix=OUT+'/shots/'+item.name+'-'+theme+'-'+width;
|
|
await s.screenshot({path:prefix+'-original.png',animations:'disabled'});
|
|
let mapping={};
|
|
if(item.name==='studio-real'){
|
|
const data=await p.evaluate(()=>({eye:document.querySelector('.studio-eyebrow').textContent,title:document.querySelector('.studio-display').innerText,em:document.querySelector('.studio-display em').textContent,description:document.querySelector('.hero-description').textContent,stages:[...document.querySelectorAll('.studio-stages>div')].map(e=>({text:e.textContent,done:e.classList.contains('done'),cur:e.classList.contains('cur')})),cards:[...document.querySelectorAll('.a-card')].map(e=>({title:e.querySelector('.title')?.textContent,status:e.querySelector('.status-tag')?.textContent,meta:e.querySelector('.meta')?.innerText,cover:e.querySelector('img')?.src})),confirm:[...document.querySelectorAll('.studio-side .confirm-item')].map(e=>e.innerText)}));mapping=data;
|
|
await s.evaluate(data=>{const hero=document.querySelector('#p-studio .hero');hero.querySelector('.eyebrow').textContent=data.eye;const d=hero.querySelector('.display'),em=document.createElement('em');em.textContent=data.em;d.replaceChildren(data.title.split('\n')[0],document.createElement('br'),em,' '+data.title.split('\n').slice(1).join(' ').replace(data.em,''));hero.querySelector('.copy p').textContent=data.description;hero.querySelector('.art').style.backgroundImage='none';hero.querySelector('.copy .row .btn:last-child').textContent='查看阶段草稿';hero.querySelectorAll('.stagebar>div').forEach((e,i)=>{e.classList.toggle('done',data.stages[i].done);e.classList.toggle('cur',data.stages[i].cur)});document.querySelectorAll('#p-studio .quick p')[1].textContent='粘贴剧本文本';const list=document.querySelector('#projGrid'),template=list.firstElementChild.cloneNode(true),add=list.lastElementChild.cloneNode(true);list.replaceChildren();for(const card of data.cards){const el=template.cloneNode(true);el.querySelector('.cv').style.backgroundImage=card.cover?`url("${card.cover}")`:'none';el.querySelector('.pb b').textContent=card.title;el.querySelector('.tag').textContent=card.status;el.querySelector('.pb>.row').textContent=card.meta;list.append(el)}list.append(add);document.querySelector('#p-studio .sec-h .tag').textContent=data.cards.length;},data);
|
|
}
|
|
if(item.creative){
|
|
const id=+new URL(p.url()).searchParams.get('wf'),w=await api('/api/workflows/'+id);
|
|
const data=await p.evaluate(()=>({prompt:document.querySelector('#desk-prompt')?.value||'',negative:document.querySelector('#desk-negative')?.value||'',uploads:[...document.querySelectorAll('.media-token img')].map(e=>e.src),file:document.querySelector('.workflow-file')?.textContent,connection:document.querySelector('.studio-heading .conn')?.textContent,media:document.querySelector('.print img,.print video')?.src,ratio:(()=>{const e=document.querySelector('.print img,.print video');return e?((e.naturalWidth||e.videoWidth)/(e.naturalHeight||e.videoHeight)):null})(),failed:document.querySelector('.stage-empty')?.innerText?.includes('失败')}));
|
|
mapping={workflow:w.name,...data};
|
|
await s.evaluate(({w,data,kind})=>{st.kind=kind;const slots=w.input_schema.filter(x=>['image','mask'].includes(x.kind)).map(x=>[x.role==='mask'?'mask':x.role==='first_frame'?'first':x.role==='last_frame'?'last':'input',1,1,true]);const mapped={...WF.find(x=>x.k===kind),id:w.id,k:kind,name:w.name,file:data.file||w.name,slots,neg:!!data.negative||w.input_schema.some(x=>x.role==='negative'),ready:true,pending:false};WF.splice(0,WF.length,mapped);st.sel[kind]=w.id;st.q=w.name;document.querySelector('#wfSearch').value=w.name;st.hist[kind]=data.media?[{n:1,k:kind,wf:w.id,ratio:data.ratio||1,seed:42,img:data.media}]:data.failed?[{n:1,k:kind,wf:w.id,fail:true}]:[];st.fills[w.id]={};slots.forEach((x,i)=>{if(data.uploads[i])st.fills[w.id][x[0]+i]=data.uploads[i]});renderCreate();document.querySelector('#posTa').value=data.prompt;document.querySelector('#negTa').value=data.negative;count();if(data.prompt.length>1000)document.querySelector('#dock').classList.add('tall')},{w,data,kind:new URL(p.url()).searchParams.get('kind')||'image'});
|
|
}
|
|
if(item.projectStage==='storyboard'){
|
|
const texts=await p.locator('.storyboard-card').allTextContents();mapping={project:project.title,shots:stages.storyboard.shots,texts};
|
|
await s.evaluate(({title,shots,texts})=>{document.querySelector('#p-project .crumb b').textContent=title;document.querySelectorAll('#projShots .scard').forEach((e,i)=>{e.querySelector('.im').style.backgroundImage='none';e.querySelector('.bd p').textContent=i?'女孩沿着海岸走向灯塔,纸船随海风起伏。':(texts[0]?.includes('等待确认')?'等待确认的新草稿':'女孩沿着海岸走向灯塔,纸船随海风起伏。');e.querySelector('.bd b').textContent='远景';e.querySelector('.tc').textContent=String(i+1).padStart(2,'0')+' · 5s';e.querySelector('.st .tag').textContent='待画'});document.querySelector('#projTasks').replaceChildren();document.querySelector('#draftbar').classList.toggle('hide',!texts[0]?.includes('等待确认'))},{title:project.title,shots:stages.storyboard.shots,texts});
|
|
}
|
|
if(item.name==='tasks-real'){
|
|
const cells=await p.locator('.task-table tbody tr').evaluateAll(es=>es.map(e=>[...e.cells].map(c=>c.innerText)));
|
|
const thumbnails=await p.locator('.task-table tbody tr').evaluateAll(es=>es.map(e=>e.cells[0].querySelector('img')?.src||''));mapping={cells,thumbnails};
|
|
await s.evaluate(({cells,thumbnails})=>{const tbody=document.querySelector('#taskTable'),template=tbody.firstElementChild.cloneNode(true),button=template.querySelector('button').cloneNode(true);tbody.replaceChildren();for(const [idx,cellsRow] of cells.entries()){const row=template.cloneNode(true);[...row.cells].forEach((e,i)=>{if(i===0)e.firstElementChild.style.backgroundImage=thumbnails[idx]?`url("${thumbnails[idx]}")`:'none';else if(i===1)e.querySelector('b').textContent=cellsRow[i];else if(i===5){const tag=e.querySelector('.tag');tag.textContent=cellsRow[i];tag.className='tag'+(cellsRow[i].includes('失败')?' err':cellsRow[i].includes('完成')?' ok':'');e.querySelector('.bar')?.remove()}else if(i===7){const b=button.cloneNode(true);b.textContent=cellsRow[i];b.className='btn sm'+(cellsRow[i].includes('重试')?'':' ghost');e.querySelector('.row').replaceChildren(b)}else e.textContent=cellsRow[i]||''});tbody.append(row)}},{cells,thumbnails});
|
|
}
|
|
if(item.name==='workflows-long-disabled'){
|
|
const cells=await p.locator('.mg-table tbody tr').evaluateAll(es=>es.map(e=>[...e.cells].map(c=>c.innerText)));mapping={cells};
|
|
await s.evaluate(cells=>{const body=document.querySelector('#wfTable'),template=body.firstElementChild.cloneNode(true);body.replaceChildren();for(const vals of cells){const row=template.cloneNode(true);[...row.cells].forEach((e,i)=>{if(i===0){e.querySelector('b').textContent=vals[i].split('\n')[0];e.querySelector('small').textContent=vals[i].split('\n').slice(1).join(' ')}else if(i<5){const child=e.querySelector('.tag,.dim');if(child)child.textContent=vals[i];else e.textContent=vals[i]}});body.append(row)}},cells);
|
|
}
|
|
if(item.name==='library-real'){
|
|
const media=await p.locator('.asset-preview img,.asset-preview video').evaluateAll(es=>es.map(e=>({src:e.src,kind:e.tagName})));for(const [i,m]of media.entries())if(m.kind==='VIDEO'){const video=p.locator('.asset-preview video').nth(media.slice(0,i).filter(x=>x.kind==='VIDEO').length);m.src='data:image/png;base64,'+(await video.screenshot()).toString('base64')};mapping={media};
|
|
await s.evaluate(media=>{const grid=document.querySelector('#libGrid'),template=grid.firstElementChild.cloneNode(true);grid.replaceChildren();for(const m of media){const el=template.cloneNode(true);el.querySelector('img').src=m.src;el.querySelector('.tag')?.remove();grid.append(el)}},media);
|
|
}
|
|
if(item.name.startsWith('models-cloud'))await s.evaluate(kind=>{const cards=document.querySelector('#modelCards');[...cards.children].forEach((e,i)=>{if(kind==='image'?![2].includes(i):![3,4].includes(i))e.remove()});document.querySelectorAll('#p-models .seg button').forEach((e,i)=>e.classList.toggle('on',i===(kind==='image'?2:3)))},item.name.endsWith('image')?'image':'video');
|
|
if(item.name==='connections-probed'){
|
|
const cards=await p.locator('.mg-card').evaluateAll(es=>es.map(e=>e.innerText));mapping={cards};await s.evaluate(cards=>{const c=document.querySelector('#modelCards');const template=c.firstElementChild.cloneNode(true);const add=c.lastElementChild.cloneNode(true);const clouds=[...c.children].slice(2,5);c.replaceChildren();for(const text of cards.filter(x=>x.includes('http://'))){const e=template.cloneNode(true),lines=text.split('\n').filter(Boolean);e.querySelector('b').textContent=lines[0];e.querySelector('.mono').textContent=lines.find(x=>x.includes('http://'));e.querySelector('.muted').textContent=lines.find(x=>x.includes('队列未知'));e.querySelector('.lat').textContent=lines.find(x=>/^\d+ms$/.test(x))||'—';c.append(e)}c.append(...clouds,add)},cards);
|
|
}
|
|
if(item.creative)await s.evaluate(()=>renderViewport());
|
|
await wait(80);await p.screenshot({path:prefix+'-actual.png',animations:'disabled'});await s.screenshot({path:prefix+'-mapped.png',animations:'disabled'});
|
|
const actual=await metrics(p,{rail:'aside.sidebar',header:'.management-header,.studio-header,.studio-heading,.project-header',content:'.mg-main,.studio-hero,.reference-desk,.project-content,.mg-media',primary:'.dock .gen,[data-testid=stage-confirm-btn]',footer:'.project-footer',card:'.mg-card,.storyboard-card,.asset-card',input:'#desk-prompt',modal:'.modal-panel',frame:'.print',ring:'.desk-emblem'});
|
|
const sampleValues=await metrics(s,{rail:'.rail',header:'#p-'+item.ref+' .ph',content:'#p-'+item.ref+' .mg-main,#p-'+item.ref+' .hero,#p-'+item.ref+' .create,#p-'+item.ref+' .proj-main,#libGrid',primary:'#genBtn,#confirmStage',footer:'#p-project .proj-foot',card:'#p-'+item.ref+' .mcard,#p-'+item.ref+' .scard,#libGrid>div',input:'#posTa',modal:'.pop.on',frame:'.frame,.player',ring:'.empty-stage .ring'});
|
|
result.rows.push({name:item.name,theme,width,height,basis:item.missing?'missing-reference':item.basis||'content-map-partial',missing:item.missing,mapping,actual,sample:sampleValues});
|
|
}
|
|
console.log('CAPTURED',item.name,12);fs.writeFileSync(OUT+'/results.json',JSON.stringify(result,null,2));
|
|
}
|
|
await c.close();ok('no pageerror',result.errors.length===0);
|
|
}finally{fs.writeFileSync(OUT+'/results.json',JSON.stringify(result,null,2));await browser.close();await new Promise(r=>sample.close(r))}
|
|
})().catch(e=>{console.error(e);process.exitCode=1});
|