Files
gods-eye-view/src/app/engineChoice.test.mjs
T
German Khokhlov 4ded3fbf15 feat(app): run gev on Navara behind ?engine=navara
The page's engine is ?engine=cesium|navara, else localStorage gev.engine,
else Cesium (src/app/engineChoice.js). Cesium mode is unchanged.

In Navara mode (src/app/navaraMode.js, loaded with import() only then,
and loading the Navara globe the same way) the scene builds the Navara
globe on the app container with no viewer; map stacks go through
engine.maps (Google 3D from the browser key, else Esri imagery); only the
shell's own data credits are registered. The layer catalog is empty and
the controls get empty layer stand-ins. The shell does not create its
viewer-bound parts (cockpit view, celestial ring, detection, tracked
readout, post-process stages); the tools install the render governor on
the engine, skip the director, annotations, drawing, imagery box, scope
mask, voice and embedded views, skip the first-run welcome, and show
"Experimental Navara engine: layers, cockpit, director and voice are
unavailable". window.__godsEyeView.viewer is null.

Navara's attribution card is kept clear of the location tray. A few
shell paths became null-safe for the missing viewer, layers or stages
without changing Cesium behaviour.

scripts/qa-engine-shell.mjs checks both modes headless: boot, viewer,
console errors, map drawn, search and fly, north/tilt/zoom/reset, orbit,
HUD, share link restore and map stacks.
2026-10-15 20:56:16 +04:00

56 lines
1.7 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { ENGINE_STORAGE_KEY, resolveEngineKind } from './engineChoice.js';
const storage = (value) => ({
getItem: (key) => (key === ENGINE_STORAGE_KEY ? value : null),
});
test('Cesium is the default engine', () => {
assert.equal(resolveEngineKind(), 'cesium');
assert.equal(
resolveEngineKind({ search: '', storage: storage(null) }),
'cesium',
);
assert.equal(ENGINE_STORAGE_KEY, 'gev.engine');
});
test('?engine= chooses the engine and wins over storage', () => {
assert.equal(resolveEngineKind({ search: '?engine=navara' }), 'navara');
assert.equal(
resolveEngineKind({
search: '?x=1&engine=cesium',
storage: storage('navara'),
}),
'cesium',
);
assert.equal(resolveEngineKind({ search: '?engine=NAVARA' }), 'navara');
});
test('the stored choice applies without a query', () => {
assert.equal(
resolveEngineKind({ search: '', storage: storage('navara') }),
'navara',
);
assert.equal(
resolveEngineKind({ search: '?lat=1', storage: storage(' navara ') }),
'navara',
);
});
test('unknown values and unreadable storage fall back to Cesium', () => {
assert.equal(resolveEngineKind({ search: '?engine=unreal' }), 'cesium');
assert.equal(
resolveEngineKind({ search: '?engine=unreal', storage: storage('navara') }),
'navara',
'an unknown query value does not hide a valid stored choice',
);
assert.equal(resolveEngineKind({ storage: storage('unreal') }), 'cesium');
const throwing = {
getItem() {
throw new Error('SecurityError');
},
};
assert.equal(resolveEngineKind({ search: '', storage: throwing }), 'cesium');
});