71 lines
2.8 KiB
TypeScript
71 lines
2.8 KiB
TypeScript
import { test, expect } from "./fixtures/console-gate";
|
|
import { routeOnlineboardRouteFixtures } from "./helpers/api-fixtures";
|
|
|
|
// TIRREDESIGN-10 — Onlineboard list rows must surface "Купить билет"
|
|
// and "Онлайн регистрация" inside the expanded body when the per-flight
|
|
// visibility rules pass:
|
|
// • Buy: now ∈ [departure - buyTicketMaxHours, departure - buyTicketMinHours]
|
|
// • Register: leg.transition.registration.status === "InProgress"
|
|
//
|
|
// Use captured API fixtures so parallel e2e runs are not dependent on
|
|
// upstream WAF availability or a particular time of day.
|
|
|
|
test("Onlineboard expanded row shows Купить билет + Онлайн регистрация when applicable", async ({
|
|
page,
|
|
consoleMessages,
|
|
}) => {
|
|
await routeOnlineboardRouteFixtures(page);
|
|
// Today in the harness clock.
|
|
const today = new Date().toISOString().slice(0, 10).replace(/-/g, "");
|
|
await page.goto(`/ru-ru/onlineboard/route/MOW-LED-${today}`);
|
|
await expect(page.locator(".flight-card").first()).toBeVisible({
|
|
timeout: 15000,
|
|
});
|
|
|
|
// Walk Scheduled rows whose departure ≥ +2h from now and try to expand
|
|
// them until we find one that surfaces the Buy button (Register depends
|
|
// on the live `transition.registration.status` flag — when present we
|
|
// also assert it; when absent the assertion is skipped).
|
|
const cards = page.locator(".flight-card--clickable");
|
|
const count = await cards.count();
|
|
let proven = false;
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
const card = cards.nth(i);
|
|
const text = (await card.innerText()).replace(/\s+/g, " ");
|
|
if (!/Запланирован/.test(text)) continue;
|
|
await card.click();
|
|
const expanded = page
|
|
.locator(".flight-card--expanded")
|
|
.filter({ hasText: text.split(" ").slice(0, 2).join(" ") });
|
|
const buy = expanded.locator('[data-testid="buy-ticket-button"]');
|
|
if ((await buy.count()) === 0) {
|
|
// collapse and try the next
|
|
await card.click();
|
|
continue;
|
|
}
|
|
await expect(buy).toBeVisible();
|
|
await expect(buy).toHaveText("Купить билет");
|
|
|
|
// Register button is conditional on registration.status === InProgress —
|
|
// assert it only when the row's body shows the Регистрация panel.
|
|
const hasRegPanel = await expanded
|
|
.getByText("Регистрация")
|
|
.first()
|
|
.isVisible()
|
|
.catch(() => false);
|
|
if (hasRegPanel) {
|
|
const reg = expanded.locator('[data-testid="registration-button"]');
|
|
await expect(reg).toBeVisible();
|
|
await expect(reg).toHaveText("Онлайн регистрация");
|
|
}
|
|
proven = true;
|
|
break;
|
|
}
|
|
|
|
test.skip(
|
|
!proven,
|
|
"no Scheduled flight ≥ +2h from now in the live MOW→LED board — cannot assert (live data dependency)",
|
|
);
|
|
});
|