Files
rf4-spotter/apps/web/tests/plan-page.spec.ts
T
ik 9569f4768a
CI / backend-and-migrations (push) Waiting to run
CI / astro-build (push) Waiting to run
CI / dependency-audit (push) Waiting to run
CI / compose-e2e (push) Waiting to run
feat: share local fishing plans
2026-09-20 20:17:08 +07:00

29 lines
2.0 KiB
TypeScript

import { expect, test } from "@playwright/test";
test("saved spot appears on the plan page and can be removed or cleared", async ({ page }) => {
await page.goto("/spots/vyunok-6331x6332");
await page.evaluate(() => localStorage.setItem("rf4spotter:fishing-plan", JSON.stringify([{ key: "/spots/vyunok-6331x6332", waterbody: "Вьюнок", coordinates: "6331:6332", baits: "Тестовая приманка", freshness: "2026-09-20T12:55:11.236309Z", confidence: "24" }])));
await page.goto("/plan");
await expect(page.getByRole("heading", { name: "Вьюнок" })).toBeVisible();
await expect(page.getByText("6331:6332")).toBeVisible();
await expect(page.getByText("1 из 5 точек")).toBeVisible();
await page.getByRole("button", { name: "Убрать" }).click();
await expect(page.getByRole("heading", { name: "План пока пуст" })).toBeVisible();
await page.goto("/spots/vyunok-6331x6332");
await page.evaluate(() => localStorage.setItem("rf4spotter:fishing-plan", JSON.stringify([{ key: "/spots/vyunok-6331x6332", waterbody: "Вьюнок", coordinates: "6331:6332", baits: "Тестовая приманка", freshness: "", confidence: "" }])));
await page.goto("/plan");
await page.getByRole("button", { name: "Очистить план" }).click();
await expect(page.getByRole("heading", { name: "План пока пуст" })).toBeVisible();
});
test("plan can be restored from a shareable URL", async ({ page }) => {
const shared = encodeURIComponent(JSON.stringify([{ key: "/spots/vyunok-6331x6332", waterbody: "Вьюнок", coordinates: "6331:6332", baits: "Тестовая приманка", freshness: "", confidence: "" }]));
await page.goto(`/plan?plan=${shared}`);
await expect(page.getByRole("heading", { name: "Вьюнок" })).toBeVisible();
await expect(page.getByRole("button", { name: "Поделиться планом" })).toBeVisible();
await expect(page.getByText("1 из 5 точек")).toBeVisible();
});