Skip to content

explorer: Playwright coverage for tryEnterPointModeIfNeeded() invariants #192

@rdhyee

Description

@rdhyee

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

  1. Short-circuit invariantstryEnterPointModeIfNeeded() 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)
  2. Camera-handler boot path — deep-link-style URL load, mock loadRes(8, ...) to resolve true after a tick, assert enterPointMode() was called.

  3. 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.

  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions