Follow-up from #191 (issue #190 fix 2).
PR #191 introduced an idempotent tryEnterPointModeIfNeeded() helper that centralizes the cluster→point-mode transition and is called from four loadRes call sites to close a supersession liveness gap. None of the new behavior is exercised by Playwright today.
The cold-cache 60-90s repro is hard to automate (it depends on real network behavior of DuckDB-WASM 1.24.0), but the deterministic parts of the helper can be covered cheaply by mocking loadRes or stubbing viewer.camera.positionCartographic.height.
Suggested coverage
-
Short-circuit invariants — tryEnterPointModeIfNeeded() is a no-op when:
mode === 'point' (already there)
viewer.camera.positionCartographic.height >= ENTER_POINT_ALT (cluster altitude)
currentRes !== 8 && loading === true (another load is in flight; that path's call site is responsible for chasing)
-
Camera-handler boot path — deep-link-style URL load, mock loadRes(8, ...) to resolve true after a tick, assert enterPointMode() was called.
-
Source-filter supersession recovery (the bug round 3 closed) — set up cold-cache state with a pending res8 load, fire a source-filter change, assert that after both loads settle the user ends up in point mode, not stranded in cluster mode at point altitude.
-
Post-await re-checks — after the helper's loadRes await, assert enterPointMode() is not called when:
- The user zoomed back out during the wait (
hNow >= ENTER_POINT_ALT)
- Another path entered point mode first (
mode === 'point')
- The load was superseded or failed (
res8Ready === false)
Implementation notes
The current tests/playwright/cesium-queries.spec.js is the only Playwright file in tests/playwright/. New spec(s) probably belong alongside it. The helper lives inside the zoomWatcher OJS cell closure, so direct unit-testing is awkward — the cleanest seam is probably an integration test that drives the real explorer with a mocked db.query resolver, then asserts on mode / currentRes / phase-message text.
Acceptance
Refs
Follow-up from #191 (issue #190 fix 2).
PR #191 introduced an idempotent
tryEnterPointModeIfNeeded()helper that centralizes the cluster→point-mode transition and is called from fourloadRescall sites to close a supersession liveness gap. None of the new behavior is exercised by Playwright today.The cold-cache 60-90s repro is hard to automate (it depends on real network behavior of DuckDB-WASM 1.24.0), but the deterministic parts of the helper can be covered cheaply by mocking
loadResor stubbingviewer.camera.positionCartographic.height.Suggested coverage
Short-circuit invariants —
tryEnterPointModeIfNeeded()is a no-op when:mode === 'point'(already there)viewer.camera.positionCartographic.height >= ENTER_POINT_ALT(cluster altitude)currentRes !== 8 && loading === true(another load is in flight; that path's call site is responsible for chasing)Camera-handler boot path — deep-link-style URL load, mock
loadRes(8, ...)to resolvetrueafter a tick, assertenterPointMode()was called.Source-filter supersession recovery (the bug round 3 closed) — set up cold-cache state with a pending res8 load, fire a source-filter change, assert that after both loads settle the user ends up in point mode, not stranded in cluster mode at point altitude.
Post-await re-checks — after the helper's
loadResawait, assertenterPointMode()is not called when:hNow >= ENTER_POINT_ALT)mode === 'point')res8Ready === false)Implementation notes
The current
tests/playwright/cesium-queries.spec.jsis the only Playwright file intests/playwright/. New spec(s) probably belong alongside it. The helper lives inside thezoomWatcherOJS cell closure, so direct unit-testing is awkward — the cleanest seam is probably an integration test that drives the real explorer with a mockeddb.queryresolver, then asserts onmode/currentRes/ phase-message text.Acceptance
quarto previewsetup the existing tests use.Refs
tryEnterPointModeIfNeeded()