From abc3e827307713ffd654b0492587322cae1c5000 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 27 Jun 2026 12:27:23 +0200 Subject: [PATCH] test(planner): cover the single-place route-tools visibility gate (#1330) Asserts the route tools appear for one located place when a bookend accommodation exists, and stay hidden without one, guarding the #1330 visibility change. --- .../Planner/DayPlanSidebar.test.tsx | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/client/src/components/Planner/DayPlanSidebar.test.tsx b/client/src/components/Planner/DayPlanSidebar.test.tsx index 7038db2d..28c37f1b 100644 --- a/client/src/components/Planner/DayPlanSidebar.test.tsx +++ b/client/src/components/Planner/DayPlanSidebar.test.tsx @@ -168,6 +168,34 @@ describe('DayPlanSidebar', () => { expect(screen.getByText('D2')).toBeInTheDocument() }) + // ── #1330: route tools for a single optimizable place ─────────────────────── + it('FE-PLANNER-DAYPLAN-005b: route tools show for one located place with a bookend hotel (#1330)', () => { + const place = buildPlace({ name: 'Louvre', lat: 48.86, lng: 2.34 }) + const day = buildDay({ id: 10, date: '2025-06-01', title: 'Day 1' }) + const day2 = buildDay({ id: 11, date: '2025-06-02', title: 'Day 2' }) + const assignment = buildAssignment({ id: 99, day_id: 10, order_index: 0, place }) + const accommodations = [{ id: 1, start_day_id: 10, end_day_id: 11, place_lat: 48.85, place_lng: 2.35 }] + render() + // With accommodation optimization on, one located place is routable (hotel → place → hotel), + // so the route tools (here the Google Maps export button) must be visible. + expect(screen.getByRole('button', { name: 'Open in Google Maps' })).toBeInTheDocument() + }) + + it('FE-PLANNER-DAYPLAN-005c: route tools stay hidden for one place with no bookend hotel (#1330 guard)', () => { + const place = buildPlace({ name: 'Louvre', lat: 48.86, lng: 2.34 }) + const day = buildDay({ id: 10, date: '2025-06-01', title: 'Day 1' }) + const assignment = buildAssignment({ id: 99, day_id: 10, order_index: 0, place }) + render() + // No accommodation to bookend the lone place, so nothing routable — tools stay hidden. + expect(screen.queryByRole('button', { name: 'Open in Google Maps' })).not.toBeInTheDocument() + }) + // ── Day expansion/collapse ────────────────────────────────────────────── it('FE-PLANNER-DAYPLAN-006: days are expanded by default', () => {