// Local GET-only:129 entries/5 Notes/42 exact/2 bounded unresolved/46 unversioned aliases. import fs from 'node:fs'; import assert from 'node:assert/strict'; import crypto from 'node:crypto'; const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright'); const out='.local-evidence/singleloop-document/browser';fs.mkdirSync(out,{recursive:true}); const checks=[],requests=[],errors=[],blockedFonts=[],assertionGroups={},interceptions=[];let group='aggregate'; const textRenderings=[]; function check(condition,label){assert.ok(condition,label);checks.push(label);assertionGroups[group]=(assertionGroups[group]||0)+1;console.log('PASS '+label);} function assertLocalUrl(raw){ const u=new URL(String(raw));assert.ok(u.protocol==='http:'&&['127.0.0.1','localhost'].includes(u.hostname)&&['8247','5173'].includes(u.port)&&!u.username&&!u.password,'Refused before request: '+u);return u; } function localFetch(raw){assertLocalUrl(raw);return fetch(raw);} for(const raw of ['http://6.0.0.1:8247/api/workflows','http://127.0.0.1:9999/','https://example.invalid/','http://127.0.0.1:8247@evil.invalid/']){assert.throws(()=>assertLocalUrl(raw));check(true,'URL预检拒绝且未发送 '+raw);} for(const raw of ['http://127.0.0.1:8247/api/workflows','http://127.0.0.1:5173/connections'])assertLocalUrl(raw); const browser=await chromium.launch({headless:true,executablePath:process.env.BROWSER_EXECUTABLE}); try { const page=await browser.newPage({viewport:{width:1440,height:1000}}); await page.routeWebSocket('**/*',ws=>{ws.close();}); // No HMR socket transport is needed for read-only checks. await page.route('**/*',route=>{ const u=new URL(route.request().url()); if(u.hostname==='fonts.googleapis.com'){blockedFonts.push(String(u));return route.fulfill({contentType:'text/css',body:''});} try{assertLocalUrl(u);}catch(e){errors.push(String(e));return route.abort();} if(route.request().method()!=='GET'||u.pathname==='/api/view'||(/\.(mp4|png|wav|mp3|webm)$/i.test(u.pathname)&&u.pathname!=='/favicon.png')){errors.push('Forbidden request '+u);return route.abort();} return route.continue(); }); page.on('request',r=>{if(r.url().includes('/api/'))requests.push({method:r.method(),url:r.url()});}); page.on('pageerror',e=>errors.push(e.message)); requests.push({method:'GET',url:'http://127.0.0.1:8247/api/workflows'}); const records=await(await localFetch('http://127.0.0.1:8247/api/workflows')).json(); const names=['Wan2.1_infinitetalk_音频驱动视频配音-单人for循环长视频(官流)','Wan2.1_I2V_InfiniteTalk_提示词调度动作控制图生视频数字人(KJ版)','minimax-h3首尾帧生视频无审核版','minimax-h3文生视频无审核版','minimax-h3多参生视频无审核版','Minimax_H3_视频动作参考_SelfLift双采样潜放大_Qwen3.8官方Skills自动提示词','Minimax_H3_r2v_参考生视频_双采样潜空间放大+Qwen3.8官方Skills自动提示词','MiniMax_H3_音频数字人_SelfLift双采样潜放大分块_Qwen3.8官方Skills自动提示词','MiniMax_H3_音频MV_多参长视频分段_Selflift双采潜放大_Qwen3.8官方Skills自动提示词','MiniMax_H3_导演台时间线素材_双采样潜空间放大_多分段拼接','MiniMax_H3_导演台_文-图-参考-分段循环-双采放大_多合一','MiniMax_H3_导演台_双采样多段循环-PV动画尾帧衔接','MiniMax_H3_导演台MiniMaxH3_多合一多分段拼接','MiniMax_H3_导演台_短剧创作-音频参考','MiniMax_H3_导演台_短剧创作-多宫格分镜参考','MiniMax_H3_导演台_视频人物替换','MiniMax_H3_导演台_视频参考+多参图-SelfLift双采样潜放大','MiniMax_H3_导演台_视频参考+多参图','MiniMax_H3_导演台_双采样潜空间放大','MiniMax_H3_导演台_文_图_首尾_参考多合一(单采样)','MiniMax_H3_孤海智能一体化(多合一简化版)','Minimax_H3_音频数字人_单采样','Minimax_H3_T8双采样_潜空间放大_参考生视频','Minimax_H3_T8双时钟采样_参考生视频-8步高质量极速版','Minimax_H3_T8双时钟采样_图生视频-8步高质量极速版','Minimax_H3_T8双时钟采样_文生音视频-8步高质量极速版','MiniMax_H3_多参考_双采样潜空间放大','MiniMax_FastH3_i2v_图生视频8步极速','MiniMax_FastH3_t2v_文生图8步极速','minimax_h3_r2v_多参生视频','minimax_h3_i2v_图生视频','minimax_h3_t2v_文生视频','肖像大师_美女提示词生成','Qwen_image2.1_图像编辑_深度-姿势-线稿-硬边缘-控图洗图','Qwen_Image2.1_图像编辑_VNCCS任意角度-任意姿势','Qwen_image2.1_图像编辑_角色BFS头部迁移','Qwen_image2.1_图像编辑_一键16张姿势图','Qwen_image2.1_图像编辑_动漫转真人','Qwen_image2.1_图像编辑_角色表四视图','Qwen_image2.1_文生图_角色表四视图','Qwen_image2.1_文生_多图编辑_透明背景','Qwen_image2.1_文生_多图编辑_提示词增强(N版)','Qwen_image2.1_文生_多图编辑_8步lora加速','Anima_Klein放大_超强动漫模型','krea2_turbo_文生图_2万提示词随机模板+4千种风格选择','Krea2_turbo_文生图_4_6_8宫格故事板','Krea2_turbo_文生图_极致写实双采样2k版(N版)','Krea2_turbo_文生图_角色三视图双采样2k版','krea2_turbo_文生图_Qwen3.5自动提示词生成','krea2-Edit-Anything2Real_动漫转真人v3','krea2_identity_edit_图像编辑','krea2_turbo_文生图_极致写实(N版)','krea2_turbo_文生图 (N版)','krea2_turbo_文生图_图像风格参考','krea2_turbo_文生图_动漫风格Image2风格','krea2_turbo_文生图_动漫风格线条动漫','krea2_turbo_文生图_动漫风格2.5D半写实','krea2_turbo_文生图_奇幻现实风格','krea2_turbo_文生图_赛博朋克现实风格','krea2_turbo_文生图_美学质量增强','krea2_turbo_文生图_细节增强','krea2_turbo_文生图','Z_Image_turbo_十八种风格_通用b','Z_Image_turbo_十八种风格_通用a_','Z_Image_turbo_十八种风格_照片摄影','Z_Image_turbo_十八种风格_插图漫画','12_Z_Image_Tubro_文生图_SeedVR2高清放大8K','11_Z_Image_Turbo+模型放大_图像4K高清放大','10_Z_Image双采样+Fluax2-klein修复-高清直出','9_Z-Image+Flux2-Klein_风格重新编辑','8_Z-image+Controlnet_姿势控制-洗图','7_Z-image+Controlnet_图像扩展','6_Z-image_局部重绘','5_Z-Image+Qwen3.5提示词反推_文生图','4_Z-Image+Qwen3.5-文生图','3_Z-Image_文生图(摇光梦幻).app','2_Z-Image+Base+Turbo+双重采样工作流','1_Z-Image-Tubro_文生图','flux2_klein-图生图_人物动作迁移','flux2_klein_图生图_人物迁移','flux2_klein_图生图_印花提取','flux2_klein_服装迁移','flux2_klein_图生图_老照片修复','10_flux2_klein_文生图-角色三视图','8_flux2_klein_双图编辑','7_flux2_klein_图生图-动漫转真人','6_flux2-klein+Qwen3.5_转线稿洗图','5_flux2_klein_图生图_扩图','4_flux2_klein_图生图_局部重绘','3_flux2_klein_图生图一致性增强(大雄lora)','3_flux2_klein_图生图一致性增强(小志lora)','2_flux2_klein_图生图','1_flux2_klein_文生图','minimax_music_文生音乐','ace_step_1.5+Qwen3.5_自动歌词音乐生成','ace_step1_5_xl_turbo_8Step极速音乐生成','index-TTS2-情绪控制-音频参考-文本控制-克隆-多人对话','Qwen3-TTS_语音设计+语音克隆','Qwen3-TTS_多角色对话','Llama-cpp+Qwen3.5-提示词','moge3_深度图_几何图_线稿图','Seedvr2_视频放大FOR循环长视频','VOSR2_视频放大_分批循环长视频','视频模型放大插帧(简单快速版)','图像放大比较','VOSR2_图像超分放大','Seedvr2_3b_int8_视频放大','Seedvr2_3b_int8_图像放大','RTX_video_upscale','RTX_image_upscale','手动按分镜视频截取','sam3_图像视频-提示词遮罩分割','多视频合成分屏展示','图像4种添加水印节点','birefnet_图像移除背景','加载本地latent解码','截取视频每一帧','双图像或视频合并显示','视频转gif动图图片','加载图片合成视频','视频倒放','NLF_视频人物动作骨架获取','openpose-video-姿态检测','sdpose_视频人物姿势骨架提取','gemma4_提示词反推(图像视频音频)','图像合并成四宫格','图像分割-多宫格分割','Qwen_image2.1_图像编辑_背景移除','Qwen_image2.1_图像编辑_提示词增强','Qwen_image2.1_文生图_提示词增强','ControlNet_aux_常用样例','Qwen3-ASR-语音转文字','Qwen3-ASR-Subtitle语音转字幕','Minimax-H3提示词增强','音频转MP3格式','音频人声分离','视频-音频分离','图像嵌入文字描述']; const details=[];let actualGetRaw; for(const name of names){const r=records.find(r=>r.name===name);assert.ok(r);const url=`http://127.0.0.1:8247/api/workflows/${r.id}`;requests.push({method:'GET',url});const response=await localFetch(url);const raw=await response.text();const detail=JSON.parse(raw);if(name===names[0])actualGetRaw=raw;details.push(detail);} check(details.length===138&&details.reduce((n,d)=>n+d.doc_json.fixed_version.fields.length,0)===8480,'138图8480保存条目'); check(details.reduce((n,d)=>n+(d.doc_json.source_notes?.length||0),0)===246,'138图246源注释'); await page.goto(assertLocalUrl('http://127.0.0.1:5173/connections').href,{waitUntil:'networkidle'}); const dialog=page.getByRole('dialog',{name:'工作流说明'}); const fixedCard=dialog.locator('.card').filter({has:page.getByText('固定版本参数说明',{exact:true})}); async function begin(name){const row=page.locator('.wf-row').filter({has:page.getByText(name,{exact:true})}).first();const button=row.getByRole('button',{name:'说明',exact:true});await button.focus();await page.keyboard.press('Enter');return button;} async function loaded(){await dialog.getByText('用途与来源',{exact:true}).waitFor();await dialog.evaluate(el=>Promise.all(el.getAnimations().map(a=>a.finished)));} for(const width of [1440,390]){ await page.setViewportSize({width,height:width===390?844:1000}); for(const d of details){ group=details.indexOf(d)<1?'new_singleloop':'old_one_hundred_thirty_seven';const b=d.doc_json.fixed_version,button=await begin(d.name);await loaded(); const overview=dialog.locator('.card').filter({has:page.getByText('用途与来源',{exact:true})}); check((await overview.innerText()).includes(b.user_overview),`${width} ${d.name}默认中文用途`); check(!(await dialog.getByText('源图与审校记录',{exact:true}).locator('..').evaluate(el=>el.open)),`${width} ${d.name}源审校默认折叠`); check(!(await dialog.getByText('核对范围与来源依据',{exact:true}).locator('..').evaluate(el=>el.open)),`${width} ${d.name}技术范围默认折叠`); const visible=await fixedCard.innerText(); check(!visible.includes('执行标量')&&!visible.includes('widgetId')&&!visible.includes(b.source_sha256)&&!visible.includes('UUID'),`${width} ${d.name}默认无执行计数/实现标识`); check(visible.includes('依据固定版本整理,目标环境与实际效果未核对。'),`${width} ${d.name}默认依据限制可见`); for(const t of ['说明未定稿','未验证实跑','未检查'])check((await dialog.innerText()).includes(t),`${width} ${d.name} ${t}`); check(!d.is_enabled&&!d.doc_completed_at&&!d.exec_verified_at,`${width} ${d.name}停用/时间戳空`); check(await fixedCard.locator('summary').filter({hasText:/^节点 [\d:]+ · /}).count()===b.fields.length,`${width} ${d.name}参数全保留`); check(await dialog.locator('.drawer-body').evaluate(el=>el.scrollWidth<=el.clientWidth),`${width} ${d.name}默认无溢出`); await dialog.locator('.drawer-body').evaluate(el=>el.scrollTop=0); if(details.indexOf(d)<1)await page.screenshot({path:`${out}/${width}-${d.id}-default.png`}); if(details.indexOf(d)>0){await page.keyboard.press('Escape');await dialog.waitFor({state:'hidden'});check(await button.evaluate(el=>el===document.activeElement),`${width} ${d.name}旧图归还焦点`);continue;} await dialog.getByText('源图与审校记录',{exact:true}).click(); check((await overview.innerText()).includes(d.doc_json.purpose)&&(await overview.innerText()).includes(d.source_repo_path),`${width} ${d.name}原用途/源路径展开保留`); await dialog.getByText('核对范围与来源依据',{exact:true}).click(); const flowText=await fixedCard.innerText();check(flowText.includes(`被连线覆盖 ${b.counts.linked_saved_fields} 项`)&&flowText.includes(`仅前端控制 ${b.counts.frontend_only} 项`),`${width}准确覆盖与前端位置计数`); for(const line of b.flow)check(flowText.replace(/\s+/g," ").includes(line.replace(/\s+/g," ")),`${width} ${d.name}展开流程 ${b.flow.indexOf(line)}`); const field=(nid,name)=>b.fields.find(f=>f.node_id===nid&&f.field===name); check(b.counts.saved_fields===129&&b.comments.length===5&&b.boundaries.length===0&&b.zero_saved_nodes.length===8,`${width}129原条目/五注释/无子图/八真实[]`); check(b.fields.every(f=>f.scope==='root'&&f.named_state==='missing'&&!('named_pointer'in f)&&!('named_value'in f)),`${width}全部无具名/不造双指针`); check(b.node_bindings.length===90&&b.node_bindings.filter(x=>x.implementation_verified).length===42&&b.node_bindings.filter(x=>x.source_id.startsWith('unresolved-')).map(x=>x.node_id).sort().join(',')==='129,232'&&b.node_bindings.filter(x=>x.source_id==='unknown-no-version').length===46,`${width}42准确/两Wan入口未匹配/46无版本别名`); check(b.sources.some(x=>x.id==='rgthree'&&x.tag==='1.0.2512112053')&&b.sources.some(x=>x.id==='litegraph'&&x.file==='src/lib/litegraph/LICENSE'),`${width}发布成员与内部LiteGraph独立许可`); const source=JSON.parse(fs.readFileSync('docs/hel-892/singleloop-document-evidence/source-check.json')); const node=n=>JSON.parse(b.flow.find(x=>x.startsWith(n+' 原节点完整保存 ')).split(' 原节点完整保存 ')[1]); const edges=b.flow.filter(x=>x.startsWith('root 物理边 ')).map(x=>JSON.parse(x.slice('root 物理边 '.length))); const edge=(id,from,to)=>{const e=edges.find(e=>e[0]===id);return e&&e[1]===from&&e[3]===to;}; check(b.counts.physical_edges===90&&edges.length===90,`${width}90物理边完整保留`); check(b.node_bindings.every(x=>node(Number(x.node_id)).mode===0)&&[17,172,238,25,253,260,266,267].every(id=>node(id).widgets_values.length===0),`${width}全mode0与八真实[]`); check(node(263).widgets_values.slice(1).every(x=>x===null)&&!('links'in node(253).outputs[1])&&[245,246].every(id=>!('links'in node(id).outputs[0])),`${width}音频两null与未消费缺links分列`); check(edge(532,129,172)&&edge(636,172,266)&&edge(599,232,238)&&edge(641,238,267)&&node(172).outputs[1].links.length===0&&node(238).outputs[1].links.length===0,`${width}两真LATENT起点/普通output解码/denoised[]`); check(edge(642,267,259)&&edge(625,232,259)&&field('259','batch_index').value===0&&field('259','length').value===4096,`${width}裁后帧起点覆盖与4096缓存`); check(edge(616,252,232)&&edge(628,252,260)&&edge(622,259,260)&&edge(626,260,253)&&edge(634,265,246),`${width}前段帧/裁后帧/拼合/别名分隔原边`); check(edge(621,212,252)&&edge(617,252,254)&&edge(618,254,255)&&edge(635,254,253)&&edge(619,256,257)&&field('252','total').value===1,`${width}total/index/初值原物理边不求值`); check(field('212','expression').value==='ceil((a*b+1-c)/c)'&&field('254','expression').value==='a+1'&&field('248','value').json_type==='int'&&field('248','value').value===25&&field('256','value').value===121&&field('174','value').value===6,`${width}完整表达式与FloatConstant原JSON int`); check(edge(629,200,261)&&edge(630,261,25)&&edge(606,191,245)&&edge(609,235,246)&&field('263','audio').value==='冰沙王子.WAV',`${width}音频分叉与正式音轨Get只名称意图`); check(edge(542,32,183)&&edge(602,32,240)&&edge(601,239,240)&&node(32).outputs[1].links.length===0,`${width}图像直供视觉/Set分叉/MASK[]`); check(edge(528,129,169)&&edge(529,129,170)&&edge(576,232,230)&&edge(579,232,231)&&field('171','noise_seed').value===460326298055398&&field('229','noise_seed').value===515326640083775,`${width}各Wan输出MODEL供Guider/Scheduler与独立seed`); for(const [nid,rate] of [['245',16],['246',25]]){ const history=field(nid,'videopreview');const json=JSON.stringify(history.value);const hash=crypto.createHash('sha256').update(json).digest('hex'); check(b.fields.filter(f=>f.node_id===nid).length===11&&history.json_type==='dict'&&history.pointer.endsWith('/widgets_values/videopreview')&&history.value.params.score==='0'&&history.value.params.frame_rate===rate&&field(nid,'frame_rate').value===25,`${width} ${nid}十标量/完整历史/score str0/帧率分列`); textRenderings.push({viewport:width,kind:'history'+nid,canonical_js_sha256:hash}); } for(const phrase of ['42准确类/发布成员实例','两个具体unresolved','46个Set/Get只有aux','不宣称全仓不存在','src/lib/litegraph','准确树缺LICENSE','不补成此未核Wan协议'])check(b.steps.some(x=>x.includes(phrase)),`${width}准确来源与具体边界 ${phrase}`); const notesBox=dialog.locator('.card').filter({has:page.getByText('源文件注释',{exact:true})}); for(const n of b.comments){ const nd=notesBox.locator('details').filter({has:page.getByText(`节点 ${n.node_id}`,{exact:true})});await nd.locator('summary').click();const renderedJSON=await nd.locator('pre').textContent(); const sourceNote=d.doc_json.source_notes.find(x=>String(x.node_id)===n.node_id);assert.equal(renderedJSON,JSON.stringify(sourceNote.content,null,2));const decoded=JSON.parse(renderedJSON)[0];assert.equal(decoded,n.text);const rawSha=crypto.createHash('sha256').update(decoded,'utf8').digest('hex');const expected=source.notes.find(x=>x.node===n.node_id); check(Array.from(decoded).length===expected.characters&&decoded.split('\n').length-1===expected.LF&&decoded.split('\r').length-1===expected.CR&&decoded.endsWith('\n')===expected.tail_LF&&rawSha===expected.sha256,`${width}Note${n.node_id}完整/LF/尾LF/SHA`);textRenderings.push({viewport:width,kind:`Note${n.node_id}`,raw_sha256:rawSha,rendered_json_sha256:crypto.createHash('sha256').update(renderedJSON,'utf8').digest('hex'),decoded_sha256:rawSha,tail_LF:expected.tail_LF}); await nd.evaluate(el=>el.scrollIntoView({block:'start'}));await page.screenshot({path:`${out}/${width}-${d.id}-note-${n.node_id}.png`});await nd.locator('summary').click(); } check(await dialog.locator('img,canvas,video,audio,iframe').count()===0,`${width}只文本无媒体/编辑器`); for(const [phrase,label]of [['重要准确来源缺口','source-gap'],['首段实际LATENT532','first-latent'],['循环段实际LATENT599','loop-latent'],['252.value1经616','loop-physical'],['200 Get629','audio-fork'],['两VHS保存frame_rate','vhs-history']]){ const line=b.flow.filter(x=>x.includes(phrase)).sort((a,b)=>a.length-b.length)[0];await fixedCard.getByText(line,{exact:true}).first().evaluate(el=>el.scrollIntoView({block:'start'}));await page.screenshot({path:`${out}/${width}-${d.id}-${label}.png`}); } await dialog.getByText('版本、源图与连线依据',{exact:true}).click(); check((await fixedCard.innerText()).includes(b.source_sha256)&&b.versions.every(v=>(v&&true)),`${width} ${d.name}原件摘要可展开`); const versionText=await fixedCard.innerText(); for(const v of b.versions)check(versionText.includes(v),`${width} ${d.name}版本 ${b.versions.indexOf(v)}`); if(details.indexOf(d)<1){ for(const f of b.fields){ const summary=fixedCard.locator(`details[data-fixed-field="${f.pointer}"] > summary`);await summary.focus();await page.keyboard.press('Enter');const box=summary.locator('..'); check(await box.evaluate(el=>el.open),`${width} ${f.node_id}.${f.field}键盘展开`); let text=await box.innerText();const has=value=>text.replace(/\s+/g,' ').includes(value.replace(/\s+/g,' '));check(has(f.label)&&has(f.effect)&&has(f.limits)&&has(f.schema_default)&&has(f.execution_note)&&has(f.unit),`${width} ${f.node_id}.${f.field}用途/未知单位范围/身份条件`); check(await box.locator(':scope > pre').first().textContent()===(typeof f.value==='string'?f.value:JSON.stringify(f.value,null,2)),`${width} ${f.node_id}.${f.field}精确保留现值`); check(!text.includes(f.pointer),`${width} ${f.node_id}.${f.field}指针默认折叠`); await box.getByText('来源依据',{exact:true}).click();text=await box.innerText(); check(text.includes(f.pointer)&&(!f.named_pointer||text.includes(f.named_pointer))&&text.includes(f.class_type)&&text.includes(f.json_type)&&f.evidence.every(i=>{const e=b.sources[i];return (!e.commit||text.includes(e.commit))&&text.includes(e.sha256)&&text.includes(e.lines.join('~'));}),`${width} ${f.node_id}.${f.field}身份记录/源类型/指针`);if(f.named_pointer)check(text.includes(f.named_pointer),`${width} ${f.node_id}.${f.field}原具名指针保留`);else check(f.named_state==='missing'&&!('named_value'in f)&&text.includes('不补具名值/双指针'),`${width}未具名位置保留/不补指针`); if('named_value' in f){check((await box.innerText()).includes(f.named_pointer),`${width} ${f.node_id}.${f.field}具名指针保留`);if(JSON.stringify(f.named_value)!==JSON.stringify(f.value)){const rendered=(await box.locator(':scope > p').first().textContent()).split('具名保存完整形态(与位置历史分列):')[1];assert.deepEqual(JSON.parse(rendered),f.named_value);check(true,`${width} ${f.node_id}.${f.field}具名完整历史含空img对象`);};} check(await dialog.locator('.drawer-body').evaluate(el=>el.scrollWidth<=el.clientWidth),`${width} ${f.node_id}.${f.field}展开无溢出`); if(typeof f.value==='string'&&Array.from(f.value).length>100){ const rendered=await box.locator(':scope > pre').first().textContent();const hash=crypto.createHash('sha256').update(rendered,'utf8').digest('hex');const expected=source.texts.find(x=>x.node===f.node_id&&x.field===f.field);check(rendered===f.value&&hash===expected.sha256&&Array.from(rendered).length===expected.characters&&rendered.split('\n').length-1===expected.LF&&rendered.endsWith('\n')===expected.tail_LF,`${width}完整${f.node_id}.${f.field}长文本/原空白/标点/SHA`);textRenderings.push({viewport:width,kind:f.node_id+'.'+f.field,raw_sha256:hash,rendered_utf8_sha256:hash}); } if(['129.position_0','232.position_3','187.position_0','212.expression','254.expression','248.value','252.total','259.batch_index','261.chunk_overlap','263.audioUI','245.videopreview','246.videopreview','171.noise_seed','239.clip_name'].includes(f.node_id+'.'+f.field)){await summary.evaluate(el=>el.scrollIntoView({block:'start'}));await page.screenshot({path:`${out}/${width}-${d.id}-${f.node_id}-${f.field}.png`});} await summary.click(); } await dialog.getByRole('button',{name:'关闭',exact:true}).focus();await page.keyboard.press('Tab');check(await dialog.evaluate(el=>el.contains(document.activeElement)),`${width}Tab焦点保留`);await page.keyboard.press('Shift+Tab');check(await dialog.evaluate(el=>el.contains(document.activeElement)),`${width}ShiftTab焦点保留`); } await page.keyboard.press('Escape');await dialog.waitFor({state:'hidden'});check(await button.evaluate(el=>el===document.activeElement),`${width} ${d.name}关闭归还焦点`); } } assert.deepEqual(JSON.parse(actualGetRaw),details[0]);fs.writeFileSync(`${out}/actual-get.json`,actualGetRaw); group='shared_regressions'; for(const name of ['旧工作流回退(隔离测试夹具)','空说明回退(隔离测试夹具)']){await begin(name);await loaded();check((await dialog.innerText()).includes('隔离库旧条目回退测试'),'旧/空说明回退 '+name);await page.keyboard.press('Escape');} // Missing summary and mismatched bindings are tested with local GET fixtures, without writes. for(const variant of ['missing-overview','mismatched','html-summary']){ const d=structuredClone(details[0]); if(variant==='missing-overview')delete d.doc_json.fixed_version.user_overview; if(variant==='mismatched')d.doc_json.fixed_version={matched:false,notice:'固定版本参数说明待核对:源文件、声明版本或说明依据未匹配,未采用旧定义。'}; if(variant==='html-summary')d.doc_json.fixed_version.user_overview='仅纯文本'; await page.route(`**/api/workflows/${d.id}`,route=>{interceptions.push({variant,url:route.request().url()});return route.fulfill({json:d});}); const responseReady=page.waitForResponse(r=>new URL(r.url()).pathname===`/api/workflows/${d.id}`&&r.status()===200); await begin(d.name);const fixtureResponse=await responseReady;await fixtureResponse.finished(); const returned=await fixtureResponse.json();assert.deepEqual(returned,d); const expectedSummary=variant==='missing-overview'?'这张图的用途和操作重点可在下方使用步骤中查看;目标环境与实际效果仍待核对。':variant==='mismatched'?d.doc_json.fixed_version.notice:d.doc_json.fixed_version.user_overview; await dialog.getByText(expectedSummary,{exact:true}).waitFor({timeout:20000});await loaded(); if(variant==='missing-overview')check((await dialog.innerText()).includes('这张图的用途和操作重点可在下方使用步骤中查看;目标环境与实际效果仍待核对。'),'缺摘要自然中文回退'); if(variant==='mismatched')check((await dialog.innerText()).includes(d.doc_json.fixed_version.notice)&&!await dialog.getByText('核对范围与来源依据',{exact:true}).count(),'错绑定提示明确且不展示旧字段'); if(variant==='html-summary')check((await dialog.innerText()).includes(d.doc_json.fixed_version.user_overview)&&await dialog.locator('img').count()===0,'摘要HTML仅纯文本不创建图像或请求'); check(!(await dialog.innerText()).includes('undefined'),'回退不暴露undefined');await page.keyboard.press('Escape');await page.unroute(`**/api/workflows/${d.id}`); } let release,entered,delivered;const hold=new Promise(r=>release=r),intercept=new Promise(r=>entered=r),done=new Promise(r=>delivered=r); await page.route(`**/api/workflows/${details[0].id}`,async route=>{interceptions.push({variant:"late",url:route.request().url()});entered();await hold;await route.fulfill({json:details[0]});delivered();}); await begin(details[0].name);await intercept;await page.keyboard.press('Escape');await begin(details[1].name);await loaded();release();await done; check((await dialog.innerText()).includes(details[1].doc_json.fixed_version.user_overview)&&await fixedCard.locator('summary').filter({hasText:/^节点 [\d:]+ · /}).count()===details[1].doc_json.fixed_version.fields.length,'迟到新图响应不覆盖旧图摘要/字段');await page.keyboard.press('Escape');await page.unroute(`**/api/workflows/${details[0].id}`); await page.route(`**/api/workflows/${details[0].id}`,route=>{interceptions.push({variant:'failure',url:route.request().url()});return route.fulfill({status:500,json:{detail:'隔离失败夹具'}});});await begin(details[0].name);await dialog.getByRole('alert').waitFor({timeout:20000});check(await dialog.getByRole('button',{name:'重试',exact:true}).isVisible(),'GET失败显示重试');check(await dialog.getByText('用途与来源',{exact:true}).count()===0,'读取失败隐藏旧摘要');await page.unroute(`**/api/workflows/${details[0].id}`);await dialog.getByRole('button',{name:'重试',exact:true}).click();await loaded();check((await dialog.innerText()).includes(details[0].doc_json.fixed_version.user_overview),'重试恢复摘要');await page.keyboard.press('Escape'); check(errors.length===0,'无脚本错误或禁止请求 '+JSON.stringify(errors));check(requests.every(r=>r.method==='GET'&&new URL(r.url).hostname==='127.0.0.1'&&!r.url.includes('/api/view')),'全程本地GET无写/生成/目标/历史预览请求'); const polling=requests.filter(r=>['/api/jobs','/api/events'].includes(new URL(r.url).pathname)); const fixed=requests.filter(r=>!polling.includes(r)); const frequencies=rs=>Object.fromEntries([...new Set(rs.map(r=>new URL(r.url).pathname))].sort().map(p=>[p,rs.filter(r=>new URL(r.url).pathname===p).length])); fs.writeFileSync(`${out}/browser-results.json`,JSON.stringify({request_accounting:{fixed_count:fixed.length,fixed_paths:frequencies(fixed),polling_count:polling.length,polling_paths:frequencies(polling),polling_tolerance:1,reason:'固定请求逐路径核账;events零差额,只允许已证末次jobs至多1差额;禁止请求零容忍。'},assertion_count:checks.length,assertionGroups,text_renderings:textRenderings,interceptions,checks,requests,errors,blockedFonts,viewports:[1440,390]},null,2)); } finally {await browser.close();}