From fb83a22457666e50c436da3fe0457dafc3532a4c Mon Sep 17 00:00:00 2001 From: Hannah Purcell <69368883+hannahpurcell@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:16:43 -0400 Subject: [PATCH] fix: Missed Stops should not display until detour finished (#2520) --- assets/src/hooks/useDetour.ts | 6 ++++-- assets/tests/hooks/useDetour.test.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/assets/src/hooks/useDetour.ts b/assets/src/hooks/useDetour.ts index fab382e4b..3abdccfac 100644 --- a/assets/src/hooks/useDetour.ts +++ b/assets/src/hooks/useDetour.ts @@ -133,9 +133,11 @@ export const useDetour = ({ routePatternId, shape }: OriginalRoute) => { setState(DetourState.Edit) } - const missedStops = finishedDetour?.missedStops || [] + const missedStops = finishedDetour?.missedStops || undefined - const missedStopIds = new Set(missedStops.map((stop) => stop.id)) + const missedStopIds = missedStops + ? new Set(missedStops.map((stop) => stop.id)) + : new Set() const stops = (shape.stops || []).map((stop) => ({ ...stop, missed: missedStopIds.has(stop.id), diff --git a/assets/tests/hooks/useDetour.test.ts b/assets/tests/hooks/useDetour.test.ts index 2f06b5ace..81b28e346 100644 --- a/assets/tests/hooks/useDetour.test.ts +++ b/assets/tests/hooks/useDetour.test.ts @@ -388,7 +388,7 @@ describe("useDetour", () => { act(() => result.current.undo?.()) await waitFor(() => { - expect(result.current.missedStops).toHaveLength(0) + expect(result.current.missedStops).toBeUndefined() }) })