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.
This commit is contained in:
German Khokhlov committed 2026-10-15 20:56:16 +04:00
1 parent 306e3e9467
commit 4ded3fbf15
21 files changed
+776 -49

No files matched your search

+169
View File
@@ -0,0 +1,169 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createApplicationScene } from './scene.js';
import { createFakeEngine } from '../globe/testing/fakeEngine.js';
import {
installRenderGovernor,
isRenderGovernorInstalled,
} from '../renderGovernor.js';
// The scene's Navara branch in Node: the globe loader is a seam, so the fake
// engine stands in for Navara and nothing Cesium is built.
function installDom() {
const saved = {
window: globalThis.window,
document: globalThis.document,
CustomEvent: globalThis.CustomEvent,
};
const container = { id: 'cesiumContainer' };
const appended = [];
globalThis.document = {
getElementById: (id) => (id === 'cesiumContainer' ? container : null),
querySelector: () => null,
querySelectorAll: () => [],
createElement: () => {
throw new Error('the Navara scene creates no Cesium credit container');
},
body: { appendChild: (node) => appended.push(node) },
};
const events = [];
globalThis.window = {
dispatchEvent: (event) => events.push(event),
addEventListener() {},
removeEventListener() {},
};
globalThis.CustomEvent ??= class {
constructor(type, { detail } = {}) {
this.type = type;
this.detail = detail;
}
};
const restore = () => {
for (const [name, value] of Object.entries(saved)) {
if (value === undefined) delete globalThis[name];
else globalThis[name] = value;
}
};
return { container, appended, events, restore };
}
const requestServices = {
terrain: { getHeights: async () => [] },
regional: { getBrief: async () => null },
weather: { getConditions: async () => null },
summary: { summarize: async () => null },
features: Object.fromEntries(
[
'getAdministrativeAreas',
'getAreaGeometry',
'getEnclosingAreas',
'getFocusFootprints',
'getFootprints',
'getMonuments',
'getNeighborhoodAreas',
'getStreetAreas',
'getStreetLines',
].map((name) => [name, async () => []]),
),
};
// Tests end with run.teardown (the scene's cleanups, then the DOM stand-ins).
async function startScene(options = {}) {
const dom = installDom();
const cleanups = [];
const loads = [];
const engine = createFakeEngine({ kind: 'navara' });
let globeDestroyed = 0;
const loaderStatus = { textContent: '' };
const scene = await createApplicationScene({
engineKind: 'navara',
requestServices,
googleApiKey: 'google-test',
credits: [
{ key: 'opensky', html: 'Flights credit' },
{ key: 'photon-geocoder', html: 'Search credit' },
{ key: 'openstreetmap', html: 'OSM credit' },
{ key: 'reearth-terrain', html: 'Terrain credit' },
],
loaderStatus,
signal: new AbortController().signal,
defer: (dispose) => cleanups.push(dispose),
loadNavaraGlobe: async () => async (globeOptions) => {
loads.push(globeOptions);
return {
engine,
destroy() {
globeDestroyed += 1;
engine.destroy();
},
};
},
...options,
});
const teardown = async () => {
while (cleanups.length) await cleanups.pop()();
dom.restore();
};
return {
scene,
engine,
loads,
dom,
loaderStatus,
teardown,
globeDestroyed: () => globeDestroyed,
};
}
test('the Navara scene builds the engine on the app container and no viewer', async (t) => {
const run = await startScene();
t.after(run.teardown);
assert.equal(run.scene.viewer, null);
assert.equal(run.scene.tileset, null);
assert.equal(run.scene.engine, run.engine);
assert.equal(run.scene.engine.kind, 'navara');
assert.equal(run.loads.length, 1);
assert.equal(run.loads[0].container, run.dom.container);
assert.ok(run.scene.operations.searchAndFlyTo);
assert.equal(globalThis.window.__GOOGLE_MAPS_API_KEY__, 'google-test');
// Data layers are off: only the credits of what the shell itself uses
// (place search, its OSM data, keyless terrain) go to the engine's credits.
assert.deepEqual(
run.engine.fake.credits.map(({ html }) => html),
['Search credit', 'OSM credit', 'Terrain credit'],
);
});
test('the Navara scene opens Google 3D through the engine', async (t) => {
const run = await startScene();
t.after(run.teardown);
const { mapStackController } = run.scene;
assert.equal(mapStackController.getActiveId(), 'photoreal');
assert.equal(mapStackController.isStackAvailable('bing-aerial'), false);
const [tiles] = run.engine.fake.callsOf('maps.setPhotorealTiles')[0].args;
assert.equal(tiles.kind, 'photoreal');
});
test('without a browser key the Navara scene opens on base imagery', async (t) => {
const run = await startScene({ googleApiKey: '' });
t.after(run.teardown);
assert.equal(run.scene.mapStackController.getActiveId(), 'esri-imagery');
assert.equal(
run.engine.fake.callsOf('maps.setBaseImagery')[0].args[0].kind,
'esri-imagery',
);
});
test('the Navara scene tears down the controller, then the globe', async (t) => {
const run = await startScene();
// The tools install the governor on the engine (src/app/tools.js); the
// scene removes it before the engine goes.
installRenderGovernor(run.engine);
const view = globalThis.window;
await run.teardown();
assert.equal(run.globeDestroyed(), 1);
assert.equal(run.engine.isDestroyed(), true);
assert.equal(isRenderGovernorInstalled(run.engine), false);
assert.equal(view.__GOOGLE_MAPS_API_KEY__, undefined);
});