mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 07:42:23 +00:00
scripts/report-engine-coupling.mjs counts the engine-specific code left outside src/globe/cesium and src/globe/navara: layer renderer lines per engine, Cesium imports, `viewer` mentions, engine-name checks, raw Navara reads, Navara ground passes, Cesium SDK loads and ScreenSpaceEventHandler users. engineCoupling.test.mjs fails npm test when a count grows past scripts/engine-coupling-baseline.json, so each step towards drawing through the globe contract can only lower them. scripts/qa-contract-suite.mjs runs src/globe/testing/contractSuite.mjs in headless Chrome on the Cesium and Navara of a keyless dev server, which until now only ran on the fake engine. The page imports the suite from the dev server, starts at a fixed view, waits for the camera to rest and lets the pointer through the panels. Cesium passes 57 of 57 checks, Navara 64 of 67; docs/CURRENT-STATE.md names the three that fail.
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
ENGINE_COUPLING_METRICS,
|
|
couplingGrowth,
|
|
measureEngineCoupling,
|
|
readBaseline,
|
|
} from './report-engine-coupling.mjs';
|
|
|
|
test('engine coupling does not grow past the baseline', () => {
|
|
const growth = couplingGrowth(
|
|
measureEngineCoupling(),
|
|
readBaseline().metrics,
|
|
);
|
|
assert.deepEqual(
|
|
growth,
|
|
[],
|
|
'Code outside the globe engines grew more engine-specific. Draw through ' +
|
|
'the globe contract instead; only a deliberate exception may raise ' +
|
|
'scripts/engine-coupling-baseline.json (--write-baseline).',
|
|
);
|
|
});
|
|
|
|
test('the baseline names every metric', () => {
|
|
const { metrics } = readBaseline();
|
|
assert.deepEqual(
|
|
Object.keys(metrics).sort(),
|
|
ENGINE_COUPLING_METRICS.map(({ id }) => id).sort(),
|
|
);
|
|
});
|
|
|
|
test('a metric that grows is reported, one that falls is not', () => {
|
|
const baseline = Object.fromEntries(
|
|
ENGINE_COUPLING_METRICS.map(({ id }) => [id, 10]),
|
|
);
|
|
const measured = { ...baseline, viewerLines: 11, navaraKindChecks: 3 };
|
|
assert.deepEqual(
|
|
couplingGrowth(measured, baseline).map(({ id }) => id),
|
|
['viewerLines'],
|
|
);
|
|
});
|