53 lines
2.1 KiB
TypeScript
53 lines
2.1 KiB
TypeScript
import { test, expect } from "./fixtures/console-gate";
|
|
import { addDays, formatYmd } from "./helpers/dates";
|
|
|
|
// TIRREDESIGN-5: the search-history sidebar header must read
|
|
// "Ранее искали" (not "Вы искали"). The block exists on Schedule
|
|
// and Online-Board start pages once the user has run at least one
|
|
// search; we seed a synthetic history entry via localStorage so
|
|
// the test is deterministic.
|
|
|
|
// Matches `searchHistoryItemSchema` in useSearchHistory.ts.
|
|
async function seedHistory(page: import("@playwright/test").Page) {
|
|
const dateFrom = formatYmd(new Date());
|
|
const dateTo = formatYmd(addDays(new Date(), 6));
|
|
const seed = [
|
|
{
|
|
type: "schedule-route" as const,
|
|
url: `/ru-ru/schedule/route/MOW-LED-${dateFrom}-${dateTo}`,
|
|
label: "Москва — Санкт-Петербург",
|
|
params: {
|
|
departure: "MOW",
|
|
arrival: "LED",
|
|
dateFrom,
|
|
dateTo,
|
|
},
|
|
},
|
|
];
|
|
// Storage uses sessionStorage with the `afl_` namespace prefix and is
|
|
// keyed `history_${lang}` — see src/shared/hooks/useSearchHistory.ts.
|
|
await page.addInitScript((items) => {
|
|
window.sessionStorage.setItem("afl_history_ru", JSON.stringify(items));
|
|
}, seed);
|
|
}
|
|
|
|
test.describe("Search-history label is 'Ранее искали' (TIRREDESIGN-5)", () => {
|
|
test("Schedule start page", async ({ page, consoleMessages }) => {
|
|
await seedHistory(page);
|
|
await page.goto("/ru-ru/schedule");
|
|
const block = page.getByTestId("search-history");
|
|
await expect(block).toBeVisible({ timeout: 15000 });
|
|
await expect(block).toContainText("Ранее искали");
|
|
await expect(block).not.toContainText("Вы искали");
|
|
});
|
|
|
|
test("Online-Board start page", async ({ page, consoleMessages }) => {
|
|
await seedHistory(page);
|
|
await page.goto("/ru-ru/onlineboard");
|
|
const block = page.getByTestId("search-history");
|
|
await expect(block).toBeVisible({ timeout: 15000 });
|
|
await expect(block).toContainText("Ранее искали");
|
|
await expect(block).not.toContainText("Вы искали");
|
|
});
|
|
});
|