@@ -83,6 +83,25 @@ test("shows CSV losses and retains evidence after invalid source", async ({
|
||||
await expect(output).toHaveValue(previous);
|
||||
});
|
||||
|
||||
test("identifies bounded signatures and exposes the portable evidence contract", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/format-lab/");
|
||||
await page
|
||||
.locator('input[type="file"]')
|
||||
.first()
|
||||
.setInputFiles("tests/fixtures/signature.pdf");
|
||||
await expect(page.getByText(/PDF \(strong: %PDF- header/u)).toBeVisible();
|
||||
await page.getByText("Portable evidence JSON", { exact: true }).click();
|
||||
const evidence = await page
|
||||
.getByRole("textbox", { name: "Evidence report", exact: true })
|
||||
.inputValue();
|
||||
expect(JSON.parse(evidence)).toMatchObject({
|
||||
contractVersion: 1,
|
||||
provenance: { execution: "local-browser", networkRequired: false },
|
||||
});
|
||||
});
|
||||
|
||||
test("integrates help, themes, identity, headers and offline reload", async ({
|
||||
page,
|
||||
request,
|
||||
@@ -115,7 +134,7 @@ test("integrates help, themes, identity, headers and offline reload", async ({
|
||||
);
|
||||
await expect(manifest.json()).resolves.toMatchObject({
|
||||
id: "de.add-ideas.format-lab",
|
||||
version: "0.1.0",
|
||||
version: "0.2.0",
|
||||
privacy: { processing: "local", telemetry: false },
|
||||
});
|
||||
await context.setOffline(true);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("keeps the primary workspace inside a narrow viewport", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/format-lab/");
|
||||
await expect(page.locator("main").first()).toBeVisible();
|
||||
await expect(
|
||||
page.locator("main .loading, main .workbench-loading"),
|
||||
).toHaveCount(0);
|
||||
|
||||
const widths = await page.evaluate(() => ({
|
||||
content: document.documentElement.scrollWidth,
|
||||
viewport: document.documentElement.clientWidth,
|
||||
}));
|
||||
expect(widths.viewport).toBeLessThanOrEqual(430);
|
||||
expect(widths.content).toBeLessThanOrEqual(widths.viewport + 1);
|
||||
});
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
%PDF-1.7
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { findRoutes, properties } from "../../src/lab/catalog";
|
||||
import { parseData, runRoundTrip, serializeData } from "../../src/lab/data";
|
||||
import { parseEvidence, serializeEvidence } from "../../src/lab/evidence";
|
||||
|
||||
const all = properties.data.map((property) => property.id);
|
||||
const sample = JSON.stringify([
|
||||
@@ -29,6 +30,13 @@ describe("structured data lab", () => {
|
||||
property: "metadata",
|
||||
status: "not-tested",
|
||||
});
|
||||
expect(parseEvidence(serializeEvidence(result.evidence))).toEqual(
|
||||
result.evidence,
|
||||
);
|
||||
expect(result.evidence).toMatchObject({
|
||||
contractVersion: 1,
|
||||
provenance: { execution: "local-browser", networkRequired: false },
|
||||
});
|
||||
});
|
||||
|
||||
it("exposes CSV type, null and nested-value changes", () => {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { exportCorpusFiles } from "../../src/lab/corpus";
|
||||
import {
|
||||
formatSignatures,
|
||||
identifyBySignature,
|
||||
} from "../../src/lab/signatures";
|
||||
|
||||
describe("format signatures and corpus", () => {
|
||||
it("distinguishes masked RIFF forms and container-only evidence", () => {
|
||||
const wav = Uint8Array.of(
|
||||
0x52,
|
||||
0x49,
|
||||
0x46,
|
||||
0x46,
|
||||
0x24,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0x57,
|
||||
0x41,
|
||||
0x56,
|
||||
0x45,
|
||||
);
|
||||
expect(identifyBySignature(wav).map((item) => item.format)).toContain(
|
||||
"wav",
|
||||
);
|
||||
expect(identifyBySignature(wav).map((item) => item.format)).not.toContain(
|
||||
"webp",
|
||||
);
|
||||
expect(
|
||||
identifyBySignature(Uint8Array.of(0x50, 0x4b, 0x03, 0x04))[0],
|
||||
).toMatchObject({ format: "zip", confidence: "container" });
|
||||
});
|
||||
|
||||
it("ships a broad, deterministic structured regression corpus", () => {
|
||||
expect(formatSignatures.length).toBeGreaterThanOrEqual(20);
|
||||
const first = exportCorpusFiles();
|
||||
expect(first).toEqual(exportCorpusFiles());
|
||||
expect(first.map((file) => file.path)).toEqual(
|
||||
expect.arrayContaining([
|
||||
"structured/typed.json",
|
||||
"structured/text-cells.csv",
|
||||
"corpus-manifest.json",
|
||||
]),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user