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.
This commit is contained in:
Maurice
2026-09-29 21:45:27 +02:00
parent 71a8b24f8d
commit fd5afb0fad
@@ -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)
})
})