fix: harden saved plan normalization

This commit is contained in:
ik
2026-09-21 18:13:51 +07:00
parent 675cd8ba4e
commit 2d56a67461
3 changed files with 27 additions and 3 deletions
+22
View File
@@ -54,3 +54,25 @@ test("plan caps imported entries, stays printable and fits narrow viewports", as
await expect(page.getByRole("button", { name: "Печать / PDF" })).toBeHidden();
await expect(page.locator(".plan-card")).toHaveCount(5);
});
test("plan preserves a real zero confidence and bounds imported text", async ({ page }) => {
await page.goto("/plan");
await page.evaluate(() => localStorage.setItem("rf4spotter:fishing-plan", JSON.stringify([{
key: "/spots/" + "x".repeat(600),
waterbody: "Вьюнок",
coordinates: "6331:6332",
baits: "Приманка",
confidence: "0",
risk: "Малая выборка",
method: "Спиннинг",
retrieve: "равномерная",
oversized: "x".repeat(5000),
}])));
await page.reload();
await expect(page.getByText(/Доверие: 0%/)).toBeVisible();
const stored = await page.evaluate(() => JSON.parse(localStorage.getItem("rf4spotter:fishing-plan") || "[]"));
expect(stored[0].key.length).toBeLessThanOrEqual(512);
expect(stored[0].confidence).toBe("0");
expect(stored[0].oversized).toBeUndefined();
});