diff --git a/apps/web/src/hooks/usePinMarker.test.tsx b/apps/web/src/hooks/usePinMarker.test.tsx index bbe47a55d..ffe93cb01 100644 --- a/apps/web/src/hooks/usePinMarker.test.tsx +++ b/apps/web/src/hooks/usePinMarker.test.tsx @@ -162,6 +162,10 @@ it("reattaches the pin after the map is replaced by a retry", async () => { expect(fake.map.getCanvasContainer().querySelector("span")?.textContent).toBe("Station"); const replacement = createFakeMap({ styleLoaded: true }); + // The visible label is fitted against the new map's container on the next frame. + Object.assign(replacement.map.getContainer(), { + getBoundingClientRect: () => new DOMRect(0, 0, 1200, 800), + }); mapRef.current = replacement.map; styleVersion++; view.rerender(); @@ -169,6 +173,7 @@ it("reattaches the pin after the map is replaced by a retry", async () => { expect(fake.map.getCanvasContainer().querySelector("span")).toBeNull(); expect(replacement.map.getCanvasContainer().querySelector("span")?.textContent).toBe("Station"); + await act(async () => new Promise((resolve) => requestAnimationFrame(() => resolve()))); view.unmount(); mapRef.current = fake.map; styleVersion = 0;