27 lines
1.5 KiB
TypeScript
27 lines
1.5 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
test("home makes the selected query context explicit and shareable", async ({ page }) => {
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
await page.goto("/?waterbody=kuori&fish=lake-trout&hours=72&sort=freshness");
|
|
|
|
await expect(page.getByRole("heading", { name: "Озёрная форель · Куори" })).toBeVisible();
|
|
await expect(page.getByText("72 часа · Сначала свежие")).toBeVisible();
|
|
await expect(page.getByRole("link", { name: "Сбросить запрос" })).toHaveAttribute("href", "/#results");
|
|
await expect(page.getByLabel("Водоём")).toHaveValue("kuori");
|
|
await expect(page.getByLabel("Рыба")).toHaveValue("lake-trout");
|
|
await expect(page.getByLabel("Период")).toHaveValue("72");
|
|
await expect(page.getByLabel("Сначала")).toHaveValue("freshness");
|
|
|
|
const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
|
|
expect(overflow).toBeLessThanOrEqual(0);
|
|
});
|
|
|
|
test("empty filtered result offers a clear way back to the full dataset", async ({ page }) => {
|
|
await page.goto("/?waterbody=kuori&fish=lake-trout&hours=6&sort=freshness");
|
|
|
|
const emptyState = page.getByRole("heading", { name: "Пока нет свежих данных" });
|
|
if (await emptyState.isVisible()) {
|
|
await expect(page.getByRole("link", { name: "Показать все данные" })).toHaveAttribute("href", "/#results");
|
|
}
|
|
});
|