Wire DetailsBackButton and FlightSchedule into OnlineBoardDetailsPage

This commit is contained in:
2026-04-17 02:07:58 +03:00
parent 4093a2f1b5
commit 6fd42585c1
2 changed files with 35 additions and 3 deletions
@@ -264,4 +264,33 @@ describe("OnlineBoardDetailsPage", () => {
expect(screen.getByTestId("board-details-header")).toBeTruthy();
});
});
describe("back button integration", () => {
it("renders DetailsBackButton in headerLeft", () => {
mockState = { flight: mockFlight, allFlights: [mockFlight], daysOfFlight: ["20260416"], loading: false, error: null };
render(<OnlineBoardDetailsPage flightId={mockFlightId} locale="ru" canonicalOrigin="https://example.com" />);
expect(screen.getByTestId("details-back-button")).toBeTruthy();
});
});
describe("flight schedule integration", () => {
it("renders FlightSchedule when firstLeg.daysOfWeek is present", () => {
const flightWithDaysOfWeek = {
...mockFlight,
leg: {
...mockFlight.leg,
daysOfWeek: { current: "1000010", flight: "1111111" },
},
};
mockState = { flight: flightWithDaysOfWeek, allFlights: [flightWithDaysOfWeek], daysOfFlight: ["20260416"], loading: false, error: null };
render(<OnlineBoardDetailsPage flightId={mockFlightId} locale="ru" canonicalOrigin="https://example.com" />);
expect(screen.getByTestId("flight-schedule")).toBeTruthy();
});
it("does not render FlightSchedule when daysOfWeek is absent", () => {
mockState = { flight: mockFlight, allFlights: [mockFlight], daysOfFlight: ["20260416"], loading: false, error: null };
render(<OnlineBoardDetailsPage flightId={mockFlightId} locale="ru" canonicalOrigin="https://example.com" />);
expect(screen.queryByTestId("flight-schedule")).toBeNull();
});
});
});
@@ -16,7 +16,6 @@ import { FlightListSkeleton } from "@/ui/flights/FlightListSkeleton.js";
import { SeoHead } from "@/ui/seo/SeoHead.js";
import { JsonLdRenderer } from "@/shared/seo/json-ld.js";
import { PageLayout } from "@/ui/layout/PageLayout.js";
import { PageTabs } from "@/ui/layout/PageTabs.js";
import { useAppSettings } from "@/shared/hooks/useAppSettings.js";
import { useFlightDetails } from "../hooks/useFlightDetails.js";
import { useLiveFlightDetails } from "../hooks/useLiveFlightDetails.js";
@@ -27,6 +26,8 @@ import { FlightDetailsAccordion } from "./details-panels/FlightDetailsAccordion.
import { FlightsMiniList } from "./FlightsMiniList/index.js";
import { DayTabs } from "./DayTabs/index.js";
import { BoardDetailsHeader } from "./BoardDetailsHeader/index.js";
import { DetailsBackButton } from "./DetailsBackButton/index.js";
import { FlightSchedule } from "./FlightSchedule/index.js";
import type { IParsedFlightId, IFlightLeg } from "../types.js";
export interface OnlineBoardDetailsPageProps {
@@ -192,7 +193,7 @@ export const OnlineBoardDetailsPage: FC<OnlineBoardDetailsPageProps> = ({
const onlineboardHref = `/${locale}/onlineboard`;
const commonLayoutProps = {
headerLeft: <PageTabs viewType="onlineboard" />,
headerLeft: <DetailsBackButton locale={locale} />,
breadcrumbs: [
{ label: t("BREADCRUMBS.ONLINEBOARD"), url: onlineboardHref },
],
@@ -237,7 +238,7 @@ export const OnlineBoardDetailsPage: FC<OnlineBoardDetailsPageProps> = ({
<SeoHead {...seoProps} />
<JsonLdRenderer data={jsonLd} />
<PageLayout
headerLeft={<PageTabs viewType="onlineboard" />}
headerLeft={<DetailsBackButton locale={locale} />}
title={<h1 className="flight-details__flight-number">{flightNumber}</h1>}
breadcrumbs={[
{ label: t("BREADCRUMBS.ONLINEBOARD"), url: onlineboardHref },
@@ -297,6 +298,8 @@ export const OnlineBoardDetailsPage: FC<OnlineBoardDetailsPageProps> = ({
<div className="flight-details__flying-time" data-testid="flying-time">
Total flying time: {displayFlight.flyingTime}
</div>
<FlightSchedule flight={displayFlight} />
</div>
</PageLayout>
</>