import { expect, test } from "@playwright/test"; for (const path of ["/", "/deep/nested/device/"]) { test(`inspects capabilities locally at ${path}`, async ({ page }) => { const external: string[] = []; page.on("request", (request) => { if (!request.url().startsWith("http://127.0.0.1:4213")) external.push(request.url()); }); await page.goto(path); await expect( page.getByRole("heading", { name: "Inspect capabilities, not identity.", }), ).toBeVisible(); await expect( page.getByRole("heading", { name: "Browser and display capabilities" }), ).toBeVisible(); await page.getByRole("button", { name: "Read permission states" }).click(); await expect(page.locator(".probe-result").first()).toBeVisible(); await expect(page.getByLabel("Redacted JSON report")).not.toContainText( "userAgent", ); expect(external).toEqual([]); }); } test("keeps the installed capability lab available offline", async ({ page, context, }) => { await page.goto("/"); await page.evaluate(async () => navigator.serviceWorker.ready); await page.reload(); await context.setOffline(true); try { await page.reload(); await expect( page.getByRole("heading", { name: "Inspect capabilities, not identity.", }), ).toBeVisible(); } finally { await context.setOffline(false); } });