This commit is contained in:
@@ -1,48 +1,62 @@
|
||||
import { test, expect } from "./fixtures/console-gate";
|
||||
|
||||
// TIRREDESIGN-12 — when both schedule cities are filled, the date-picker
|
||||
// must grey out the days the route does NOT operate. The fix in
|
||||
// ScheduleFilter.tsx aligned the date-format used for the
|
||||
// available-days set lookup (yyyy-MM-dd, matching the schedule
|
||||
// `/days` API output) — previously the lookup compared `yyyymmdd`
|
||||
// against `yyyy-MM-dd`, so every day was treated as unavailable
|
||||
// and the entire calendar greyed out.
|
||||
// must grey out the days the route does NOT operate. The schedule
|
||||
// `/days` bitmask is anchored to the requested calendar minimum date:
|
||||
// bit 0 maps to that exact date, not "base date minus one".
|
||||
|
||||
test("Schedule calendar greys out non-operating days for the route", async ({
|
||||
page,
|
||||
consoleMessages,
|
||||
}) => {
|
||||
await page.goto("/ru-ru/schedule/route/MOW-MMK-20260427-20260503");
|
||||
await expect(page.locator(".day-grouped-flight-list").first()).toBeVisible({
|
||||
timeout: 15000,
|
||||
function ymd(date: Date): string {
|
||||
return [
|
||||
date.getFullYear(),
|
||||
String(date.getMonth() + 1).padStart(2, "0"),
|
||||
String(date.getDate()).padStart(2, "0"),
|
||||
].join("");
|
||||
}
|
||||
|
||||
function addDays(date: Date, days: number): Date {
|
||||
const next = new Date(date);
|
||||
next.setDate(next.getDate() + days);
|
||||
return next;
|
||||
}
|
||||
|
||||
test("Schedule calendar greys out non-operating days for the route", async ({ page }) => {
|
||||
const minDate = addDays(new Date(), -1);
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
const dateTo = addDays(minDate, 6);
|
||||
|
||||
await page.route("**/api/flights/v1/*/days/**/schedule/", async (route) => {
|
||||
await route.fulfill({
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ days: `0${"1".repeat(381)}` }),
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto(`/ru-ru/schedule/route/LED-KUF-${ymd(minDate)}-${ymd(dateTo)}-C0`);
|
||||
|
||||
// Open the picker.
|
||||
await page.locator("button.p-datepicker-trigger").first().click();
|
||||
const panel = page.locator(".p-datepicker-panel, .p-datepicker").first();
|
||||
await expect(panel).toBeVisible();
|
||||
|
||||
// Wait for the operating-days API to come back (the disabled-set
|
||||
// is derived from it; before that, every day is enabled).
|
||||
await expect
|
||||
.poll(async () =>
|
||||
page
|
||||
.locator(".p-datepicker td span.p-disabled")
|
||||
.count(),
|
||||
{ timeout: 10000 })
|
||||
.toBeGreaterThan(0);
|
||||
const visibleDaySelector = ".p-datepicker td:not(.p-datepicker-other-month) span";
|
||||
const minDateDay = String(minDate.getDate());
|
||||
const nextDateDay = String(addDays(minDate, 1).getDate());
|
||||
|
||||
// The MOW→MMK route operates roughly daily today onward, so the
|
||||
// visible month must contain BOTH enabled and disabled cells.
|
||||
// The check is intentionally loose because the live operating
|
||||
// schedule shifts by route — but a fully-enabled or fully-disabled
|
||||
// calendar would prove the format-mismatch regression returned.
|
||||
const enabled = await page
|
||||
.locator(".p-datepicker td span:not(.p-disabled)")
|
||||
.count();
|
||||
const disabled = await page
|
||||
.locator(".p-datepicker td span.p-disabled")
|
||||
.count();
|
||||
expect(enabled).toBeGreaterThan(0);
|
||||
expect(disabled).toBeGreaterThan(0);
|
||||
await expect.poll(async () => {
|
||||
const cells = await page.locator(visibleDaySelector).evaluateAll((nodes) =>
|
||||
nodes.map((node) => ({
|
||||
text: node.textContent?.trim(),
|
||||
className: node.className,
|
||||
})),
|
||||
);
|
||||
return cells.find((cell) => cell.text === minDateDay)?.className ?? "";
|
||||
}, { timeout: 10000 }).toContain("p-disabled");
|
||||
|
||||
const cells = await page.locator(visibleDaySelector).evaluateAll((nodes) =>
|
||||
nodes.map((node) => ({
|
||||
text: node.textContent?.trim(),
|
||||
className: node.className,
|
||||
})),
|
||||
);
|
||||
expect(cells.find((cell) => cell.text === nextDateDay)?.className ?? "").not.toContain("p-disabled");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user