Files
gods-eye-view/src/app/layers/qaSources.test.mjs
T
German Khokhlov 0ef29781e5 Fix the review findings across the engines, layers, data and QA
Navara now matches Cesium where the review found it diverging: a flight
holds the camera inputs, camera.changed counts turns as Cesium does,
render requests made during a frame survive it, follow pinches zoom,
ground widths follow the pixel ratio and Cyber sonar reaches glyph caches
and models. On Cesium, a staged imagery swap keeps loading tiles, setView
replaces a running flight, and a cleared weather detail goes away.

The contract gains MoverSet.failed, maps.terrainRevision,
render.maxTextureSize and surface.sampleTerrainMostDetailed on every
engine, so layers retry failed models, key road heights by terrain,
size weather textures to the GPU and place Bhote Koshi cards on detailed
terrain.

Engine switches keep the live view, follows, focus, layer options and
cards: a pick hands over the exact pose, applies no address options and
pans no carried-over card; a history visit still applies its entry.

Layers put GhostMaps pins, cable landings, OSM Places and directions on
the measured surface without per-frame sampling, draw the Cockpit contact
dot, hide disabled CCTV on attach, and keep ALPR running outside secure
contexts. KML imports draw raised polygon fills, rotated and coloured
ground overlays and north-referenced icon headings, and report files
with nothing to draw.

QA scripts read the contract instead of Cesium internals (test:track is
109/109 again), wait for the camera to rest before clicking, and give
cold switches and parked engines realistic time. Docs follow the code.
2026-11-09 21:34:42 +04:00

152 lines
5.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test';
import assert from 'node:assert/strict';
import { createQaSources, parseQaFeed } from './qaSources.js';
test('qaFeed names fixture sources per layer', () => {
assert.deepEqual(
parseQaFeed('?qaFeed=flights:synthetic:10000,vessels:fixture'),
[
{ layer: 'flights', kind: 'synthetic', count: 10000 },
{ layer: 'vessels', kind: 'fixture', count: null },
],
);
assert.deepEqual(parseQaFeed('?engine=navara'), []);
assert.throws(() => parseQaFeed('?qaFeed=flights:live'), /qaFeed/);
assert.throws(() => parseQaFeed('?qaFeed=weather:fixture'), /qaFeed/);
assert.throws(() => parseQaFeed('?qaFeed=flights:synthetic:-3'), /qaFeed/);
});
test('fixture sources answer with the live sources’ snapshot shape', async () => {
const now = Date.UTC(2026, 9, 16, 12);
const sources = createQaSources(
parseQaFeed('?qaFeed=flights:synthetic:500,vessels:fixture'),
{ now: () => now },
);
const flights = await sources.flights.getSnapshot({});
assert.equal(flights.records.length, 500);
assert.ok(
flights.records.every((record) => Number.isFinite(record.latitude)),
);
// Seeded: the same aircraft every time.
const again = await sources.flights.getSnapshot({});
assert.deepEqual(
again.records.map(({ id }) => id),
flights.records.map(({ id }) => id),
);
const vessels = await sources.vessels.getSnapshot({ maxRows: 12000 });
assert.equal(vessels.records.length, 12000);
const near = await sources.vessels.getSnapshot({
maxRows: 12000,
area: { lat: 40.65724, lon: -73.78, radiusKm: 10 },
});
assert.ok(near.records.length > 10 && near.records.length < 12000);
assert.deepEqual(createQaSources([]), {});
});
test('military:synthetic answers with the military source’s shape, some shared with flights', async () => {
const now = Date.UTC(2026, 9, 16, 12);
const sources = createQaSources(
parseQaFeed('?qaFeed=military:synthetic:300,flights:synthetic:500'),
{ now: () => now },
);
const military = await sources.military.getSnapshot({});
assert.equal(military.records.length, 300);
assert.ok(military.records.some((record) => record.onGround));
assert.ok(military.records.every((record) => record.typeCode));
const identities = await sources.military.getIdentities({});
assert.ok(identities.records?.length ?? identities.length);
const civil = new Set(
(await sources.flights.getSnapshot({})).records.map(({ id }) => id),
);
const shared = military.records.filter(({ id }) => civil.has(id));
assert.equal(shared.length, 25);
assert.equal(sources.military.getTrack, undefined);
});
test('local-adsb:fixture answers as the local receivers do (1090 MHz and UAT)', async () => {
const now = Date.UTC(2026, 9, 16, 12);
assert.deepEqual(parseQaFeed('?qaFeed=local-adsb:fixture'), [
{ layer: 'local-adsb', kind: 'fixture', count: null },
]);
const { localAdsbFeeds } = createQaSources(
parseQaFeed('?qaFeed=local-adsb:fixture'),
{ now: () => now },
);
const loaded = new Promise((resolve) =>
localAdsbFeeds.subscribe((state) => {
if (state.records?.length) resolve();
}),
);
localAdsbFeeds.start();
await loaded;
const state = localAdsbFeeds.getState();
localAdsbFeeds.stop();
assert.equal(state.records.length, 40);
assert.ok(state.records.some((record) => record.band === '978'));
assert.ok(state.records.some((record) => record.band === '1090'));
});
test('flight fixture enrichment returns a not-found reply without regenerating the fleet', async () => {
let clockReads = 0;
const { flights } = createQaSources(
parseQaFeed('?qaFeed=flights:synthetic:10000'),
{
now: () => {
clockReads++;
return Date.UTC(2026, 9, 16, 12);
},
},
);
for (const kind of ['type', 'route']) {
const reply = await flights.getEnrichment({ kind, id: 'a00001' });
assert.equal(reply.found, false);
assert.deepEqual(Object.keys(reply), ['found']);
}
assert.equal(clockReads, 0);
});
test('flight fixture track reads do not regenerate a snapshot', async () => {
let clockReads = 0;
const { flights } = createQaSources(
parseQaFeed('?qaFeed=flights:synthetic:10000'),
{
now: () => {
clockReads++;
return Date.UTC(2026, 9, 16, 12);
},
},
);
assert.deepEqual(await flights.getTrack('a00001'), {
records: [],
complete: false,
});
assert.equal(clockReads, 0);
});
test('vessel fixture answers a relative track URL and retains its full snapshot', async () => {
const { vessels } = createQaSources(parseQaFeed('?qaFeed=vessels:fixture'), {
now: () => Date.UTC(2026, 9, 16, 12),
});
assert.deepEqual(await vessels.getTrack('990000001'), {
records: [],
complete: false,
});
assert.equal((await vessels.getSnapshot({})).records.length, 12000);
});
test('fixture counts cannot exceed the QA fleet budget', () => {
for (const count of [
'10001',
'1e9',
'9007199254740992',
'Infinity',
'0',
'1.5',
])
assert.throws(
() => parseQaFeed(`?qaFeed=flights:synthetic:${count}`),
TypeError,
);
assert.equal(parseQaFeed('?qaFeed=flights:synthetic:10000')[0].count, 10000);
});