Files
gods-eye-view/src/app/qaProbe.test.mjs
T
German Khokhlov ec7dcc944e test(qa): an engine-neutral layer probe
- src/app/qaProbe.js → window.__godsEyeView.layers: list() (with
  `available`), unavailable(), available(id), enable/disable(id) (a user
  toggle through the layer manager), objects(id) → [{ id, label, position,
  screen }], screenOf(id, objectId), selected(id), following(), movers(),
  framesDrawn() - all through the engine and the catalog's availability, the
  same on Cesium and Navara. Installed after the tools.
- src/app/layers/qaSources.js: `?qaFeed=flights:synthetic:10000,
  vessels:fixture` (dev server only, allowQaRegistration) replaces those
  sources with seeded synthetic answers served through the live sources'
  own parsers (same snapshot shape; loaded with import() only then). The
  pure generators moved from src/tooling/w1Feeds.js to src/bench/w1Feeds.js
  (the browser graph may not reach src/tooling); the W1 recordings
  re-export them.
- scripts/qa-w1-layers.mjs: the parity checklist's frame, --layer
  --engine=cesium|navara with the fixture feeds, JSON per run and
  --compare (objects on screen per pose, 5 known objects within 2 px).
  Filled: 1 view, 8 idle, 9 errors/no leftover mover sets after 10
  on/off; 2-7 report TODO for the layer tasks.
- qa-perf, qa-labels, qa-overlay-baseline and qa-label-readability take
  --engine= and use the engine (camera, frames, render requests, tiles) and
  the probe (layers, following, movers) instead of the viewer; checks whose
  layers an engine lacks are SKIPPED with the reason (Navara today), as are
  qa-perf's animated-style checks there (Cesium post stages).

Verdicts, Cesium, before → after: qa-perf 24/24 → 24/24, qa-labels 14/14 →
14/14, qa-overlay-baseline (datacenters, firms, detection-50) 2 measured +
1 skipped → the same. Navara: qa-perf 14 passed, 3 skipped; qa-labels 3/3,
1 skipped; qa-overlay-baseline 3 skipped; qa-w1-layers flights: Cesium 5/5
(10 000 synthetic aircraft), Navara skipped (no flights renderer yet).
2026-10-16 22:52:18 +04:00

104 lines
3.4 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import * as geo from '../geo/index.js';
import { createFakeEngine } from '../globe/testing/fakeEngine.js';
import { createQaProbe } from './qaProbe.js';
import {
createLayerAvailability,
createRendererRegistry,
} from './layers/renderers.js';
function fakeManager(modules) {
const enabled = new Set();
return {
layers: new Map(modules.map((module) => [module.id, { module }])),
getAll: () =>
modules.map(({ id, name }) => ({ id, name, enabled: enabled.has(id) })),
isEnabled: (id) => enabled.has(id),
async setEnabled(id, value) {
if (value) enabled.add(id);
else enabled.delete(id);
return true;
},
};
}
test('the probe lists, toggles and reads layers through the engine', async () => {
const engine = createFakeEngine({ kind: 'navara' });
const position = geo.cartesian3.fromDegrees(-73.78, 40.64, 1000);
const flights = {
id: 'flights',
name: 'Live Flights',
getAllPositions: () => [{ id: 'ae01ce', label: 'UAL1', position }],
getTrackedInfo: () => ({ icao24: 'ae01ce' }),
};
const manager = fakeManager([flights]);
const registry = createRendererRegistry();
registry.register('navara', { flights: () => ({}) });
const probe = createQaProbe({
engine,
dataManager: manager,
availability: createLayerAvailability('navara', { registry }),
});
assert.deepEqual(probe.list(), [
{ id: 'flights', name: 'Live Flights', enabled: false, available: true },
]);
assert.equal(probe.available('flights'), true);
assert.equal(probe.available('satellites'), false);
assert.deepEqual(
probe
.unavailable()
.map(({ id }) => id)
.includes('satellites'),
true,
);
assert.equal(await probe.enable('flights'), true);
assert.equal(manager.isEnabled('flights'), true);
engine.camera.setView({
destination: geo.cartesian3.fromDegrees(-73.78, 40.64, 50_000),
});
engine.fake.script('worldToWindow', () => ({ x: 640, y: 400 }));
const [object] = probe.objects('flights');
assert.equal(object.id, 'ae01ce');
assert.deepEqual(
[object.position.x, object.position.y, object.position.z],
[position.x, position.y, position.z],
);
assert.deepEqual(object.screen, { x: 640, y: 400 });
assert.deepEqual(probe.screenOf('flights', 'ae01ce'), { x: 640, y: 400 });
assert.equal(probe.screenOf('flights', 'nope'), null);
assert.deepEqual(probe.selected('flights'), { icao24: 'ae01ce' });
assert.deepEqual(probe.objects('unknown'), []);
// Follow, movers and frames come from the engine.
assert.equal(probe.following(), null);
engine.camera.follow({
position: () => position,
viewFrom: { x: 0, y: -1000, z: 300 },
label: {
id: 'flights:ae01ce',
model: { title: 'UAL1' },
position: () => position,
},
});
assert.deepEqual(probe.following(), {
label: 'flights:ae01ce',
native: null,
});
engine.movers.createSet({
id: 'fleet',
kind: 'point',
capacity: 4,
point: { sizePx: 4 },
});
assert.deepEqual(probe.movers(), [
{ id: 'fleet', kind: 'point', count: 0, capacity: 4 },
]);
const before = probe.framesDrawn();
engine.fake.frame();
engine.fake.frame();
assert.equal(probe.framesDrawn() - before, 2);
assert.equal(await probe.disable('flights'), true);
assert.equal(manager.isEnabled('flights'), false);
probe.destroy();
});