import { expect, test } from "@playwright/test";
import { createToolcraftSvgFixtureDownload } from "./svg-download-test-fixtures";
import { inspectToolcraftSvgDownload } from "./svg-artifact-inspection";
const validSvg = `
`;
test("inspects strict self-contained vector SVG bytes", async ({
page,
}) => {
await page.goto("/");
const download = await createToolcraftSvgFixtureDownload(page, validSvg);
const result = await inspectToolcraftSvgDownload({ download, page });
expect(result.inspection).toMatchObject({
backgroundColor: null,
height: 48,
kind: "svg",
mediaType: "image/svg+xml",
vectorElementCount: 1,
viewBox: [0, 0, 64, 48],
width: 64,
});
expect(result.inspection.byteLength).toBeGreaterThan(0);
expect(result.inspection.contentHash).toMatch(/^[a-f0-9]{64}$/u);
});
test("inspects the exact runtime background before product vectors", async ({
page,
}) => {
await page.goto("/");
const source = `
`;
const download = await createToolcraftSvgFixtureDownload(page, source);
const result = await inspectToolcraftSvgDownload({ download, page });
expect(result.inspection.backgroundColor).toBe("#112233");
expect(result.inspection.vectorElementCount).toBe(1);
expect(result.inspection.viewBox).toEqual([-4, 2, 64, 48]);
});
const invalidSvgCases = [
{
message: "not valid XML",
name: "valueless XML attribute",
source:
'',
},
{
message: "namespaced