From efd5f7b1722c5186ca36cc20a437f268eb561ae0 Mon Sep 17 00:00:00 2001 From: IK Date: Wed, 16 Sep 2026 20:02:47 +0700 Subject: [PATCH] test: cover admin media review smoke --- apps/web/tests/smoke.spec.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/apps/web/tests/smoke.spec.ts b/apps/web/tests/smoke.spec.ts index 7ac8620..3ce3b65 100644 --- a/apps/web/tests/smoke.spec.ts +++ b/apps/web/tests/smoke.spec.ts @@ -76,6 +76,7 @@ for (const viewport of [{ name: "desktop", width: 1280, height: 900 }, { name: " const path = new URL(request.url()).pathname; if (path.endsWith("/fishes")) return route.fulfill({ json: [{ slug: "pike", name_ru: "Щука" }] }); if (path.endsWith("/waterbodies")) return route.fulfill({ json: [{ slug: "kuori", name_ru: "Куори" }] }); + if (path.endsWith("/source-status")) return route.fulfill({ json: [{ source_system: "rf4db", name: "RF4DB", status: "healthy", last_started_at: null, last_success_at: null, observations: 1 }] }); if (path.endsWith("/admin/external-observations")) return route.fulfill({ json: [{ id: "10000000-0000-0000-0000-000000000001", source_system: "rf4db", source_external_id: "fixture-1", source_url: "https://rf4db.com/fixture-1", fish_name: "Pike", waterbody_name: "Kuori", x: 72, y: 84, weight_g: null, status: "staged", fish_slug: null, waterbody_slug: null, review_note: null }] }); return route.fulfill({ status: 404 }); }); @@ -90,6 +91,26 @@ for (const viewport of [{ name: "desktop", width: 1280, height: 900 }, { name: " const dimensions = await page.evaluate(() => ({ width: document.documentElement.clientWidth, scroll: document.documentElement.scrollWidth })); expect(dimensions.scroll).toBeLessThanOrEqual(dimensions.width); }); + + test(`admin media review is read-only on ${viewport.name}`, async ({ page }) => { + await page.setViewportSize(viewport); + let mutations = 0; + await page.route("**/api/v1/**", async route => { + const request = route.request(); + if (request.method() !== "GET") mutations += 1; + const path = new URL(request.url()).pathname; + if (path.endsWith("/admin/media/catalog")) return route.fulfill({ json: [{ id: "a".repeat(64), status: "upgrade_stored", entity_type: "fish", entity_key: "fish:pike", label: "Щука", width: 1024, height: 1024, content_type: "image/webp", image_url: "/api/v1/admin/media/assets/" + "a".repeat(64), source_system: "rf4db", source_url: "https://rf4db.com/fish/pike", derivatives: [{ role: "card", format: "webp", width: 256, height: 256 }] }] }); + return route.fulfill({ status: 404 }); + }); + await page.goto("/admin/media"); + await page.getByLabel("Административный токен").fill("test-token-not-sent"); + await page.getByRole("button", { name: "Открыть медиатеку" }).click(); + await expect(page.locator(".media-library__card")).toContainText("Щука"); + await expect(page.locator(".media-library__card")).toContainText("upgrade_stored"); + expect(mutations).toBe(0); + const dimensions = await page.evaluate(() => ({ width: document.documentElement.clientWidth, scroll: document.documentElement.scrollWidth })); + expect(dimensions.scroll).toBeLessThanOrEqual(dimensions.width); + }); } test("public pages fit the narrow viewport and expose the skip link", async ({ page }) => {