Release Subtitle Tools 0.2.0
Verify / verify (push) Canceled after 0s

This commit is contained in:
2026-09-02 08:44:49 +02:00
parent b92793eb82
commit 88c2bcd0ff
36 changed files with 1354 additions and 182 deletions
+74 -5
View File
@@ -1,4 +1,5 @@
import { expect, test, type Page } from "@playwright/test";
import { Buffer } from "node:buffer";
const ORIGIN = "http://127.0.0.1:4197";
async function localOnly(page: Page) {
@@ -36,10 +37,10 @@ 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 page.getByRole("button", { 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.getByRole("button", { 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(
@@ -50,13 +51,57 @@ test("parses, validates, edits and converts the example", async ({ page }) => {
test("applies a bounded timing shift", async ({ page }) => {
await page.goto("/deep/nested/subtitle/");
await page.getByRole("tab", { name: "Timing" }).click();
await page.getByRole("button", { 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 page.getByRole("button", { name: "Cues & checks" }).click();
await expect(page.getByText(/00:00:01\.500/u).first()).toBeVisible();
});
test("imports flat TTML and performs timeline edits", async ({ page }) => {
await page.goto("/deep/nested/subtitle/");
await page
.getByLabel("Subtitle source")
.fill(
`<tt xmlns="http://www.w3.org/ns/ttml"><body><div><p begin="1s" end="3s">One<br/>line</p></div></body></tt>`,
);
await page.getByRole("button", { name: "Parse source" }).click();
await expect(
page.getByLabel("Subtitle summary").getByText("TTML", { exact: true }),
).toBeVisible();
await page.getByRole("button", { name: "Cues & checks" }).click();
await page.getByRole("button", { name: "Duplicate" }).click();
await expect(
page
.getByLabel("Subtitle summary")
.locator(":scope > div")
.filter({ hasText: /^Cues2$/u })
.locator("strong"),
).toHaveText("2");
await page.getByRole("button", { name: "Uppercase" }).click();
await page.getByRole("button", { name: "Source & export" }).click();
await page.getByLabel("Output format").selectOption("ttml");
await expect(page.getByLabel("Export preview")).toHaveValue(/<tt/u);
await expect(page.getByLabel("Export preview")).toHaveValue(/ONE/u);
});
test("attaches playback before completing worker waveform extraction", async ({
page,
}) => {
await page.goto("/deep/nested/subtitle/");
await page.getByRole("button", { name: "Waveform" }).click();
await page.getByLabel("Open media").setInputFiles({
name: "tone.wav",
mimeType: "audio/wav",
buffer: wavFixture(),
});
await expect(page.locator("audio")).toBeVisible();
await expect(
page.getByLabel("Audio waveform with subtitle start markers"),
).toBeVisible();
await expect(page.getByRole("alert")).toHaveCount(0);
});
test("serves release identity and hardened local-only headers", async ({
request,
}) => {
@@ -72,8 +117,32 @@ test("serves release identity and hardened local-only headers", async ({
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",
version: "0.2.0",
entry: "./",
privacy: { processing: "local", telemetry: false },
});
});
function wavFixture(): Buffer {
const sampleRate = 8_000;
const samples = sampleRate / 4;
const output = Buffer.alloc(44 + samples * 2);
output.write("RIFF", 0);
output.writeUInt32LE(output.length - 8, 4);
output.write("WAVEfmt ", 8);
output.writeUInt32LE(16, 16);
output.writeUInt16LE(1, 20);
output.writeUInt16LE(1, 22);
output.writeUInt32LE(sampleRate, 24);
output.writeUInt32LE(sampleRate * 2, 28);
output.writeUInt16LE(2, 32);
output.writeUInt16LE(16, 34);
output.write("data", 36);
output.writeUInt32LE(samples * 2, 40);
for (let index = 0; index < samples; index += 1)
output.writeInt16LE(
Math.round(Math.sin((index / sampleRate) * Math.PI * 2 * 440) * 12_000),
44 + index * 2,
);
return output;
}