Files
flights_web/tests/e2e/schedule-flight-details-button.spec.ts

96 lines
3.1 KiB
TypeScript

import { test, expect } from "./fixtures/console-gate";
import { routeScheduleVvoMjzFixtures } from "./helpers/api-fixtures";
import { vvoMjzRouteUrl, vvoMjzScheduleDates } from "./helpers/dates";
test.describe("Schedule flight details button", () => {
test.beforeEach(async ({ page }) => {
await routeScheduleVvoMjzFixtures(page);
});
test("flight details button is visible in expanded flight body", async ({
page,
}) => {
await page.goto(vvoMjzRouteUrl());
const cards = page.locator(".flight-card--clickable");
await expect(cards.first()).toBeVisible({ timeout: 30000 });
await cards.first().click();
const actions = page.locator('[data-testid="schedule-flight-body-actions"]');
await expect(actions).toBeVisible({ timeout: 10000 });
const detailsBtn = actions.locator('[data-testid="flight-details-button"]');
await expect(detailsBtn).toBeVisible();
});
test("flight details button has correct label (Russian)", async ({ page }) => {
await page.goto(vvoMjzRouteUrl());
const cards = page.locator(".flight-card--clickable");
await expect(cards.first()).toBeVisible({ timeout: 30000 });
await cards.first().click();
const detailsBtn = page.locator('[data-testid="flight-details-button"]');
await expect(detailsBtn).toBeVisible();
const text = await detailsBtn.textContent();
expect(text).toContain("Детали");
});
test("flight details button navigates to flight details page", async ({
page,
}) => {
await page.goto(vvoMjzRouteUrl());
const cards = page.locator(".flight-card--clickable");
await expect(cards.first()).toBeVisible({ timeout: 30000 });
await cards.first().click();
const detailsBtn = page.locator('[data-testid="flight-details-button"]');
await detailsBtn.click();
await expect(page).toHaveURL(/\/ru-ru\/schedule\/[A-Z]{3}\/SU\d+-\d{8}\/[A-Z]{3}/);
});
test("flight details button works for connecting flights", async ({
page,
}) => {
await page.goto(vvoMjzRouteUrl());
const cards = page.locator(".flight-card--clickable");
await expect(cards.first()).toBeVisible({ timeout: 30000 });
const firstCard = cards.first();
await firstCard.click();
const detailsBtn = page.locator('[data-testid="flight-details-button"]');
await expect(detailsBtn).toBeVisible({ timeout: 10000 });
await detailsBtn.click();
await expect(page).toHaveURL(
/\/ru-ru\/schedule\/[A-Z]{3}\/SU\d+-\d{8}\/[A-Z]{3}\/SU\d+-\d{8}\/[A-Z]{3}/,
);
});
test("flight details button preserves search context in URL", async ({
page,
}) => {
const dates = vvoMjzScheduleDates();
await page.goto(vvoMjzRouteUrl());
const cards = page.locator(".flight-card--clickable");
await expect(cards.first()).toBeVisible({ timeout: 30000 });
await cards.first().click();
const detailsBtn = page.locator('[data-testid="flight-details-button"]');
await detailsBtn.click();
const url = page.url();
expect(url).toContain("?request=");
expect(url).toContain(`schedule-route-VVO-MJZ-${dates.startYmd}-${dates.endYmd}`);
});
});