Skip to content

test(web): give the retried map's container a size in the pin test - #726

Merged
Medformatik merged 1 commit into
mainfrom
test/pin-marker-replacement-map-rect
Oct 31, 2026
Merged

Medformatik merged 1 commit into
mainfrom
test/pin-marker-replacement-map-rect

Conversation

@Medformatik

Copy link
Copy Markdown
Collaborator

What changed and why

test (web) failed on #719, which touches no web code. All 5,664 tests passed, but Vitest reported an unhandled error from apps/web/src/hooks/usePinMarker.test.tsx:

TypeError: map.getContainer(...).getBoundingClientRect is not a function
 ❯ fitPinLabel apps/web/src/hooks/usePinMarker.ts:34:38

The cause is the test "reattaches the pin after the map is replaced by a retry":

  • It swaps in a second fake map whose container has no getBoundingClientRect. Only the first map's container is given one at the top of the file.
  • Because the label is visible, the hook fits it against the new map's container on the next animation frame.
  • The test usually unmounted first, which cancels that frame. On a slow runner the frame ran and threw outside the test.

The hook itself does cancel its pending frame on cleanup, so this is a test-only race.

The replacement container now gets the same size as the first. The test also waits for one animation frame before unmounting, as the other label tests in the file do, so it always runs the fit on the replacement map instead of racing it.

Verification

  • With a forced wait before the unmount, the unmodified test reproduces the CI error every time.
  • With the fix, three runs of the file pass with no errors. With the frame wait but without the container size, the error comes back.
  • pnpm exec vitest run --project web: 601 files, 5,667 tests, no errors. Biome passes.

Release and upgrade impact

Product impact: ordinary

The test that replaces the map gave the replacement a fake container
without getBoundingClientRect. The visible label is fitted against the
container on the next animation frame. The test usually unmounted
first, which cancels that frame, but on a slow runner the frame ran and
threw outside the test, and Vitest failed the web run with an unhandled
error.

The replacement container now has the same size as the first map's, and
the test waits for that frame before it unmounts, so it always runs the
fit on the replacement map.
@Medformatik Medformatik self-assigned this Oct 31, 2026
@Medformatik
Medformatik merged commit c263411 into main Oct 31, 2026
23 checks passed
@Medformatik
Medformatik deleted the test/pin-marker-replacement-map-rect branch October 31, 2026 18:57
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant