Files
zemion eb7ff7ae8f
Verify / verify (push) Canceled after 0s
Release Contact Tools 0.2.0
2026-09-02 11:45:06 +02:00

61 lines
2.2 KiB
TypeScript

import { expect, test, type Page } from "@playwright/test";
const ORIGIN = "http://127.0.0.1:4173";
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/contact/");
await expect(
page.getByRole("banner").getByRole("heading", { name: "Contact Tools" }),
).toBeVisible();
expect(external).toEqual([]);
expect(errors).toEqual([]);
});
test("preserves contacts on parse failure and generates QR locally", async ({
page,
}) => {
const external = await localOnly(page);
await page.goto("/deep/nested/contact/");
await expect(page.getByRole("heading", { name: "2 contacts" })).toBeVisible();
await page.getByLabel("vCard source").fill("not a card");
await page.getByRole("button", { name: "Parse safely" }).click();
await expect(page.getByRole("alert")).toContainText("No complete");
await page.getByRole("button", { name: "Contact QR" }).click();
await page.getByRole("button", { name: "Generate local QR preview" }).click();
await expect(page.getByRole("img", { name: /QR code for/u })).toBeVisible();
expect(external).toEqual([]);
});
test("serves release identity and hardened headers", async ({ request }) => {
const index = await request.get("/deep/nested/contact/");
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/contact/toolbox-app.json");
await expect(manifest.json()).resolves.toMatchObject({
id: "de.add-ideas.contact-tools",
version: "0.2.0",
entry: "./",
privacy: { processing: "local", telemetry: false },
});
});