Fix online board time range guard

This commit is contained in:
2026-05-05 17:11:15 +03:00
parent dfea0aec73
commit 04a71192fa
8 changed files with 143 additions and 32 deletions
+31 -24
View File
@@ -8,7 +8,18 @@ import { test, expect } from "./fixtures/console-gate";
// 3. Assert URL gained the `-{timeFrom}{timeTo}` suffix
// 4. Assert the rendered list shrank to flights inside the new window
const ROUTE_URL = "/ru-ru/onlineboard/route/MOW-LED-20260423";
function todayYyyymmdd(): string {
const today = new Date();
return [
today.getFullYear(),
String(today.getMonth() + 1).padStart(2, "0"),
String(today.getDate()).padStart(2, "0"),
].join("");
}
function routeUrl(): string {
return `/ru-ru/onlineboard/route/MOW-LED-${todayYyyymmdd()}`;
}
test.describe("Onlineboard time-range filter (TIRREDESIGN-11)", () => {
test("URL with time-range suffix filters the list (URL → state path)", async ({
@@ -16,7 +27,8 @@ test.describe("Onlineboard time-range filter (TIRREDESIGN-11)", () => {
consoleMessages,
}) => {
// Baseline: no filter
await page.goto(ROUTE_URL);
const baseUrl = routeUrl();
await page.goto(baseUrl);
await expect(page.locator(".flight-card").first()).toBeVisible({
timeout: 15000,
});
@@ -24,7 +36,16 @@ test.describe("Onlineboard time-range filter (TIRREDESIGN-11)", () => {
expect(baseline).toBeGreaterThan(15);
// Filtered: 14:0018:00
await page.goto(`${ROUTE_URL}-14001800`);
const filteredRequest = page.waitForRequest((request) => {
const url = new URL(request.url());
return (
url.pathname.endsWith("/api/flights/v1.1/ru/board") &&
url.searchParams.get("timeFrom") === "14:00:00" &&
url.searchParams.get("timeTo") === "18:00:00"
);
});
await page.goto(`${baseUrl}-14001800`);
await filteredRequest;
await expect(page.locator(".flight-card").first()).toBeVisible({
timeout: 15000,
});
@@ -41,32 +62,18 @@ test.describe("Onlineboard time-range filter (TIRREDESIGN-11)", () => {
page,
consoleMessages,
}) => {
await page.goto(ROUTE_URL);
await page.goto(routeUrl());
await expect(page.locator(".flight-card").first()).toBeVisible({
timeout: 15000,
});
// Drag the start thumb roughly to the 50 % mark (= 12:00).
// Click the track near the 50 % mark. PrimeReact moves the nearest
// handle, which is the start handle while the range is 00:00-24:00.
const slider = page.locator(".p-slider").first();
const startThumb = page.locator(".p-slider-handle-start").first();
const sliderBox = await slider.boundingBox();
const thumbBox = await startThumb.boundingBox();
expect(sliderBox && thumbBox).toBeTruthy();
if (!sliderBox || !thumbBox) return;
const fromX = thumbBox.x + thumbBox.width / 2;
const fromY = thumbBox.y + thumbBox.height / 2;
// 50 % position along the track
const targetX = sliderBox.x + sliderBox.width * 0.5;
await page.mouse.move(fromX, fromY);
await page.mouse.down();
// Step the move a few times so PrimeReact's mousemove handler picks it up.
for (let i = 1; i <= 10; i++) {
const x = fromX + ((targetX - fromX) * i) / 10;
await page.mouse.move(x, fromY);
}
await page.mouse.up();
expect(sliderBox).toBeTruthy();
if (!sliderBox) return;
await slider.click({ position: { x: sliderBox.width * 0.5, y: sliderBox.height / 2 } });
// The thumb should have left 0 — exact value depends on snap-to-step.
const labelAfterDrag = await page
@@ -79,6 +86,6 @@ test.describe("Onlineboard time-range filter (TIRREDESIGN-11)", () => {
await page.locator('[data-testid="search-submit"]').click();
// URL must have grown a time suffix.
await expect(page).toHaveURL(/\/onlineboard\/route\/MOW-LED-20260423-\d{8}/);
await expect(page).toHaveURL(/\/onlineboard\/route\/MOW-LED-\d{8}-\d{8}/);
});
});