refactor(street-level): remove the remaining duplicated code and fakes

A duplicate scan of every module the PR adds (repeated 4-line blocks,
normalised) after gekh's dedup round left these:

- glyphs.js: the cone, ring and position glyphs share cachedGlyph(), wedge(),
  ring() and dot(). Checked with a recording canvas: all 20 draw calls keep
  the same path and fill/stroke state, so the glyphs are pixel-identical.
- panelPositionControls.js: one placeAt() for the three places that pin a
  panel's top-left corner as a fixed window.
- tiles.js: one warn() for the three background-failure logs.
- Tests: src/testSupport/streetLevelFakes.mjs holds the provider snapshot
  (uiState + presentation tests), the stand-in provider (core + controls
  tests) and one real-ray pinhole camera (view + coverage tests, which had
  each written their own). The coverage line-of-sight test still fails when
  refresh() stops passing its focus.
- qa-street-level.mjs: one waitForCoverage() for the five copies of the
  "on, drawn, settled, not key-gated" wait.

No behaviour change: unit 5862 pass, fixture gate 16/16, panel gate 5/5.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Said TurkseverandClaude Opus 5.5 committed 2026-10-06 14:27:58 +01:00
1 parent d70f468781
commit c2f1b54d00
12 files changed
+281 -345

No files matched your search

+1
View File
@@ -274,6 +274,7 @@
"src/ui/styles.js",
"src/ui/shellLifecycle.test.mjs",
"src/testSupport/readStylesheet.mjs",
"src/testSupport/streetLevelFakes.mjs",
"src/splitFlap.js",
"style.css",
"src/ui/styles/overlays.css",
+22 -54
View File
@@ -200,6 +200,23 @@ function readPanel(page) {
});
}
/** Wait until Street Level is on, drawn, settled and not key-gated. */
function waitForCoverage(page, { timeout = 90_000 } = {}) {
return page.waitForFunction(
() => {
const dm = window.__godsEyeView.dataManager;
const u = dm.layers.get('street-level').module.getUIState();
return (
dm.isEnabled('street-level') &&
u.coverage.count > 0 &&
!u.coverage.loading &&
!u.keyRequired
);
},
{ timeout },
);
}
/** Without a key on the server the panel gates its controls and says why. */
async function assertKeylessGate(page) {
await page.evaluate(() =>
@@ -360,15 +377,7 @@ async function main() {
origin: 'user',
}),
);
await page.waitForFunction(
() => {
const u = window.__godsEyeView.dataManager.layers
.get('street-level')
.module.getUIState();
return u.coverage.count > 0 && !u.coverage.loading;
},
{ timeout: 90_000 },
);
await waitForCoverage(page);
const info = await panel();
assert.equal(info.controlsDisabled, false);
// Cesium paints on-screen credits a frame or two after they register.
@@ -410,18 +419,7 @@ async function main() {
);
assert.equal((await ui()).coverage.count, 0);
await page.click('#sl-status');
await page.waitForFunction(
() => {
const dm = window.__godsEyeView.dataManager;
const u = dm.layers.get('street-level').module.getUIState();
return (
dm.isEnabled('street-level') &&
u.coverage.count > 0 &&
!u.coverage.loading
);
},
{ timeout: 90_000 },
);
await waitForCoverage(page);
assert.equal(
await page.$eval('#sl-status', (node) =>
node.getAttribute('aria-pressed'),
@@ -458,18 +456,7 @@ async function main() {
'lighting the chip turns the layer back on with coverage',
async () => {
await page.click(chip);
await page.waitForFunction(
() => {
const dm = window.__godsEyeView.dataManager;
const u = dm.layers.get('street-level').module.getUIState();
return (
dm.isEnabled('street-level') &&
u.coverage.count > 0 &&
!u.coverage.loading
);
},
{ timeout: 90_000 },
);
await waitForCoverage(page);
assert.equal(
await page.$eval(chip, (node) => node.getAttribute('aria-pressed')),
'true',
@@ -614,17 +601,7 @@ async function main() {
);
fixture.tiles = 'ok';
await page.click('#sl-status');
await page.waitForFunction(
() => {
const u = window.__godsEyeView.dataManager.layers
.get('street-level')
.module.getUIState();
return (
u.coverage.count > 0 && !u.coverage.loading && !u.keyRequired
);
},
{ timeout: 90_000 },
);
await waitForCoverage(page);
await statusText('ON');
},
);
@@ -806,16 +783,7 @@ async function main() {
.module.getUIState().surface === 'draped',
{ timeout: 10_000 },
);
const coverageLoaded = () =>
page.waitForFunction(
() => {
const u = window.__godsEyeView.dataManager.layers
.get('street-level')
.module.getUIState();
return u.coverage.count > 0 && !u.coverage.loading;
},
{ timeout: 60_000 },
);
const coverageLoaded = () => waitForCoverage(page, { timeout: 60_000 });
await coverageLoaded();
assert.equal((await surface()).surface, 'draped', 'draped on Esri');
const photoreal = await page.evaluate(() =>