Fix schedule aircraft link target

This commit is contained in:
2026-05-14 17:22:11 +03:00
parent b3d242e7e0
commit 6cf57596bf
4 changed files with 107 additions and 29 deletions
+61
View File
@@ -0,0 +1,61 @@
import { test, expect } from "./fixtures/console-gate";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
// 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 URL =
"/ru-ru/schedule/VVO/SU5752-20260518/KJA/SU6837-20260519/MJZ?request=schedule-route-VVO-MJZ-20260518-20260524";
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: scheduleDetails,
});
});
await context.route("http://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(URL);
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();
});