import { expect, test } from "@playwright/test"; import { Buffer } from "node:buffer"; for (const path of ["/", "/deep/nested/repro/"]) { test(`builds a manifest locally at ${path}`, async ({ page }) => { const external: string[] = []; page.on("request", (request) => { if (!request.url().startsWith("http://127.0.0.1:4182")) external.push(request.url()); }); await page.goto(path); await expect( page.getByRole("heading", { name: "Make a file set verifiable." }), ).toBeVisible(); await page .locator('input[type="file"]') .first() .setInputFiles({ name: "hello.txt", mimeType: "text/plain", buffer: Buffer.from("hello"), }); await page.getByRole("button", { name: "Build manifest" }).click(); await expect(page.getByLabel("Generated manifest")).toHaveValue( /hello\.txt/u, ); await page .getByRole("button", { name: "Generate one-time key and sign" }) .click(); await expect(page.getByLabel("Signature envelope")).toHaveValue( /ECDSA-P256-SHA256/u, ); await page.getByRole("button", { name: "Verify envelope" }).click(); await expect( page.getByText( "Signature is valid for this exact manifest and public key.", ), ).toBeVisible(); expect(external).toEqual([]); }); } test("keeps the installed application 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: "Make a file set verifiable." }), ).toBeVisible(); } finally { await context.setOffline(false); } });