import { expect, test } from "@playwright/test"; import { installMockApi } from "./mockApi"; test("overview renders run strip, KPIs, charts, top repos and reasons", async ({ page }) => { await installMockApi(page); await page.goto("/"); // Run strip await expect(page.locator(".overview-run-strip").getByText("run_0002")).toBeVisible(); await expect(page.getByText("delta sync")).toBeVisible(); // KPI cards with fixture values await expect(page.getByText("VRPs")).toBeVisible(); await expect(page.getByText("987")).toBeVisible(); await expect(page.locator(".kpi-grid").getByText("Rejected")).toBeVisible(); // Charts render (recharts svg) await expect(page.locator(".recharts-responsive-container").first()).toBeVisible(); // Top repositories table await expect(page.getByRole("cell", { name: "repo-a.example" })).toBeVisible(); // Top reject reasons await expect(page.getByText("certificate expired: notAfter")).toBeVisible(); }); test("overview does not request the global object list (first-screen discipline)", async ({ page, }) => { await installMockApi(page); const objectListRequests: string[] = []; page.on("request", (req) => { const url = new URL(req.url()); if (/\/api\/v1\/runs\/[^/]+\/objects$/.test(url.pathname)) { objectListRequests.push(req.url()); } }); await page.goto("/"); await expect(page.getByText("987")).toBeVisible(); expect(objectListRequests).toEqual([]); }); test("overview drill-down: repo row navigates to repository detail", async ({ page }) => { await installMockApi(page); await page.goto("/"); await page.getByRole("cell", { name: "repo-b.example" }).click(); await expect(page).toHaveURL(/\/repositories\/repo-b2c3d4e5f6a7/); await expect(page.getByRole("heading", { name: "repo-b.example" })).toBeVisible(); }); test("overview drill-down: reason navigates to filtered validation page", async ({ page }) => { await installMockApi(page); await page.goto("/"); await page.getByRole("link", { name: /manifest stale/ }).click(); await expect(page).toHaveURL(/\/validation\?reason=manifest/); await expect(page.getByRole("heading", { name: "Validation" })).toBeVisible(); }); test("overview shows an explicit error state when the run cannot be loaded", async ({ page }) => { await installMockApi(page, { failLatestRun: true }); await page.goto("/"); await expect(page.getByRole("alert")).toContainText("Failed to load the latest run"); });