Skip to content

Stabilize Node 24 map tests by removing Leaflet DOM snapshot coupling - #1104

Closed
acelaya with Copilot wants to merge 10 commits into
mainfrom
copilot/fix-ci-unit-tests-24-x
Closed

acelaya with Copilot wants to merge 10 commits into
mainfrom
copilot/fix-ci-unit-tests-24-x

Conversation

Copilot AI commented Sep 26, 2026 •

Copy link
Copy Markdown

The ci / unit-tests (24.x) failure came from a brittle MapModal snapshot that depended on Leaflet tile DOM/state, which varies across browser/runtime environments. This change makes the affected map tests deterministic by asserting stable rendered content instead of Leaflet internals.

  • Replace flaky snapshot coverage

    • Remove the full-dialog snapshot from MapModal.test.tsx
    • Assert the visible map region and rendered marker content directly
  • Mock react-leaflet in map tests

    • Replace runtime Leaflet DOM with a small test double for MapContainer, Marker, Popup, and TileLayer
    • Avoid environment-specific tile classes/styles such as leaflet-tile-loaded and transient opacity values
  • Strengthen behavior-focused assertions

    • Verify marker content for the expected cities/counts
    • Add explicit coverage for singular formatting (1 visit from ...)
    • Keep OpenMapModalBtn filtering assertions focused on rendered marker count via stable test hooks
vi.mock('react-leaflet', () => ({
  MapContainer: ({ children }) => <div role="region" aria-label="Map">{children}</div>,
  Marker: ({ children }) => <div data-testid="marker">{children}</div>,
  Popup: ({ children }) => <>{children}</>,
  TileLayer: () => null,
}));

expect(screen.getAllByTestId('marker')).toHaveLength(expectedMarkers);
expect(screen.getByTestId('marker')).toHaveTextContent('1 visit from London');

Copilot AI and others added 9 commits September 26, 2026 16:53
Co-authored-by: acelaya <2719332+acelaya@users.noreply.github.com>
Co-authored-by: acelaya <2719332+acelaya@users.noreply.github.com>
Co-authored-by: acelaya <2719332+acelaya@users.noreply.github.com>
Co-authored-by: acelaya <2719332+acelaya@users.noreply.github.com>
Co-authored-by: acelaya <2719332+acelaya@users.noreply.github.com>
Co-authored-by: acelaya <2719332+acelaya@users.noreply.github.com>
Co-authored-by: acelaya <2719332+acelaya@users.noreply.github.com>
Co-authored-by: acelaya <2719332+acelaya@users.noreply.github.com>
Co-authored-by: acelaya <2719332+acelaya@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job ci / unit-tests (24.x) Stabilize Node 24 map tests by removing Leaflet DOM snapshot coupling Sep 26, 2026
Copilot AI requested a review from acelaya September 26, 2026 17:00
@acelaya acelaya closed this Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants