Release Schema Tools v0.1.0
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
const ORIGIN = "http://127.0.0.1:4181";
|
||||
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/schema/");
|
||||
await expect(
|
||||
page.getByRole("banner").getByRole("heading", { name: "Schema Tools" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByText("Five languages, deliberately different guarantees"),
|
||||
).toBeVisible();
|
||||
expect(external).toEqual([]);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
test("validates and traces a supplied local JSON Schema reference", async ({
|
||||
page,
|
||||
}) => {
|
||||
const external = await localOnly(page);
|
||||
await page.goto("/deep/nested/schema/");
|
||||
await page.getByRole("tab", { name: "Validate" }).click();
|
||||
await page.getByRole("button", { name: "Validate instance" }).click();
|
||||
await expect(page.getByText(/Instance is valid/u)).toBeVisible();
|
||||
await page.getByRole("tab", { name: "References" }).click();
|
||||
await expect(
|
||||
page.getByText("address.schema.json#/$defs/address", { exact: true }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("resolved", { exact: true })).toBeVisible();
|
||||
expect(external).toEqual([]);
|
||||
});
|
||||
|
||||
test("preserves the last successful report after a parse failure", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/schema/");
|
||||
await expect(page.getByText("2 documents · 1 reference")).toBeVisible();
|
||||
await page.getByLabel("Schema source").fill("not: [valid");
|
||||
await page.getByRole("button", { name: "Inspect workspace" }).click();
|
||||
await expect(page.getByRole("alert")).toContainText(
|
||||
"last successful report remains",
|
||||
);
|
||||
await expect(page.getByText("2 documents · 1 reference")).toBeVisible();
|
||||
});
|
||||
|
||||
test("serves release identity and hardened headers", async ({ request }) => {
|
||||
const index = await request.get("/deep/nested/schema/");
|
||||
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/schema/toolbox-app.json");
|
||||
await expect(manifest.json()).resolves.toMatchObject({
|
||||
id: "de.add-ideas.schema-tools",
|
||||
version: "0.1.0",
|
||||
entry: "./",
|
||||
privacy: { processing: "local", telemetry: false },
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user