// Real local detail GET, all 49 ASR 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/asr-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 ['Qwen3-ASR-语音转文字', 'Qwen3-ASR-Subtitle语音转字幕', '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(',') === '19,30,18,5,8,8,14', '49新增保存定义与53旧定义独立'); 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 && ['needs_conversion','pending_check'].includes(detail.import_state) && !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','hints','previewMode','output_format','forced_aligner','max_chars'].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==='Qwen3-ASR-语音转文字') { for (const line of ['32.audio','34.audio','32槽0 TEXT → 24.source','34槽0 TEXT → 35.source','32.hints为空','34.hints非空','MarkdownNote33']) check(text.includes(line), `${width}两独立识别支路 ${line}`); await dialog.getByText('源文件注释',{exact:true}).scrollIntoViewIfNeeded(); const note=dialog.getByText('节点 33',{exact:true}); await note.click(); const noteText=await note.locator('..').locator('pre').textContent(); check(noteText===JSON.stringify(detail.doc_json.source_notes[0].content,null,2), `${width}源MarkdownNote逐字保留`); } else { for (const line of ['9槽0 TEXT → 4.source','9槽1 SUBTITLES → 2.source','9槽2 LANUGAGE → 3.source','9槽3 OUTPUT_PATH → 1.source','7槽0 STRING → 9.hints','不写字幕文件','normalize_text=true','均无-hf','四出口槽在API与UI均']) check(text.includes(line), `${width}字幕与配套边界 ${line}`); check(!('normalize_text' in Object.fromEntries(fixed.fields.map(f=>[f.field,f.value]))), `${width}不伪造normalize_text源保存位置`); } 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.slice(2),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()===30, '迟到ASR响应不覆盖字幕30项'); 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'),'两ASR图浏览全本地GET,无生成/目标机请求'); fs.writeFileSync(`${out}/browser-results.json`, JSON.stringify({checks,requests,errors,viewports:[1440,390]},null,2)); } finally { await browser.close(); }