Files
gods-eye-view/src/mapStackController.test.mjs
T
German Khokhlov 7f478e3815 Remove always-true layer availability and leftover viewer paths
Every layer draws on both engines, so the per-engine availability
machinery always answered yes. The renderer manifest is now the id to
display map plus the wind flow backend; the catalog filter, the voice and
QA-probe refusals and the engine-kind checks go with it. The Navara
notice lists the same layers in the same words.

Paths that read the Cesium viewer behind an engine that is always there
are gone: the Recent Imagery viewer fallbacks, the shell's imagery-host
service (one shared host module remains), the engineless map controller,
viewer gates in voice actions, world packets and camera verbs, the
orientation controls' tracked-entity fallback, and the Bhote Koshi and
FIRMS Cesium-shaped paths. setCameraInputs, which nothing called, leaves
the contract; suspensions remain.

Smaller duplicates go too: one tracker-release helper for navigation and
location, the no-op frame latch, missing-engine guards, one name for the
injected display, flat bikeshare and installations displays, one overlay
host and binder, one name per world-overlay method, and stub-viewer
guards in the Cesium engine. Layers that still read the viewer keep the
shared init(viewer, context) entry.

Behaviour is unchanged on both engines. Viewer lines fall from 849 to
750 and engine-name literals from 32 to 27.
2026-11-08 17:06:01 +04:00

50 lines
2.0 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { MapStackController } from './mapStackController.js';
import { createFakeEngine } from './globe/testing/fakeEngine.js';
test('the map stack controller applies its stacks through a given globe engine', async () => {
const engine = createFakeEngine();
const tileset = { show: true };
const controller = new MapStackController({
engine,
googleTileset: tileset,
});
await controller.setStack('photoreal');
assert.equal(
engine.fake.callsOf('maps.setPhotorealTiles')[0].args[0].tileset,
tileset,
);
await controller.setStack('osm');
const [imagery] = engine.fake.callsOf('maps.setBaseImagery')[0].args;
assert.equal(imagery.descriptor.id, 'osm');
assert.ok(imagery.provider, 'a ready provider the controller built');
assert.equal(engine.fake.callsOf('maps.setPhotorealTiles')[1].args[0], null);
controller.destroy();
});
test('on a Navara engine the map stack controller opens on Google 3D from the browser key alone', async (t) => {
const previous = globalThis.window;
globalThis.window = { __GOOGLE_MAPS_API_KEY__: 'google-test' };
t.after(() => {
if (previous === undefined) delete globalThis.window;
else globalThis.window = previous;
});
const engine = createFakeEngine({ kind: 'navara' });
const controller = new MapStackController({ engine });
assert.equal(controller.getActiveId(), 'photoreal');
assert.equal(controller.isStackAvailable('bing-aerial'), false);
await controller.setStack('photoreal');
const [photoreal] = engine.fake.callsOf('maps.setPhotorealTiles')[0].args;
assert.equal(photoreal.kind, 'photoreal');
assert.equal('tileset' in photoreal, false);
controller.destroy();
window.__GOOGLE_MAPS_API_KEY__ = '';
const keyless = new MapStackController({
engine: createFakeEngine({ kind: 'navara' }),
});
assert.equal(keyless.getActiveId(), 'esri-imagery');
assert.equal(keyless.isStackAvailable('photoreal'), false);
keyless.destroy();
});