Files
gods-eye-view/scripts/qa-gbfs-names.test.mjs
T
German Khokhlov 373edf2989 Move QA scripts to the shared harness, batch 2 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.
2026-11-10 16:43:58 +04:00

52 lines
1.4 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const source = readFileSync(
new URL('./qa-gbfs-names.mjs', import.meta.url),
'utf8',
);
const openSource = source.slice(
source.indexOf('async function open('),
source.indexOf('async function nextFrame('),
);
function fixture({ extended, dev }) {
const page = {
bringToFront: async () => {},
on() {},
setViewport: async () => {},
evaluateOnNewDocument: async () => {},
goto: async () => {},
evaluate: async () => dev,
waitForFunction: async () => {},
};
const dependencies = {
browser: { newPage: async () => page },
extended,
watchBrowserPage() {},
report: {},
appUrl: 'http://localhost:4000',
information: {},
status: {},
fromDegrees: () => ({}),
whenSettled: async () => {},
};
return new Function(
...Object.keys(dependencies),
`${openSource}\nreturn open;`,
)(...Object.values(dependencies));
}
test('preview rejects the optional dev-only raster checks before importing source modules', async () => {
await assert.rejects(
fixture({ extended: true, dev: false })(),
/--w2 requires a Vite dev server/,
);
});
test('normal preview checks and extended dev checks remain available', async () => {
await fixture({ extended: false, dev: false })();
await fixture({ extended: true, dev: true })();
});