diff --git a/src/features/schedule/components/ScheduleDetailsPage.tsx b/src/features/schedule/components/ScheduleDetailsPage.tsx index 8fb1b4f9..b801e187 100644 --- a/src/features/schedule/components/ScheduleDetailsPage.tsx +++ b/src/features/schedule/components/ScheduleDetailsPage.tsx @@ -57,16 +57,6 @@ function formatApiDate(yyyymmdd: string): string { return `${yyyymmdd.slice(0, 4)}-${yyyymmdd.slice(4, 6)}-${yyyymmdd.slice(6, 8)}T00:00:00`; } -/** Shift a yyyyMMdd date by `days` (negative for backwards). */ -function shiftYmd(yyyymmdd: string, days: number): string { - if (yyyymmdd.length !== 8) return yyyymmdd; - const d = new Date( - `${yyyymmdd.slice(0, 4)}-${yyyymmdd.slice(4, 6)}-${yyyymmdd.slice(6, 8)}T00:00:00`, - ); - d.setDate(d.getDate() + days); - const pad = (n: number) => String(n).padStart(2, "0"); - return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}`; -} /** @@ -113,13 +103,6 @@ export const ScheduleDetailsPage: FC = ({ return raw ? parseDetailsRequestParam(raw) : null; }, [searchParams]); - // TZ §4.1.16.2 — re-issue the parent schedule-route search so the - // left-side mini-list shows the available flight options for the - // selected day plus its neighbours. MUST be called unconditionally - // before any early returns to keep React's hook order stable. - // - const selectedYmd = flightIds[0]?.date ?? ""; - // Angular's `schedule-flights-mini-list` only shows a multi-day // accordion when `schedule.length > 1`; for a connecting itinerary // it renders a single card — the currently-open flight, with the diff --git a/src/features/schedule/components/ScheduleFlightBody.test.tsx b/src/features/schedule/components/ScheduleFlightBody.test.tsx index 42b33477..b36dc13e 100644 --- a/src/features/schedule/components/ScheduleFlightBody.test.tsx +++ b/src/features/schedule/components/ScheduleFlightBody.test.tsx @@ -12,7 +12,7 @@ */ import { describe, it, expect, vi } from "vitest"; -import { render, screen, fireEvent } from "@testing-library/react"; +import { render, screen } from "@testing-library/react"; import type { ISimpleFlight, IFlightLeg } from "@/features/online-board/types.js"; // ── i18n stub ───────────────────────────────────────────────────────────────── @@ -161,25 +161,9 @@ function makeConnectingFlight(depUtc: string): ISimpleFlight { // ── Buy-gate helpers ────────────────────────────────────────────────────────── -/** 10 days from now — buy should be visible */ +/** 10 days from now — used by the structure tests below to exercise a + * future-dated flight against the leg-body renderer. */ const FUTURE_10D = new Date(Date.now() + 10 * 24 * 3600 * 1000).toISOString(); -/** 340 days from now — buy should be hidden (> 330 days) */ -const FUTURE_340D = new Date(Date.now() + 340 * 24 * 3600 * 1000).toISOString(); -/** 1 hour from now — buy should be hidden (< 2h threshold) */ -const FUTURE_1H = new Date(Date.now() + 1 * 3600 * 1000).toISOString(); -/** Yesterday — buy should be hidden (past) */ -const YESTERDAY = new Date(Date.now() - 24 * 3600 * 1000).toISOString(); -/** Today (same calendar day) — status button should be visible */ -/** Return an ISO string that is guaranteed to be within today's UTC date. - * Always use UTC noon (12:00) to avoid any local-to-UTC shift pushing us - * into yesterday or tomorrow. */ -function todayUtc(): string { - const now = new Date(); - // Force UTC noon of today — well within the UTC calendar day - return new Date( - Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), 12, 0, 0), - ).toISOString(); -} // ── Tests ───────────────────────────────────────────────────────────────────── diff --git a/tests/integration/online-board/error-handling.test.tsx b/tests/integration/online-board/error-handling.test.tsx index 0a86764c..895e51e7 100644 --- a/tests/integration/online-board/error-handling.test.tsx +++ b/tests/integration/online-board/error-handling.test.tsx @@ -92,6 +92,13 @@ vi.mock("@/shared/hooks/useAppSettings.js", () => ({ }), })); +// OnlineBoardDetailsPage resolves station codes via useStationDisplayName, +// which internally hits useApiClient — no ApiClientProvider in this tree. +vi.mock("@/shared/hooks/useDictionaries.js", () => ({ + useCityName: (code: string) => code, + useStationDisplayName: (code: string) => code, +})); + // --------------------------------------------------------------------------- // Constants // --------------------------------------------------------------------------- diff --git a/tests/integration/online-board/flight-details.test.tsx b/tests/integration/online-board/flight-details.test.tsx index e39bc0b2..6d5970a8 100644 --- a/tests/integration/online-board/flight-details.test.tsx +++ b/tests/integration/online-board/flight-details.test.tsx @@ -71,6 +71,14 @@ vi.mock("@/shared/hooks/useAppSettings.js", () => ({ }), })); +// OnlineBoardDetailsPage resolves station codes via useStationDisplayName, +// which internally hits useApiClient. There's no ApiClientProvider in +// this test tree, so stub the name-lookup hooks to echo the code. +vi.mock("@/shared/hooks/useDictionaries.js", () => ({ + useCityName: (code: string) => code, + useStationDisplayName: (code: string) => code, +})); + // --------------------------------------------------------------------------- // Helpers // ---------------------------------------------------------------------------