Files
FreeCADWasmDev/tools/repaired-workers-browser-smoke.mjs

21 lines
1.3 KiB
JavaScript

import assert from 'node:assert/strict';
import {playwright} from './part-primitive-business-cases.mjs';
const browser=await playwright().chromium.launch({executablePath:'/usr/bin/google-chrome',headless:true,args:['--no-sandbox','--disable-dev-shm-usage']});
const results=[];
try {
for(const [module,command] of [['Help','help.inspectSourceInventory'],['Plot','plot.pythonApi'],['Show','show.inspectSourceInventory']]) {
const page=await browser.newPage();page.setDefaultTimeout(60000);
try {
await page.goto(`http://127.0.0.1:5180/workbench.html?module=${module}&command=${command}`);
await page.getByRole('button',{name:'执行选中命令',exact:true}).click();
await page.waitForFunction(()=>window.__freecadWorkbenchState?.response);
const reply=await page.evaluate(()=>window.__freecadWorkbenchState.response);
assert.equal(reply.kind,'result',JSON.stringify(reply));
results.push({module,command,status:'pass'});
} catch(error) {results.push({module,command,status:'fail',error:String(error)});}
finally {await page.close();}
}
} finally {await browser.close();}
const status=results.every(row=>row.status==='pass')?'pass':'fail';
console.log(JSON.stringify({status,results}));process.exitCode=status==='pass'?0:1;