fix: record browser startup failures (#4)

This commit is contained in:
dekim2 committed 2026-10-27 17:55:28 +09:00
1 parent 793cbe5aae
commit bc9bb05900
1 file changed
+11 -6
+11 -6
View File
@@ -4,15 +4,17 @@ const fs=require('node:fs/promises');
const path=require('node:path');
const assert=require('node:assert/strict');
const base=process.env.VIEWER_URL||'http://127.0.0.1:8080';
const out=path.resolve(__dirname,'../test-results');
const out=process.env.VIEWER_RESULTS_DIR?path.resolve(process.env.VIEWER_RESULTS_DIR):path.resolve(__dirname,'../test-results');
(async()=>{
await fs.mkdir(out,{recursive:true});
const browser=await chromium.launch({headless:true,...(process.env.PLAYWRIGHT_CHANNEL?{channel:process.env.PLAYWRIGHT_CHANNEL}:{})});
const page=await browser.newPage({viewport:{width:1440,height:1000}});
const errors=[];page.on('pageerror',e=>errors.push(String(e)));
let browser,page;
const errors=[];
let report={status:'failed',url:base};
try{
browser=await chromium.launch({headless:true,...(process.env.PLAYWRIGHT_CHANNEL?{channel:process.env.PLAYWRIGHT_CHANNEL}:{})});
page=await browser.newPage({viewport:{width:1440,height:1000}});
page.on('pageerror',e=>errors.push(String(e)));
await page.goto(base,{waitUntil:'networkidle'});
await page.waitForFunction(()=>document.querySelector('#loading')?.hidden && document.querySelector('#scene'));
const data=await (await page.request.get(new URL('data/network.json',base).href)).json();
@@ -80,6 +82,9 @@ const out=path.resolve(__dirname,'../test-results');
checks:['all facility information panels','summary counts','real search/selection clicks','missing-facility explanations',
'unknown ID','scale reset','plan view','layer toggles','audit dialog','reset','no page errors'],
browser:browser.version(),limitations:['Information consistency; screenshot review is separate from dimensional geometry verification.']};
}catch(e){report.error=e.stack;await page.screenshot({path:path.join(out,'failure.png'),fullPage:true}).catch(()=>{});process.exitCode=1;}
finally{await fs.writeFile(path.join(out,'ui-validation.json'),JSON.stringify(report,null,2));console.log(JSON.stringify(report,null,2));await browser.close();}
}catch(e){report.error=e.stack;if(page)await page.screenshot({path:path.join(out,'failure.png'),fullPage:true}).catch(()=>{});process.exitCode=1;}
finally{
try{await fs.writeFile(path.join(out,'ui-validation.json'),JSON.stringify(report,null,2));console.log(JSON.stringify(report,null,2));}
finally{if(browser)await browser.close();}
}
})().catch(e=>{console.error(e);process.exitCode=1;});