import { expect, test, type Page } from "@playwright/test"; const ORIGIN = "http://127.0.0.1:4182"; async function localOnly(page: Page) { const external: string[] = []; await page.route("**/*", async (route) => { const url = new URL(route.request().url()); if (url.origin !== ORIGIN) { external.push(url.href); await route.abort(); } else await route.continue(); }); return external; } test("runs from a nested path without external requests", async ({ page }) => { const errors: string[] = []; page.on("pageerror", (error) => errors.push(error.message)); page.on("console", (message) => { if (message.type() === "error") errors.push(message.text()); }); const external = await localOnly(page); await page.goto("/deep/nested/log/"); await expect( page.getByRole("banner").getByRole("heading", { name: "Log Tools" }), ).toBeVisible(); await expect(page.getByText(/complete file is never loaded/u)).toBeVisible(); expect(external).toEqual([]); expect(errors).toEqual([]); }); test("streams, filters, correlates, and redacts the sample locally", async ({ page, }) => { const external = await localOnly(page); await page.goto("/deep/nested/log/"); await page.getByRole("button", { name: "Scan pasted log" }).click(); await expect( page.getByText(/Completed 4 lines with JSON Lines/u), ).toBeVisible(); await page.getByLabel("Literal search").fill("timeout"); await expect(page.getByText(/1 of 4 retained records match/u)).toBeVisible(); await page.getByRole("tab", { name: "Correlation" }).click(); await expect( page.getByRole("heading", { name: "Hourly timeline" }), ).toBeVisible(); await page.getByRole("tab", { name: "Redaction" }).click(); await expect(page.getByLabel("Redacted preview")).not.toContainText( "ada@example.test", ); expect(external).toEqual([]); }); test("keeps HTML-like log text inert", async ({ page }) => { await page.goto("/deep/nested/log/"); await page .getByLabel("Pasted log") .fill("2026-09-01T10:00:00Z ERROR "); await page.getByRole("button", { name: "Scan pasted log" }).click(); await expect( page .getByRole("table") .getByText("2026-09-01T10:00:00Z ERROR ", { exact: true, }), ).toBeVisible(); await expect(page.locator("img[src='x']")).toHaveCount(0); }); test("serves release identity and hardened headers", async ({ request }) => { const index = await request.get("/deep/nested/log/"); expect(index.ok()).toBe(true); expect(index.headers()["content-security-policy"]).toContain( "connect-src 'self'", ); expect(await index.text()).not.toMatch(/\b(?:src|href)=["']\//u); const manifest = await request.get("/deep/nested/log/toolbox-app.json"); await expect(manifest.json()).resolves.toMatchObject({ id: "de.add-ideas.log-tools", version: "0.1.0", entry: "./", privacy: { processing: "local", telemetry: false }, }); });