Release Subtitle Tools 0.1.0
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
const ORIGIN = "http://127.0.0.1:4197";
|
||||
async function localOnly(page: Page) {
|
||||
const external: string[] = [];
|
||||
await page.route("**/*", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
if (
|
||||
(url.protocol === "http:" || url.protocol === "https:") &&
|
||||
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/subtitle/");
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Subtitle Tools" }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("No network requests")).toBeVisible();
|
||||
expect(external).toEqual([]);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
test("parses, validates, edits and converts the example", async ({ page }) => {
|
||||
const external = await localOnly(page);
|
||||
await page.goto("/deep/nested/subtitle/");
|
||||
await expect(page.getByText("SRT", { exact: true })).toBeVisible();
|
||||
await page.getByRole("tab", { name: "Cues & checks" }).click();
|
||||
await expect(page.getByText("overlap", { exact: true })).toBeVisible();
|
||||
await page.getByLabel("Text").fill("Edited locally");
|
||||
await page.getByRole("tab", { name: "Source & export" }).click();
|
||||
await page.getByLabel("Output format").selectOption("vtt");
|
||||
await expect(page.getByLabel("Export preview")).toHaveValue(/WEBVTT/u);
|
||||
await expect(page.getByLabel("Export preview")).toHaveValue(
|
||||
/Edited locally/u,
|
||||
);
|
||||
expect(external).toEqual([]);
|
||||
});
|
||||
|
||||
test("applies a bounded timing shift", async ({ page }) => {
|
||||
await page.goto("/deep/nested/subtitle/");
|
||||
await page.getByRole("tab", { name: "Timing" }).click();
|
||||
await page.getByLabel("Shift (ms)").fill("500");
|
||||
await page.getByRole("button", { name: "Apply timing transform" }).click();
|
||||
await page.getByRole("tab", { name: "Cues & checks" }).click();
|
||||
await expect(page.getByText(/00:00:01\.500/u).first()).toBeVisible();
|
||||
});
|
||||
|
||||
test("serves release identity and hardened local-only headers", async ({
|
||||
request,
|
||||
}) => {
|
||||
const index = await request.get("/deep/nested/subtitle/");
|
||||
expect(index.ok()).toBe(true);
|
||||
expect(index.headers()["content-security-policy"]).toContain(
|
||||
"connect-src 'self'",
|
||||
);
|
||||
expect(index.headers()["content-security-policy"]).not.toMatch(
|
||||
/connect-src[^;]*https?:/u,
|
||||
);
|
||||
expect(await index.text()).not.toMatch(/\b(?:src|href)=["']\//u);
|
||||
const manifest = await request.get("/deep/nested/subtitle/toolbox-app.json");
|
||||
await expect(manifest.json()).resolves.toMatchObject({
|
||||
id: "de.add-ideas.subtitle-tools",
|
||||
version: "0.1.0",
|
||||
entry: "./",
|
||||
privacy: { processing: "local", telemetry: false },
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user