mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 15:52:21 +00:00
Measure engine coupling, QA harness use and contract coverage
Counters that may only fall, each with a committed baseline and a test that fails on growth: - report-engine-coupling.mjs gains layer modules that take the viewer in attachRenderer (33), layer folders with their own "view being restored" flag (9), engine.surface calls outside src/globe (41) and layer ids named in the engine switch (3). - report-qa-harness.mjs counts QA scripts that launch Chrome themselves (98), wait with fixed sleeps (117), take the hidden loading screen as readiness (9), read Cesium-only objects (75) or define their own waitFor helpers (19). - withCallLog records every contract member the contract suite calls on the fake engine; contractCoverage.test.mjs fails when a member outside contract-uncalled-baseline.json goes uncalled, and when a listed one is called now, so the list of 12 only shrinks.
This commit is contained in:
1 parent
ba04ceaa32
commit
9c2a2d6951
11 files changed
+842
-3
No files matched your search
@@ -0,0 +1,100 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
QA_HARNESS_METRICS,
|
||||
harnessGrowth,
|
||||
measureQaHarness,
|
||||
readBaseline,
|
||||
readQaSources,
|
||||
} from './report-qa-harness.mjs';
|
||||
|
||||
test('QA harness duplication does not grow past the baseline', () => {
|
||||
assert.deepEqual(
|
||||
harnessGrowth(measureQaHarness(), readBaseline().metrics),
|
||||
[],
|
||||
'QA harness duplication grew; use scripts/qa-strict-harness.mjs helpers for browser launch, engine readiness and camera waits instead.',
|
||||
);
|
||||
});
|
||||
|
||||
test('the baseline names every metric', () => {
|
||||
assert.deepEqual(
|
||||
Object.keys(readBaseline().metrics).sort(),
|
||||
QA_HARNESS_METRICS.map(({ id }) => id).sort(),
|
||||
);
|
||||
});
|
||||
|
||||
test('a metric that grows is reported, one that falls is not', () => {
|
||||
const baseline = Object.fromEntries(
|
||||
QA_HARNESS_METRICS.map(({ id }) => [id, 10]),
|
||||
);
|
||||
assert.deepEqual(
|
||||
harnessGrowth({ ...baseline, ownLaunch: 11, fixedSleeps: 3 }, baseline).map(
|
||||
({ id }) => id,
|
||||
),
|
||||
['ownLaunch'],
|
||||
);
|
||||
assert.equal(harnessGrowth(baseline, {}).length, QA_HARNESS_METRICS.length);
|
||||
});
|
||||
|
||||
test('QA sources include the harness and exclude tests and other reports', () => {
|
||||
const names = readQaSources().map(({ file }) => file);
|
||||
assert.ok(names.includes('scripts/qa-strict-harness.mjs'));
|
||||
assert.ok(!names.some((name) => name.endsWith('.test.mjs')));
|
||||
assert.ok(!names.includes('scripts/report-qa-harness.mjs'));
|
||||
});
|
||||
|
||||
test('metrics count scripts once and distinguish helpers from their callers', () => {
|
||||
const measure = (id, ...sources) =>
|
||||
QA_HARNESS_METRICS.find((metric) => metric.id === id).measure(
|
||||
sources.map((text) => ({ text })),
|
||||
);
|
||||
assert.equal(
|
||||
measure(
|
||||
'ownLaunch',
|
||||
'puppeteer.launch({}); puppeteer.launch({});',
|
||||
'launchBrowser();',
|
||||
),
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
measure(
|
||||
'fixedSleeps',
|
||||
'const sleep = (ms) => new Promise((r) => setTimeout(r, ms));',
|
||||
'await new Promise((resolve) => { setTimeout(resolve, 1000); });',
|
||||
'await new Promise((resolve) => setTimeout(resolve));',
|
||||
'new Promise((resolve) => requestAnimationFrame(resolve));',
|
||||
'setTimeout(() => reject(new Error()), 1000);',
|
||||
),
|
||||
3,
|
||||
);
|
||||
assert.equal(
|
||||
measure(
|
||||
'loadingScreenReadiness',
|
||||
"page.waitForSelector('#loading-screen');",
|
||||
"page.waitForSelector('#loading-screen'); await waitForEngine(page);",
|
||||
"document.querySelector('#loading-screen');",
|
||||
),
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
measure(
|
||||
'cesiumOnlyReads',
|
||||
'window.__godsEyeView?.viewer; window.__godsEyeView.tileset;',
|
||||
'const { scene } = window.__godsEyeView;',
|
||||
'const app = window.__godsEyeView; app.viewer;',
|
||||
'window.__godsEyeView.sceneDirector;',
|
||||
'window.__godsEyeView.engine;',
|
||||
),
|
||||
3,
|
||||
);
|
||||
assert.equal(
|
||||
measure(
|
||||
'ownWaitHelpers',
|
||||
'async function waitForReady() {}',
|
||||
'const waitForReady = async (page) => page.ready();',
|
||||
'await waitForEngine(page);',
|
||||
"import { waitForEngine } from './qa-strict-harness.mjs';",
|
||||
),
|
||||
2,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user