Files
repro-tools/tests/browser/app.spec.ts
T
zemion bf5b72938a
Verify / verify (push) Canceled after 0s
Release Repro Tools 0.2.0
2026-09-02 07:40:24 +02:00

96 lines
2.8 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { Buffer } from "node:buffer";
import { strToU8, zipSync } from "fflate";
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);
}
});
test("compares expanded ZIP evidence and recognizes CycloneDX locally", async ({
page,
}) => {
await page.goto("/");
const zip = zipSync({ "inside.txt": strToU8("same content") });
await page.locator('input[accept="application/zip,.zip"]').setInputFiles({
name: "sample.zip",
mimeType: "application/zip",
buffer: Buffer.from(zip),
});
await expect(page.getByLabel("Archive content manifest")).toHaveValue(
/inside\.txt/u,
);
await page
.locator('input[type="file"]')
.first()
.setInputFiles({
name: "bom.cdx.json",
mimeType: "application/json",
buffer: Buffer.from(
JSON.stringify({
bomFormat: "CycloneDX",
specVersion: "1.6",
components: [{ name: "demo" }],
}),
),
});
await page.getByRole("button", { name: "Build manifest" }).click();
await page.getByRole("button", { name: "Build provenance evidence" }).click();
await expect(
page.getByRole("cell", { name: "CycloneDX JSON" }),
).toBeVisible();
});