Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/visit/visit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ function parkingInstructionDashOnboardMetrics(multimodal) {
return `${rideM} min ride`;
}

/** Minimum drive badge when the user's location is on the map (e.g. **5+ min drive**). */
const PARKING_DRIVE_ESTIMATE_DISPLAY_MIN_MINUTES = 5;

/** Right-column copy: haversine drive from the user's location (`parkingRoutePace.driveMilesPerHour`). */
function parkingInstructionDriveEstimateMetrics(
fromLat,
Expand All @@ -168,7 +171,10 @@ function parkingInstructionDriveEstimateMetrics(
const mph = resolveParkingRoutePace(
appData?.parkingRoutePace,
).driveMilesPerHour;
const min = Math.max(1, Math.round((miles / mph) * 60));
const min = Math.max(
PARKING_DRIVE_ESTIMATE_DISPLAY_MIN_MINUTES,
Math.round((miles / mph) * 60),
);
return `${min}+ min drive`;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/visit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ test.describe("Parking map (#/visit)", () => {

await expect(driveBadge).not.toHaveText("15+ min drive");
await expect(driveBadge).toHaveText(/\d+\+ min drive/);

const floored = await page.evaluate(() => {
const fn = globalThis.__parkingInstructionDriveEstimateMetricsForTest;
return fn?.(42.97, -85.68, 42.9701, -85.6801) ?? "";
});
expect(floored).toBe("5+ min drive");
});

test("preserves destination and category filters in the URL across reload", async ({
Expand Down
Loading