Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/hooks/use-directions-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ export function useReverseGeocodeDirections() {
options?: { isPermalink?: boolean }
) => {
// For permalink loading, add waypoint if needed
if (options?.isPermalink && index > 1) {
if (
options?.isPermalink &&
index > 1 &&
useDirectionsStore.getState().waypoints.length <= index
) {
addEmptyWaypointToEnd();
Comment on lines +153 to 158
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no test coverage for the new guard condition added to reverseGeocode. Specifically, the key scenario that motivated this fix β€” loading a permalink with 3 or more waypoints when the sidebar is reopened (i.e., when waypoints already exist in the store) β€” is not exercised by any test. The existing directions.spec.tsx URL-parsing tests mock useReverseGeocodeDirections entirely and therefore do not validate the internal logic of the guard condition. A test for reverseGeocode (in the hook itself or via an integration test) should:

  1. Verify that addEmptyWaypointToEnd is called when loading a 3+ waypoint permalink with a fresh (default 2-waypoint) store.
  2. Verify that addEmptyWaypointToEnd is NOT called when the store already has a waypoint at the given index (the reopen scenario).

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that the current tests in directions.spec.tsx mock useReverseGeocodeDirections, so they don't exercise the internal logic of reverseGeocode. I’ll add a dedicated test to cover the guard condition if You want???
Specifically, I plan to add tests that verify:

  • addEmptyWaypointToEnd is called when loading a permalink with 3+ waypoints on a fresh store (default 2-waypoint state).
  • addEmptyWaypointToEnd is not called when the store already has a waypoint at the given index (e.g., when reopening the sidebar).
    Respond if you want i can add this?

}

Expand Down
Loading