Move QA scripts to the shared harness, batch 3 of 4

Each script launches and closes Chrome through scripts/qa/browser.mjs,
waits on the application through scripts/qa/ready.mjs instead of the
loading screen and fixed pauses, and reads the contract instead of
Cesium where the check is not about Cesium itself.
This commit is contained in:
German Khokhlov committed 2026-11-10 16:43:58 +04:00
1 parent 373edf2989
commit 53b07ba91f
24 files changed
+628 -875

No files matched your search

+15 -50
View File
@@ -1,4 +1,6 @@
#!/usr/bin/env node
import { evaluateWithGeo } from './qa/geometry.mjs';
import { whenSettled, whenTilesLoaded, whenFramesDrawn } from './qa/ready.mjs';
/**
* qa-traffic-jamviz-ab.mjs — A/B screenshot capture for the jam-viz
* congestion prototypes (feat/traffic-jam-viz).
@@ -18,7 +20,7 @@
* Exits non-zero on harness failure (missing live mode, zero dots, etc.).
*/
import puppeteer from 'puppeteer';
import { launchBrowser, closeBrowser } from './qa/browser.mjs';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -53,50 +55,18 @@ const VIEWS = [
];
const MODES = ['none', 'density', 'heatline', 'both'];
const CHROME_EXECUTABLE_CANDIDATES = [
process.env.PUPPETEER_EXECUTABLE_PATH,
// Prefer puppeteer's version-pinned Chrome-for-Testing over the system
// Chrome: /Applications auto-updates underneath the harnesses, and its
// software-GL behavior shifts across majors (system Chrome 150 blew the
// tile-gated drain budget under SwiftShader on 2026-07-30 — six
// false-negative qa-cctv-v2 runs against a healthy build). A deterministic
// pinned browser beats the newest one for regression harnesses.
await puppeteer.executablePath().catch(() => null),
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
'/Applications/Chromium.app/Contents/MacOS/Chromium',
].filter(Boolean);
const findChromeExecutable = () =>
CHROME_EXECUTABLE_CANDIDATES.find((c) => { try { return fs.existsSync(c); } catch { return false; } }) || null;
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
/** Same pattern as qa-cctv-v2: wait for the 3D tileset to settle for crisp shots. */
function waitForTilesLoaded(page, timeoutMs) {
return page.waitForFunction(
() => {
const prims = window.__godsEyeView.viewer.scene.primitives;
for (let i = 0; i < prims.length; i++) {
const p = prims.get(i);
if (p && p.constructor && p.constructor.name === 'Cesium3DTileset') {
return p.tilesLoaded === true;
}
}
return true;
},
{ timeout: timeoutMs }
).then(() => true).catch(() => false);
}
/** Teleport to a view (cancelling any camera flight first). */
function setView(page, v) {
return page.evaluate((view) => {
const gev = window.__godsEyeView;
try { gev.viewer.camera.cancelFlight(); } catch { /* no flight */ }
const ell = gev.viewer.scene.globe.ellipsoid;
return evaluateWithGeo(page, async (qaGeo, view) => {
try { window.__godsEyeView.engine.camera.cancelFlight(); } catch { /* no flight */ }
const d2r = Math.PI / 180;
gev.viewer.camera.setView({
destination: ell.cartographicToCartesian({
window.__godsEyeView.engine.camera.setView({
destination: qaGeo.cartographic.toCartesian({
longitude: view.lon * d2r, latitude: view.lat * d2r, height: view.height,
}),
orientation: {
@@ -155,15 +125,9 @@ async function main() {
}
fs.mkdirSync(OUT_DIR, { recursive: true });
const browser = await puppeteer.launch({
headless: 'new',
...(findChromeExecutable() ? { executablePath: findChromeExecutable() } : {}),
args: [
'--no-sandbox', '--disable-setuid-sandbox', '--use-gl=angle', '--use-angle=swiftshader',
'--disable-dev-shm-usage', '--disable-web-security',
'--disable-background-timer-throttling', '--disable-renderer-backgrounding',
'--window-size=1600,900',
],
const browser = await launchBrowser({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-web-security', '--disable-background-timer-throttling', '--disable-renderer-backgrounding', '--window-size=1600,900'],
});
const manifest = [];
@@ -174,11 +138,12 @@ async function main() {
console.log('Loading app...');
await page.goto(APP_URL, { waitUntil: 'domcontentloaded', timeout: 60000 });
await page.waitForFunction(
() => window.__godsEyeView?.viewer && window.__godsEyeView?.dataManager,
() => window.__godsEyeView?.engine && window.__godsEyeView?.dataManager,
{ timeout: 60000 },
);
await whenSettled(page);
await page.evaluate(() => window.__godsEyeView.dataManager.setEnabled('traffic', true));
await sleep(1500);
await whenFramesDrawn(page);
let firstView = true;
for (const view of VIEWS) {
@@ -203,7 +168,7 @@ async function main() {
);
await setView(page, view);
const stats = await waitForFreshRender(page, since);
await waitForTilesLoaded(page, firstView ? 30000 : 15000);
await whenTilesLoaded(page, { timeoutMs: firstView ? 30000 : 15000 }).then(() => true).catch(() => false);
await sleep(1400); // flow-recolor race + heat-line pulse mid-bright
const final = await page.evaluate(() => {
@@ -249,7 +214,7 @@ async function main() {
exitCode = 3;
} finally {
fs.writeFileSync(path.join(OUT_DIR, 'manifest.json'), JSON.stringify(manifest, null, 2));
await browser.close();
await closeBrowser(browser);
}
console.log(`\nShots + manifest.json → ${OUT_DIR}`);
process.exit(exitCode);