Skip to content

test(ui): replace window.__map test-only global with a non-global affordance #104

@comnam90

Description

@comnam90

Spun out of code review on #103 (item #4).

Context

layouts/index.html assigns window.__map = map so the two NZ regression tests in tests/ui.spec.ts can call m.setView(...) and m.latLngToContainerPoint(...) directly. This works but bleeds test affordance into production:

// layouts/index.html (around L1158)
window.__map = map;

Proposed fix

Either:

  • Gate behind a build-time flag: if (window.__TEST__) window.__map = map; and have Playwright set window.__TEST__ = true before page load.
  • Or expose the map via a data-leaflet-map="ready" attribute and have tests resolve it through Leaflet's own _leaflet_id registry.

Acceptance

  • window.__map no longer set in production build
  • NZ popup-fit regression tests still pass on Mobile Chrome and Mobile Safari

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions