mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
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.
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
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;
|
|
}
|