Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

fix(qa): run the macOS-only gates on Windows and Linux (#1061)

quanticsoul4772e50bc45674c4
diff --git a/scripts/format-scope.json b/scripts/format-scope.json
index 1a880b284..296880561 100644
--- a/scripts/format-scope.json
+++ b/scripts/format-scope.json
@@ -934,6 +934,8 @@
"scripts/qa-street-level.mjs",
"src/tooling/streetLevelQa.test.mjs",
"scripts/qa-browserEvidence.mjs",
+ "scripts/qa-chrome.mjs",
+ "src/qaChrome.test.mjs",
"scripts/fixtures/street-level/mapillaryGraph.mjs",
"scripts/fixtures/street-level/kartaView.mjs",
"src/layers/streetLevel/filter.test.mjs",
diff --git a/scripts/precompute-cctv-heights.mjs b/scripts/precompute-cctv-heights.mjs
index 24813b5e7..648768341 100644
--- a/scripts/precompute-cctv-heights.mjs
+++ b/scripts/precompute-cctv-heights.mjs
@@ -1,6 +1,7 @@
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
+import { chromeExecutablePath } from './qa-chrome.mjs';
import {
planeSupportPoints,
poseHash,
@@ -389,8 +390,7 @@ async function main() {
const { default: puppeteer } = await import('puppeteer');
browser = await puppeteer.launch({
headless: false,
- executablePath:
- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ executablePath: chromeExecutablePath(),
protocolTimeout: 600000,
args: [
'--no-sandbox',
diff --git a/scripts/qa-cables-shot.mjs b/scripts/qa-cables-shot.mjs
index 12af9beb8..3e3008e03 100644
--- a/scripts/qa-cables-shot.mjs
+++ b/scripts/qa-cables-shot.mjs
@@ -6,6 +6,7 @@
*/
import puppeteer from 'puppeteer';
import { mkdirSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
const argv = process.argv;
const url = argv.includes('--url') ? argv[argv.indexOf('--url') + 1] : 'http://localhost:4214';
@@ -65,7 +66,9 @@ try {
requestAnimationFrame(tick);
}));
await new Promise((r) => setTimeout(r, 1_000));
- const path = new URL(`../qa-shots/cables-${tag}-${view.name}.png`, import.meta.url).pathname;
+ const path = fileURLToPath(
+ new URL(`../qa-shots/cables-${tag}-${view.name}.png`, import.meta.url),
+ );
await page.screenshot({ path });
console.log(`saved ${path}`);
}
diff --git a/scripts/qa-chrome.mjs b/scripts/qa-chrome.mjs
new file mode 100644
index 000000000..05c4dbff0
--- /dev/null
+++ b/scripts/qa-chrome.mjs
@@ -0,0 +1,20 @@
+/**
+ * The browser for gates that drive an installed Chrome. These gates were
+ * written against macOS Google Chrome, which Windows and Linux do not have.
+ */
+import { existsSync } from 'node:fs';
+
+export const MACOS_CHROME =
+ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
+
+/**
+ * PUPPETEER_EXECUTABLE_PATH when set, then macOS Google Chrome when it is
+ * installed. Otherwise undefined, so Puppeteer launches the browser it manages.
+ */
+export function chromeExecutablePath({
+ env = process.env,
+ exists = existsSync,
+} = {}) {
+ if (env.PUPPETEER_EXECUTABLE_PATH) return env.PUPPETEER_EXECUTABLE_PATH;
+ return exists(MACOS_CHROME) ? MACOS_CHROME : undefined;
+}
diff --git a/scripts/qa-directions.mjs b/scripts/qa-directions.mjs
index 9501690f9..ca271026f 100644
--- a/scripts/qa-directions.mjs
+++ b/scripts/qa-directions.mjs
@@ -10,6 +10,7 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import puppeteer from 'puppeteer';
+import { chromeExecutablePath } from './qa-chrome.mjs';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const args = process.argv.slice(2);
@@ -35,8 +36,7 @@ const check = (name, passed, detail = '') => {
const browser = await puppeteer.launch({
headless: false,
- executablePath:
- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ executablePath: chromeExecutablePath(),
args: [
'--no-sandbox',
'--disable-background-timer-throttling',
diff --git a/scripts/qa-draw-tool.mjs b/scripts/qa-draw-tool.mjs
index a5a16af1d..adb29f3af 100644
--- a/scripts/qa-draw-tool.mjs
+++ b/scripts/qa-draw-tool.mjs
@@ -3,6 +3,7 @@
import fs from 'node:fs';
import path from 'node:path';
import puppeteer from 'puppeteer';
+import { chromeExecutablePath } from './qa-chrome.mjs';
const BASE_URL = process.env.QA_BASE_URL || 'http://localhost:4173';
const SHOT_DIR = process.env.QA_SHOT_DIR || 'qa-shots/draw';
@@ -22,8 +23,7 @@ const browser = await puppeteer.launch({
headless: !HEADFUL,
...(HEADFUL
? {
- executablePath:
- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ executablePath: chromeExecutablePath(),
}
: {}),
args: [
diff --git a/scripts/qa-recent-imagery.mjs b/scripts/qa-recent-imagery.mjs
index 5d42279dc..89d60d96f 100644
--- a/scripts/qa-recent-imagery.mjs
+++ b/scripts/qa-recent-imagery.mjs
@@ -20,6 +20,7 @@
import fs from 'node:fs';
import path from 'node:path';
import puppeteer from 'puppeteer';
+import { chromeExecutablePath } from './qa-chrome.mjs';
const BASE_URL = process.env.QA_BASE_URL || 'http://localhost:4173';
const SHOT_DIR = process.env.QA_SHOT_DIR || 'qa-shots/recent-imagery';
@@ -54,8 +55,7 @@ const browser = await puppeteer.launch({
headless: !HEADFUL,
...(HEADFUL
? {
- executablePath:
- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ executablePath: chromeExecutablePath(),
}
: {}),
args: [
diff --git a/scripts/qa-transit-heading.mjs b/scripts/qa-transit-heading.mjs
index a16bab9bc..c229be96c 100644
--- a/scripts/qa-transit-heading.mjs
+++ b/scripts/qa-transit-heading.mjs
@@ -1,11 +1,11 @@
import puppeteer from 'puppeteer';
+import { chromeExecutablePath } from './qa-chrome.mjs';
/** Prove parked and moving headings in the real scene, without live feeds. */
export async function runTransitHeadingRegression(base, check) {
const browser = await puppeteer.launch({
headless: true,
- executablePath:
- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ executablePath: chromeExecutablePath(),
args: ['--no-sandbox', '--disable-background-timer-throttling'],
});
try {
diff --git a/scripts/qa-transit-recovery.mjs b/scripts/qa-transit-recovery.mjs
index e5fadda49..5f6404b41 100644
--- a/scripts/qa-transit-recovery.mjs
+++ b/scripts/qa-transit-recovery.mjs
@@ -1,5 +1,6 @@
/** Camera-jump regression against an existing server; never starts a server. */
import puppeteer from 'puppeteer';
+import { chromeExecutablePath } from './qa-chrome.mjs';
import { mkdir, writeFile } from 'node:fs/promises';
import { reduceTrailPixels } from '../src/layers/transit/qaMetrics.js';
@@ -8,8 +9,7 @@ const shots = process.env.QA_SHOTS || 'qa-shots/transit-recovery';
await mkdir(shots, { recursive: true });
const browser = await puppeteer.launch({
headless: false,
- executablePath:
- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ executablePath: chromeExecutablePath(),
args: [
'--disable-background-timer-throttling',
'--disable-renderer-backgrounding',
diff --git a/scripts/qa-transit.mjs b/scripts/qa-transit.mjs
index aac1d8f60..7d83d77a4 100644
--- a/scripts/qa-transit.mjs
+++ b/scripts/qa-transit.mjs
@@ -36,6 +36,7 @@ import {
*/
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import puppeteer from 'puppeteer';
+import { chromeExecutablePath } from './qa-chrome.mjs';
import { createTransitHistory } from '../server/providers/transitHistory.js';
import { DETECTION_THEME_MAP } from '../src/overlays/worldOverlayTokens.js';
import { transitModeTier } from '../src/data/transitPresetStyle.js';
@@ -262,8 +263,7 @@ await mkdir(SHOTS, { recursive: true });
const browser = await puppeteer.launch({
headless: false,
protocolTimeout: 150000,
- executablePath:
- '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ executablePath: chromeExecutablePath(),
args: [
'--no-sandbox',
'--disable-background-timer-throttling',
diff --git a/src/qaChrome.test.mjs b/src/qaChrome.test.mjs
new file mode 100644
index 000000000..4414f3c93
--- /dev/null
+++ b/src/qaChrome.test.mjs
@@ -0,0 +1,27 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { MACOS_CHROME, chromeExecutablePath } from '../scripts/qa-chrome.mjs';
+
+test('gates keep macOS Chrome where it is installed', () => {
+ assert.equal(
+ chromeExecutablePath({ env: {}, exists: (p) => p === MACOS_CHROME }),
+ MACOS_CHROME,
+ );
+});
+
+test('gates fall back to Puppeteer’s browser without macOS Chrome', () => {
+ assert.equal(
+ chromeExecutablePath({ env: {}, exists: () => false }),
+ undefined,
+ );
+});
+
+test('an explicit executable path wins', () => {
+ assert.equal(
+ chromeExecutablePath({
+ env: { PUPPETEER_EXECUTABLE_PATH: 'C:\\Chrome\\chrome.exe' },
+ exists: () => true,
+ }),
+ 'C:\\Chrome\\chrome.exe',
+ );
+});