Release Minimize Tools 0.1.0
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
const ORIGIN = "http://127.0.0.1:4200";
|
||||
|
||||
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("minimizes a JSON failure at a nested path without network access", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1800, height: 1000 });
|
||||
const external = await watchLocalOnly(page);
|
||||
await page.goto("/deep/nested/minimize/");
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Minimize Tools" }),
|
||||
).toBeVisible();
|
||||
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||
await expect(page.getByLabel("Minimized result")).toHaveValue(
|
||||
'{"request":{"id":0}}',
|
||||
);
|
||||
await expect(page.getByText(/→.*bytes · \d+ tests/u)).toBeVisible();
|
||||
expect(external).toEqual([]);
|
||||
expect(
|
||||
await page
|
||||
.locator(".toolbox-shell__main")
|
||||
.evaluate((node) => getComputedStyle(node).width),
|
||||
).toBe("1440px");
|
||||
});
|
||||
|
||||
test("runs regular expressions in a worker and keeps the complete result", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/minimize/");
|
||||
await page.getByLabel("Structure").selectOption("text");
|
||||
await page.getByLabel("Failure predicate").selectOption("regex-matches");
|
||||
await page.getByLabel("Failing input").fill("noise TARGET more noise");
|
||||
await page.getByLabel("Regular expression").fill("TARGET");
|
||||
await page.getByLabel(/Slow threshold/u).fill("100");
|
||||
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||
await expect(page.getByLabel("Minimized result")).toHaveValue("TARGET");
|
||||
await page.getByLabel("Regular expression").fill("[");
|
||||
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||
await expect(page.getByRole("alert")).toContainText("retained");
|
||||
await expect(page.getByLabel("Minimized result")).toHaveValue("TARGET");
|
||||
});
|
||||
|
||||
test("reduces XML against the restricted browser XSLT predicate", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/minimize/");
|
||||
await page.getByRole("button", { name: "XSLT failure" }).click();
|
||||
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||
await expect(page.getByLabel("Minimized result")).toContainText("BOOM");
|
||||
await expect(page.getByLabel("Minimized result")).not.toContainText(
|
||||
"metadata",
|
||||
);
|
||||
});
|
||||
|
||||
test("downloads the minimized case and exact predicate report", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/minimize/");
|
||||
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||
await expect(page.getByLabel("Minimized result")).not.toHaveValue("");
|
||||
const caseDownload = page.waitForEvent("download");
|
||||
await page.getByRole("button", { name: "Download case" }).click();
|
||||
expect((await caseDownload).suggestedFilename()).toBe("minimized.json");
|
||||
const reportDownload = page.waitForEvent("download");
|
||||
await page.getByRole("button", { name: "Download report" }).click();
|
||||
expect((await reportDownload).suggestedFilename()).toBe(
|
||||
"minimization-report.json",
|
||||
);
|
||||
});
|
||||
|
||||
test("integrates help, themes, identity, headers and offline reload", async ({
|
||||
page,
|
||||
request,
|
||||
context,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/minimize/");
|
||||
await page.getByRole("button", { name: "Help" }).click();
|
||||
await expect(
|
||||
page.getByRole("dialog", { name: "About Minimize Tools" }),
|
||||
).toContainText("predicate");
|
||||
await page.keyboard.press("Escape");
|
||||
await page.getByRole("button", { name: "Personalize" }).click();
|
||||
await page.getByRole("button", { name: "Dark" }).click();
|
||||
await expect(page.locator(".toolbox-shell").first()).toHaveAttribute(
|
||||
"data-toolbox-theme",
|
||||
"dark",
|
||||
);
|
||||
expect(
|
||||
await page.evaluate(async () =>
|
||||
Boolean(await navigator.serviceWorker.ready),
|
||||
),
|
||||
).toBe(true);
|
||||
const index = await request.get("/deep/nested/minimize/");
|
||||
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/minimize/toolbox-app.json");
|
||||
await expect(manifest.json()).resolves.toMatchObject({
|
||||
id: "de.add-ideas.minimize-tools",
|
||||
version: "0.1.0",
|
||||
privacy: { processing: "local", telemetry: false },
|
||||
});
|
||||
await context.setOffline(true);
|
||||
await page.reload();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Minimize Tools" }),
|
||||
).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user