Files
gods-eye-view/scripts/qa-nepal-locator-switch.mjs
T
German Khokhlov 7abf74518f Cut duplicated and dead code across the engines, the layers and the QA scripts
- src/geo drops the ported debug argument checks and the tests that
  bitExact already covers; package boundaries accept a directory entry,
  so src/geo/ is listed once per group.
- Cesium no longer carries movers and lines nobody draws with: they are
  optional engine capabilities. The fake engine and the Cesium camera use
  the shared cameraMath; unused contract tables, clock.ticked, the
  'finest' surface detail and Navara click statistics are gone.
- ALPR keeps one overlay core and one presentation model for both
  engines, bikeshare one station bookkeeping, the Navara ground effects
  one definition helper; image atlases, view centres, mover banks and
  colours are shared.
- The legacy switch route, the clock offset and rate controls and other
  unused exports are removed.
- The acceptance runs the Navara draw, geo import and scope checks;
  scenarios use the harness switch and page helpers; the main chunk
  check keeps the size budget only and runs once in CI.
2026-11-05 13:32:39 +04:00

132 lines
4.5 KiB
JavaScript

import { fromDegrees } from '../src/geo/cartesian3.js';
import sharp from 'sharp';
import assert from 'node:assert/strict';
import {
createStrict,
localPreview,
openPage,
waitForEngine,
} from './qa-strict-harness.mjs';
const base = localPreview(process.argv[2]);
base.search = '?engine=navara&welcome=0&look=cinematic';
base.hash =
'v=2&lat=28.3326&lon=85.4848&alt=18000&heading=0&pitch=-90&roll=0&map=sentinel2&l=';
const strict = createStrict({
origin: base.origin,
layers: ['bhote-koshi-locator'],
});
await strict.run({}, async (b) => {
const { page: p, errors } = await openPage(b, { shaderErrors: true });
await p.goto(base.href);
await waitForEngine(p, 'navara');
await p.evaluate(async () => {
const { tileset, dataManager } = window.__godsEyeView;
if (tileset || window.__GOOGLE_MAPS_API_KEY__)
throw Error('Keyless preview required');
window.qaLocator = dataManager.layers.get('bhote-koshi-locator').module;
window.qaLocator.setParams({ presentation: 'bhote-koshi-path-overview' });
await dataManager.setEnabled('bhote-koshi-locator', true, {
origin: 'user',
});
});
for (const kind of ['navara', 'cesium', 'navara']) {
if ((await p.evaluate(() => window.__godsEyeView.engine.kind)) !== kind) {
await strict.switchTo(p, kind);
}
const { same, stats, params, at } = await p.evaluate(
(world) => {
const { engine, dataManager } = window.__godsEyeView,
mod = dataManager.layers.get('bhote-koshi-locator').module;
const pos = engine.projector.worldToWindow(world, {}),
box = engine.host.canvas.getBoundingClientRect();
return {
same: mod === window.qaLocator,
stats: mod.getStats(),
params: mod.getParams(),
at: { x: pos.x + box.left, y: pos.y + box.top },
};
},
fromDegrees(85.47741, 28.33299, 1600),
);
assert.equal(same, true);
assert.equal(stats.count, 1);
assert.equal(params.presentation, 'bhote-koshi-path-overview');
// Look for the cyan river in a scene crop away from the UI rails.
await new Promise((r) => setTimeout(r, 1000));
const crop = async () =>
sharp(await p.screenshot())
.extract({ left: 400, top: 320, width: 230, height: 180 })
.removeAlpha()
.raw()
.toBuffer();
const rendered = await crop();
await p.evaluate(() =>
window.qaLocator.setParams({ presentation: 'nepal-context' }),
);
await new Promise((resolve) => setTimeout(resolve, 500));
const baseline = await crop();
let added = 0;
for (let i = 0; i < rendered.length; i += 3) {
const contrast = rendered[i + 1] - rendered[i],
previous = baseline[i + 1] - baseline[i];
if (
rendered[i + 1] > 140 &&
rendered[i + 2] > 140 &&
contrast > 35 &&
contrast - previous > 18
)
added++;
}
console.log(
kind,
stats.coverage,
'cyan pixels added by the path',
added,
at,
);
await strict.check(
p,
'bhote-koshi-locator',
'same model; the flood path adds more than 50 cyan pixels to the same scene without it',
added > 50,
{ added },
);
await p.evaluate(() =>
window.qaLocator.setParams({ presentation: 'bhote-koshi-path-overview' }),
);
}
await p.evaluate(() => {
window.qaLocator.setParams({ presentation: 'bhote-koshi-incident-places' });
window.qaLocator.setParams({ presentation: 'bhote-koshi-city-context' });
window.qaLocator.setParams({
presentation: 'bhote-koshi-trigger-record',
preview: true,
});
});
await new Promise((resolve) => setTimeout(resolve, 2500));
// The last of three quick presentation changes is the one that stays.
const last = await p.evaluate(() => ({
params: window.qaLocator.getParams(),
stats: window.qaLocator.getStats(),
}));
await strict.check(
p,
'bhote-koshi-locator',
'the last of three quick presentation changes is the one applied',
last.params.presentation === 'bhote-koshi-trigger-record' &&
last.stats.count === 1 &&
!last.stats.error,
{ presentation: last.params.presentation, count: last.stats.count },
);
await p.evaluate(() =>
window.__godsEyeView.dataManager.setEnabled('bhote-koshi-locator', false, {
origin: 'user',
}),
);
assert.deepEqual(errors, []);
console.log(
'PASS Nepal locator flood path and presentation retained, trigger and places update; both engines',
);
});