Files
flights_web/tests/e2e/schedule-details-day-tabs-operating-days.spec.ts

66 lines
2.1 KiB
TypeScript

import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { test, expect } from "./fixtures/console-gate";
import { routeAppSettingsFixture } from "./helpers/api-fixtures";
import {
replaceVvoMjzFixtureDates,
vvoMjzScheduleDates,
} from "./helpers/dates";
const FIXTURE_DIR = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"../fixtures/api",
);
test("TIRREDESIGN-26: schedule details day tabs disable non-operating flight dates", async ({
page,
consoleMessages,
}) => {
const dates = vvoMjzScheduleDates();
const url = `/ru-ru/schedule/KJA/SU6837-${dates.leg2Ymd}/MJZ?request=schedule-route-KJA-MJZ-${dates.startYmd}-${dates.endYmd}-C0`;
await routeAppSettingsFixture(page);
await page.route("**/api/flights/v1.1/*/schedule/details?**", async (route) => {
const source = JSON.parse(
replaceVvoMjzFixtureDates(
fs.readFileSync(path.join(FIXTURE_DIR, "schedule-details-vvo-mjz.json"), "utf8"),
),
) as {
data: {
routes: Array<{
flightId: { carrier: string; flightNumber: string; date: string };
}>;
partners: string[];
};
};
const su6837 = source.data.routes.find(
(flight) =>
flight.flightId.carrier === "SU" &&
flight.flightId.flightNumber === "6837" &&
flight.flightId.date === dates.leg2Iso,
);
expect(su6837).toBeTruthy();
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
data: {
partners: [],
routes: su6837 ? [su6837] : [],
daysOfFlight: [dates.leg2Ymd, dates.altLeg2Ymd],
},
}),
});
});
await page.goto(url);
await expect(page.getByTestId("day-tabs")).toBeVisible({ timeout: 15000 });
await page.getByTestId("day-tabs-next").click();
const nonOperatingFriday = page.getByTestId(`day-tab-${dates.altLeg1Ymd}`);
await expect(nonOperatingFriday).toBeDisabled();
await expect(page.getByTestId(`day-tab-${dates.altLeg2Ymd}`)).toBeEnabled();
await expect(page.getByTestId("schedule-details-not-found")).toHaveCount(0);
});