Files
flights_web/tests/e2e/schedule-su0634-aircraft-link.spec.ts
T

194 lines
5.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test, expect } from "./fixtures/console-gate";
import {
routeAppSettingsFixture,
routeDictionaryFixtures,
} from "./helpers/api-fixtures";
import {
addDays,
formatIsoDate,
formatYmd,
vvoMjzScheduleDates,
} from "./helpers/dates";
// TIRREDESIGN-28: SU0634 KJA -> HKT departs after midnight local time while
// the backend flightId.date remains on the previous service day. Angular builds
// the schedule details URL from the leg's local scheduled departure date, so
// the details request receives the local departure date and the aircraft link is rendered.
const dates = vvoMjzScheduleDates();
const serviceDate = dates.leg1;
const localDate = dates.leg2;
const routeEnd = addDays(localDate, 6);
const SERVICE_DATE_ISO = formatIsoDate(serviceDate);
const LOCAL_DATE_ISO = formatIsoDate(localDate);
const LOCAL_DATE_YMD = formatYmd(localDate);
const ROUTE_URL = `/ru-ru/schedule/route/KJA-HKT-${LOCAL_DATE_YMD}-${formatYmd(routeEnd)}-C0`;
const PLANE_PARK_URL = "http://www.aeroflot.ru/cms/ru/flight/plane_park";
const su0634Search = [
{
routeType: "Direct",
operatingBy: { scheduled: "SU", operators: [] },
status: "Scheduled",
id: "su0634-kja-hkt",
flightId: {
carrier: "SU",
flightNumber: "0634",
suffix: "",
date: SERVICE_DATE_ISO,
dateLT: LOCAL_DATE_ISO,
},
flyingTime: "08:10:00",
leg: {
departure: {
scheduled: {
city: "Красноярск",
airport: "Емельяново",
countryCode: "RU",
cityCode: "KJA",
airportCode: "KJA",
},
terminal: "1",
times: {
scheduledDeparture: {
utc: `${SERVICE_DATE_ISO}T22:05:00Z`,
local: `${LOCAL_DATE_ISO}T05:05:00+07:00`,
dayChange: { value: 0, title: "" },
localTime: "05:05",
tzOffset: 420,
},
},
},
arrival: {
scheduled: {
city: "Пхукет",
airport: "Пхукет",
countryCode: "TH",
cityCode: "HKT",
airportCode: "HKT",
},
terminal: "I",
times: {
scheduledArrival: {
utc: `${LOCAL_DATE_ISO}T06:15:00Z`,
local: `${LOCAL_DATE_ISO}T13:15:00+07:00`,
dayChange: { value: 0, title: "" },
localTime: "13:15",
tzOffset: 420,
},
},
},
flags: {
checkinAvailable: false,
purchaseAvailable: true,
statusAvailable: false,
routeChanged: false,
returnToAirport: false,
},
updated: "2026-05-15T03:29:55Z",
status: "Scheduled",
operatingBy: { scheduled: "SU", operators: [] },
transition: {},
daysOfWeek: { current: "2", flight: "25" },
flyingTime: "08:10:00",
equipment: {
meal: [{ type: "Business" }, { type: "Economy" }, { type: "Comfort" }],
aircraft: {
scheduled: { type: "333", title: "Airbus A330-300" },
actualType: { type: "333", title: "Airbus A330-300" },
actual: {
type: "333",
title: "Airbus A330-300",
registration: "73786",
name: "В. Брумель",
},
},
},
trafficRestrictions: [""],
},
},
];
const su0634Details = {
data: {
routes: su0634Search,
partners: [],
daysOfFlight: [
formatYmd(addDays(localDate, -4)),
LOCAL_DATE_YMD,
formatYmd(addDays(localDate, 3)),
formatYmd(addDays(localDate, 7)),
],
},
};
test("TIRREDESIGN-28: SU0634 schedule details uses local date and opens plane park", async ({
page,
context,
consoleMessages,
}) => {
await routeDictionaryFixtures(page);
await routeAppSettingsFixture(page);
await page.route("**/api/flights/v1/*/days/**/schedule/", async (route) => {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({ days: "1111111" }),
});
});
await page.route("**/api/flights/1/*/schedule?**", async (route) => {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(su0634Search),
});
});
await page.route("**/api/flights/v1.1/*/schedule/details?**", async (route) => {
const url = new URL(route.request().url());
const date = url.searchParams.get("dates[0]");
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(
date === `${LOCAL_DATE_ISO}T00:00:00`
? su0634Details
: { data: { routes: [], partners: [], daysOfFlight: [] } },
),
});
});
await context.route(/https?:\/\/www\.aeroflot\.ru\/cms\/ru\/flight\/plane_park/, async (route) => {
await route.fulfill({
status: 200,
contentType: "text/html",
body: "<!doctype html><title>Plane park</title>",
});
});
await page.goto(ROUTE_URL);
const card = page.locator(".flight-card--clickable").first();
await expect(card).toBeVisible({ timeout: 30000 });
await card.click();
const detailsBtn = page.locator('[data-testid="flight-details-button"]');
await expect(detailsBtn).toBeVisible({ timeout: 10000 });
await detailsBtn.click();
await expect(page).toHaveURL(
new RegExp(`/ru-ru/schedule/KJA/SU0634-${LOCAL_DATE_YMD}/HKT`),
);
const details = page.locator('[data-testid="schedule-leg-details"]');
await expect(details).toBeVisible({ timeout: 15000 });
const link = details.locator("a.schedule-leg-details__link");
await expect(link).toHaveText("Airbus A330-300");
await expect(link).toHaveAttribute("href", PLANE_PARK_URL);
await expect(link).toHaveAttribute("target", "_blank");
const popupPromise = page.waitForEvent("popup");
await link.click();
const popup = await popupPromise;
await expect(popup).toHaveURL(PLANE_PARK_URL);
await popup.close();
});