Give QA scripts one launch, readiness and geometry helper

scripts/qa/browser.mjs launches headless Chrome with QA_ANGLE and the
shared Chrome lookup; scripts/qa/ready.mjs adds frame, tile and transition
readiness and bounded polling; scripts/qa/geometry.mjs hands page
evaluations the engine-neutral geometry without dev-only source URLs.
CODE-BOUNDARIES gains the rule for new QA scripts.
This commit is contained in:
German Khokhlov committed 2026-11-10 16:43:58 +04:00
1 parent 37263a3e2b
commit 731eadc34a
7 files changed
+305

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import { build } from 'vite';
import { fileURLToPath } from 'node:url';
let bundle;
/** Supply geometry to page callbacks without requiring a dev server's /src routes. */
export async function evaluateWithGeo(page, callback, ...args) {
const evaluate = new Function(
'...args',
`${await geometryBundle()}\nreturn (${callback})(qaGeo, ...args);`,
);
return page.evaluate(evaluate, ...args);
}
/** A self-contained predicate for page-side polling as well as evaluation. */
export async function withGeo(callback, ...args) {
return `(() => { ${await geometryBundle()}\nreturn (${callback})(qaGeo, ...${JSON.stringify(args)}); })()`;
}
function geometryBundle() {
bundle ??= build({
configFile: false,
envFile: false,
logLevel: 'silent',
build: {
write: false,
minify: false,
lib: {
entry: fileURLToPath(
new URL('../../src/geo/index.js', import.meta.url),
),
name: 'qaGeo',
formats: ['iife'],
},
},
}).then((result) => result[0].output[0].code);
return bundle;
}