import { test, expect } from "@playwright/test"; import { createServer, type ViteDevServer } from "vite"; let server: ViteDevServer; let url: string; test.beforeAll(async () => { server = await createServer({ server: { host: "127.0.0.1", port: 0 } }); await server.listen(); url = server.resolvedUrls!.local[0]! + "e2e/fixtures/archive-repair.html"; }); test.afterAll(async () => { await server?.close(); }); test("reviewer selects a correction, sees pending activation and retries on desktop/mobile", async ({ page }) => { const errors: string[] = []; page.on("pageerror", e => errors.push(e.message)); await page.setViewportSize({ width: 1280, height: 900 }); await page.goto(url); await expect(page.getByRole("region", { name: "Archive conflict repair" })).toBeVisible(); await page.screenshot({ path: "/private/tmp/thothii-x1-repair-desktop.png", fullPage: true }); await page.setViewportSize({ width: 390, height: 844 }); expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(390); await page.screenshot({ path: "/private/tmp/thothii-x1-repair-mobile.png", fullPage: true }); await page.getByRole("button", { name: "Apply this correction to Evidence" }).click(); await expect(page.getByRole("status").filter({ hasText: "Correction saved" })).toContainText("activation is incomplete"); await page.getByRole("button", { name: "Retry selected correction" }).click(); await expect(page.getByRole("status").filter({ hasText: "Correction saved" })).toContainText("active in the archive index"); const responses = JSON.parse(await page.locator("#response").textContent() || "[]"); expect(responses.map((r: { choices: string[] }) => r.choices)).toEqual([["e"], ["e"]]); expect(errors).toEqual([]); });