From fd5afb0fad00b312f6861f6ea920487e612f99ba Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 29 Sep 2026 21:45:27 +0200 Subject: [PATCH] test(map): opening another trip with the overview on frames that trip The overview holds its camera frame across content edits and only publishes a fresh one on activation or on a trip switch. Activation is covered; the trip switch branch was not, so a regression there would leave the map framed on the previous trip. The new case keeps days and stops identical and changes only the trip id, so the switch alone has to produce the new frame. --- .../Map/useTripRouteOverview.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/src/components/Map/useTripRouteOverview.test.ts b/client/src/components/Map/useTripRouteOverview.test.ts index e236e7a75..4561eb118 100644 --- a/client/src/components/Map/useTripRouteOverview.test.ts +++ b/client/src/components/Map/useTripRouteOverview.test.ts @@ -255,4 +255,22 @@ describe('useTripRouteOverview', () => { await waitFor(() => expect(result.current.loading).toBe(false)) expect(result.current.focusPoints).not.toBe(frame) }) + + it('FE-MAP-TRO-014: opening another trip with the overview on publishes a fresh frame', async () => { + // Same days and stops on purpose: only the trip changed, so nothing but the trip + // switch itself can be what asks the map to frame again. + const { result, rerender } = renderHook( + ({ tripId }: { tripId: number }) => + useTripRouteOverview(tripId, DAYS, ASSIGNMENTS, [], [], 'driving', true), + { initialProps: { tripId: 7 } }, + ) + await waitFor(() => expect(result.current.loading).toBe(false)) + const frame = result.current.focusPoints + + rerender({ tripId: 8 }) + + await waitFor(() => expect(result.current.focusPoints).not.toBe(frame)) + await waitFor(() => expect(result.current.loading).toBe(false)) + expect(result.current.focusPoints).toEqual(frame) + }) })