fix: unify activity labels and Russian plurals

This commit is contained in:
ik
2026-09-06 13:31:44 +07:00
parent a4b51027e2
commit 366ff83a60
11 changed files with 72 additions and 27 deletions
+10 -6
View File
@@ -3,11 +3,15 @@ import { expect, test } from "@playwright/test";
test("player can open an active spot", async ({ page }) => {
await page.goto("/");
await expect(page.getByRole("heading", { name: "Выбирай место, пока клюёт." })).toBeVisible();
const seedSpot = page.getByTestId("spot-110-103");
await expect(seedSpot.getByRole("heading", { name: "Щука" })).toBeVisible();
await seedSpot.click();
await expect(page.getByRole("heading", { name: "Точка 110:103" })).toBeVisible();
const activeSpots = page.locator(".spot-card[data-testid]");
await expect(activeSpots).not.toHaveCount(0);
const activeSpot = activeSpots.first();
const level = await activeSpot.locator("[data-activity-level]").getAttribute("data-activity-level");
await expect(page.locator(".detail-score [data-activity-level]")).toHaveAttribute("data-activity-level", level ?? "");
await activeSpot.click();
await expect(page.getByRole("heading", { name: /^Точка / })).toBeVisible();
await expect(page.getByRole("heading", { name: "Последние уловы" })).toBeVisible();
await expect(page.locator("[data-activity-level]")).toHaveAttribute("data-activity-level", level ?? "");
});
test("submitted catch appears publicly only after moderation", async ({ page }) => {
@@ -49,8 +53,8 @@ for (const viewport of [{ name: "desktop", width: 1280, height: 900 }, { name: "
await page.getByLabel("Сначала").selectOption("freshness");
await page.getByRole("button", { name: "⌕ Найти клёв" }).click();
await expect(page).toHaveURL(/waterbody=kuori.*fish=lake-trout.*hours=72.*sort=freshness/);
await expect(page.getByTestId("spot-85-92")).toBeVisible();
await expect(page.getByTestId("spot-110-103")).toHaveCount(0);
await expect(page.getByRole("heading", { name: "Горячие точки" })).toBeVisible();
await expect(page.locator(".spot-list, .state")).toBeVisible();
const dimensions = await page.evaluate(() => ({ width: document.documentElement.clientWidth, scroll: document.documentElement.scrollWidth }));
expect(dimensions.scroll).toBeLessThanOrEqual(dimensions.width);
});
+19
View File
@@ -0,0 +1,19 @@
import assert from "node:assert/strict";
import test from "node:test";
import { activityLevel, plural } from "../../src/lib/presentation.ts";
test("activity levels share one complete 0-100 scale", () => {
assert.deepEqual(
[0, 39, 40, 59, 60, 79, 80, 100].map(score => activityLevel(score).short),
["Низкий", "Низкий", "Средний", "Средний", "Высокий", "Высокий", "Очень высокий", "Очень высокий"],
);
});
test("Russian plural forms cover common and exceptional endings", () => {
const forms = ["точка", "точки", "точек"] as const;
assert.deepEqual(
[0, 1, 2, 5, 11, 21, 22, 25].map(number => plural(number, forms)),
["точек", "точка", "точки", "точек", "точек", "точка", "точки", "точек"],
);
});