// Real local detail GET, all 22 new media saved fields, both viewport sizes and document isolation. import fs from 'node:fs'; import assert from 'node:assert/strict'; const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright'); const out = '.local-evidence/background-reading-regression/media-document/browser'; fs.mkdirSync(out, { recursive: true }); const checks = [], requests = [], errors = []; function check(value, text) { assert.ok(value, text); checks.push(text); console.log('PASS ' + text); } 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.route('**/*', route => { const u=new URL(route.request().url()); if(u.hostname==='fonts.googleapis.com')return route.fulfill({contentType:'text/css',body:''}); if(u.hostname!=='127.0.0.1'||u.pathname==='/api/view') {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)); const list = await (await fetch('http://127.0.0.1:8247/api/workflows')).json(); const details = []; for (const name of ['视频-音频分离', '图像嵌入文字描述', 'Minimax-H3提示词增强', '音频转MP3格式', '音频人声分离']) { const record = list.find(x => x.name === name); assert.ok(record); const url = `http://127.0.0.1:8247/api/workflows/${record.id}`; requests.push({ method:'GET', url }); details.push(await (await fetch(url)).json()); } check(details.map(d => d.doc_json.fixed_version.fields.length).join(',') === '8,14,18,5,8', '22新增保存定义与31旧定义独立'); await page.goto('http://127.0.0.1:5173/connections', { waitUntil: 'networkidle' }); const dialog = page.getByRole('dialog', { name: '工作流说明' }); async function begin(name) { const row = page.locator('.wf-row').filter({ has: page.locator('.wf-name').filter({ hasText:name }) }).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 detail of details.slice(0,2)) { const fixed = detail.doc_json.fixed_version; const button = await begin(detail.name); await loaded(); await dialog.getByText('核对范围与来源依据', {exact:true}).click(); check((await dialog.innerText()).includes(fixed.notice), `${width} ${detail.name}声明/假设提示`); for (const text of ['说明未定稿','未验证实跑','未检查']) check((await dialog.innerText()).includes(text), `${width} ${detail.name} ${text}`); check(!detail.is_enabled && detail.import_state==='needs_conversion' && !detail.doc_completed_at && !detail.exec_verified_at, `${width} ${detail.name}资格未改`); const names = fixed.fields.map(f => `节点 ${f.node_id} · ${f.label}`); for (const field of fixed.fields) { const summary = dialog.locator(`details[data-fixed-field="${field.pointer}"] > summary`); await summary.focus(); await page.keyboard.press('Enter'); const box = summary.locator('..'); check(await box.evaluate(el => el.open), `${width} ${field.node_id}.${field.field}键盘展开`); const text = await box.innerText(); check(text.includes(field.effect) && text.includes(field.limits) && text.includes(field.schema_default), `${width} ${field.node_id}.${field.field}语义/默认/限定`); check(await box.locator(':scope > pre').textContent() === (typeof field.value==='string'?field.value:JSON.stringify(field.value,null,2)), `${width} ${field.node_id}.${field.field}原值/类型/null/空值`); await box.getByText('来源依据',{exact:true}).click(); const evidence = await box.innerText(); check(evidence.includes(field.pointer) && field.evidence.every(i => { const e=fixed.sources[i]; return evidence.includes(e.commit) && evidence.includes(e.sha256) && evidence.includes(e.lines.join('~')); }), `${width} ${field.node_id}.${field.field}可回读依据`); check(!evidence.includes('undefined'), `${width} ${field.node_id}.${field.field}无伪具名指针`); check(await dialog.locator('.drawer-body').evaluate(el=>el.scrollWidth<=el.clientWidth), `${width} ${field.node_id}.${field.field}无溢出`); if (['audioUI','chunk_overlap','quality','font_file','font_size','border','image3_text'].includes(field.field)) await page.screenshot({path:`${out}/${width}-${detail.id}-${field.field}.png`}); await summary.click(); } check(await dialog.locator('.card').filter({has:page.getByText('固定版本参数说明',{exact:true})}).locator('summary').filter({hasText:/节点 \d+ · /}).count() === names.length, `${width} ${detail.name}无跨图参数`); const text = await dialog.innerText(); if (detail.name==='视频-音频分离') { for (const line of ['10槽0 → 17.audio','10槽0 → 11.audio','11槽0 Bass低音 → 18.audio','11槽1 Drums鼓 → 19.audio','11槽2 Other其他 → 20.audio','11槽3 Vocals人声 → 15.audio']) check(text.includes(line), `${width}分离图${line}`); check(text.includes('原音轨,不是分离后人声') && text.includes('临时目录FLAC') && text.includes('不保证永久四轨导出'), `${width}原音轨MP3支路与四试听副作用`); check(text.includes('MP4支持、可达性、音轨及实际长度均未核对'), `${width}MP4素材未知`); } else { for (const line of ['3槽0 IMAGE → 1.image1','4槽0 IMAGE → 1.image2','1槽0 Reel → 2.reel_1','2槽0 IMAGE → 5.images']) check(text.includes(line), `${width}排版图${line}`); check(text.includes('两个MASK出口都未接') && text.includes('不会凭空增加图块'), `${width}未接图片和遮罩准确`); check(text.includes('字体未知') && text.includes('字形/长文本边界未验证'), `${width}字体尺寸/效果未知`); check(text.includes('temp目录PNG') && text.includes('ui.images') && text.includes('不是修改图片描述元数据'), `${width}排版用途和临时PNG链`); } await dialog.getByText('固定版本参数说明',{exact:true}).scrollIntoViewIfNeeded(); await page.screenshot({path:`${out}/${width}-${detail.id}-overview.png`}); await page.keyboard.press('Escape'); await dialog.waitFor({state:'hidden'}); check(await button.evaluate(el=>el===document.activeElement), `${width} ${detail.name}关闭归还焦点`); } // Return to H3 and back, ensuring definition lookup does not leak across records. for (const detail of [details[2],details[3],details[4],details[0],details[1]]) { await begin(detail.name); await loaded(); check(await dialog.locator('.card').filter({has:page.getByText('固定版本参数说明',{exact:true})}).locator('summary').filter({hasText:/节点 \d+ · /}).count()===detail.doc_json.fixed_version.fields.length, `${width}切换${detail.name}定义不串条`); await page.keyboard.press('Escape'); } } // Hold audio response, switch to another actual audio graph, then deliver the old response. 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=>{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.locator('.card').filter({has:page.getByText('固定版本参数说明',{exact:true})}).locator('summary').filter({hasText:/节点 \d+ · /}).count()===14, '迟到视频分离响应不覆盖图片排版14项'); await page.unroute(`**/api/workflows/${details[0].id}`); await page.keyboard.press('Escape'); check(errors.length===0,'浏览无脚本错误'); check(requests.every(r=>r.method==='GET' && new URL(r.url).hostname==='127.0.0.1'),'两媒体图浏览全本地GET,无生成/目标机请求'); fs.writeFileSync(`${out}/browser-results.json`, JSON.stringify({checks,requests,errors,viewports:[1440,390]},null,2)); } finally { await browser.close(); }