test: harden saved plan mobile UX
This commit is contained in:
@@ -26,3 +26,29 @@ test("plan can be restored from a shareable URL", async ({ page }) => {
|
||||
await expect(page.getByRole("button", { name: "Поделиться планом" })).toBeVisible();
|
||||
await expect(page.getByText("1 из 5 точек")).toBeVisible();
|
||||
});
|
||||
|
||||
test("plan caps imported entries, stays printable and fits narrow viewports", async ({ page }) => {
|
||||
const plan = Array.from({ length: 6 }, (_, index) => ({
|
||||
key: `/spots/vyunok-6331x633${index + 2}`,
|
||||
waterbody: "Вьюнок",
|
||||
coordinates: `6331:633${index + 2}`,
|
||||
baits: "Тестовая приманка",
|
||||
freshness: "",
|
||||
confidence: "",
|
||||
}));
|
||||
|
||||
await page.goto("/plan");
|
||||
await page.evaluate((value) => localStorage.setItem("rf4spotter:fishing-plan", JSON.stringify(value)), plan);
|
||||
await page.reload();
|
||||
|
||||
await expect(page.getByText("5 из 5 точек")).toBeVisible();
|
||||
await expect(page.locator(".plan-card")).toHaveCount(5);
|
||||
for (const width of [320, 390]) {
|
||||
await page.setViewportSize({ width, height: 800 });
|
||||
const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
|
||||
expect(overflow, `${width}px plan overflows`).toBeLessThanOrEqual(0);
|
||||
}
|
||||
await page.emulateMedia({ media: "print" });
|
||||
await expect(page.getByRole("button", { name: "Печать / PDF" })).toBeHidden();
|
||||
await expect(page.locator(".plan-card")).toHaveCount(5);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user