import { expect, test, type Page } from "@playwright/test"; import { readFile } from "node:fs/promises"; import { unzipSync, strFromU8 } from "fflate"; const ORIGIN = "http://127.0.0.1:4202"; async function watchLocalOnly(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 at a nested path, stays local and uses the shared width", async ({ page, }) => { await page.setViewportSize({ width: 1800, height: 1000 }); const external = await watchLocalOnly(page); await page.goto("/deep/nested/label/"); await expect( page.getByRole("heading", { name: "Label Tools" }), ).toBeVisible(); await expect(page.getByText("2 labels ยท 1 page")).toBeVisible(); expect(external).toEqual([]); expect( await page .locator(".toolbox-shell__main") .evaluate((node) => getComputedStyle(node).width), ).toBe("1440px"); }); test("merges inert CSV and exports vector SVG and deterministic ZIP", async ({ page, }) => { await page.goto("/deep/nested/label/"); await page .getByTestId("merge-data") .fill( "name,subtitle,address,code\n,Local,No upload,SAFE-1", ); await page.getByRole("button", { name: "Parse and keep rows" }).click(); await expect(page.getByText(/1 data row parsed locally/iu)).toBeVisible(); const svgDownload = page.waitForEvent("download"); await page.getByRole("button", { name: "Current SVG" }).click(); const svgPath = await (await svgDownload).path(); const svg = await readFile(svgPath!, "utf8"); expect(svg).toContain("<script>alert"); expect(svg).not.toContain("