64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
import { test, expect } from "./fixtures/console-gate";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import {
|
|
replaceVvoMjzFixtureDates,
|
|
vvoMjzDetailsUrl,
|
|
} from "./helpers/dates";
|
|
|
|
// Schedule details uses the same Angular aircraft-link behavior as
|
|
// online-board: the model text under "Борт" opens the generic plane park page.
|
|
|
|
const FIXTURE_DIR = path.resolve(
|
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
"../fixtures/api",
|
|
);
|
|
const scheduleDetails = fs.readFileSync(
|
|
path.join(FIXTURE_DIR, "schedule-details.json"),
|
|
"utf8",
|
|
);
|
|
const scheduleDetailsBody = replaceVvoMjzFixtureDates(scheduleDetails);
|
|
|
|
test("Schedule details aircraft title opens Aeroflot plane park in a new tab", async ({
|
|
page,
|
|
context,
|
|
consoleMessages,
|
|
}) => {
|
|
await page.route("**/api/flights/v1.1/ru/schedule/details?**", async (route) => {
|
|
await route.fulfill({
|
|
status: 200,
|
|
contentType: "application/json",
|
|
body: scheduleDetailsBody,
|
|
});
|
|
});
|
|
|
|
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(vvoMjzDetailsUrl());
|
|
|
|
const details = page.locator(".schedule-leg-details");
|
|
await expect(details).toHaveCount(1, { timeout: 15000 });
|
|
await expect(details.getByText("Борт", { exact: true })).toBeVisible();
|
|
|
|
const link = details.locator("a.schedule-leg-details__link");
|
|
await expect(link).toHaveText("Sukhoi SuperJet 100");
|
|
await expect(link).toHaveAttribute(
|
|
"href",
|
|
"http://www.aeroflot.ru/cms/ru/flight/plane_park",
|
|
);
|
|
await expect(link).toHaveAttribute("target", "_blank");
|
|
|
|
const popupPromise = page.waitForEvent("popup");
|
|
await link.click();
|
|
const popup = await popupPromise;
|
|
await expect(popup).toHaveURL("http://www.aeroflot.ru/cms/ru/flight/plane_park");
|
|
await popup.close();
|
|
});
|