From ef0e1e38e5c62aa082751a4d8d5548e1241cb80d Mon Sep 17 00:00:00 2001 From: gnezim Date: Tue, 21 Apr 2026 18:08:42 +0300 Subject: [PATCH] =?UTF-8?q?Assert=20date-window=20clamp=20on=20Board=20?= =?UTF-8?q?=E2=86=90=20Schedule=20projection=20per=20TZ=204.1.8-R2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../state/crossSectionNavigation.test.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/shared/state/crossSectionNavigation.test.ts b/src/shared/state/crossSectionNavigation.test.ts index 49e1b4be..da943639 100644 --- a/src/shared/state/crossSectionNavigation.test.ts +++ b/src/shared/state/crossSectionNavigation.test.ts @@ -225,6 +225,42 @@ describe("4.1.8-R1/R2: projectScheduleToBoard", () => { }); expect(p.mode).toBe("route"); }); + + it("4.1.8-R2: projectScheduleToBoard clamps to today when schedule dateFrom is > board window", () => { + // Clock frozen at 2026-05-15. Schedule dateFrom = 2026-07-01 (47 days forward, outside board's +14 window) + const schedule: ScheduleFilterSnapshot = { + mode: "route", + departure: "MOW", + arrival: "LED", + dateFrom: "20260701", + dateTo: "20260707", + timeFrom: "0000", + timeTo: "2400", + onlyDirect: false, + showReturn: false, + searchExecuted: true, + }; + const projected = projectScheduleToBoard(schedule); + expect(projected.date).toBe("20260515"); // clamps to today + }); + + it("4.1.8-R2: projectScheduleToBoard uses today even when schedule dateFrom is before today-1", () => { + // Schedule dateFrom in the distant past + const schedule: ScheduleFilterSnapshot = { + mode: "route", + departure: "MOW", + arrival: "LED", + dateFrom: "20250101", + dateTo: "20250107", + timeFrom: "0000", + timeTo: "2400", + onlyDirect: false, + showReturn: false, + searchExecuted: true, + }; + const projected = projectScheduleToBoard(schedule); + expect(projected.date).toBe("20260515"); // clamps to today + }); }); describe("4.1.1-R26 / 4.1.8-R3: map filter is independent of board/schedule", () => {