feat(tools): 2.0 phase 5 wave 5b - ai pool: ocr-pdf, transcription, background composites (5 tools) (#226)

This commit is contained in:
SnapOtter
2026-06-13 10:19:47 +08:00
parent 6e1b9865f1
commit 51666cdd5f
59 changed files with 5423 additions and 611 deletions
+37
View File
@@ -0,0 +1,37 @@
import { describe, expect, it } from "vitest";
import type { TranscriptSegment } from "../../../apps/api/src/lib/subtitle-format.js";
import { toSrt, toVtt } from "../../../apps/api/src/lib/subtitle-format.js";
const TWO_SEGMENTS: TranscriptSegment[] = [
{ startS: 0, endS: 1.5, text: "Hello world" },
{ startS: 2.0, endS: 4.75, text: "Second line" },
];
describe("toSrt", () => {
it("formats two segments with comma millisecond separator and 1-based counters", () => {
const result = toSrt(TWO_SEGMENTS);
const expected =
"1\n00:00:00,000 --> 00:00:01,500\nHello world\n\n" +
"2\n00:00:02,000 --> 00:00:04,750\nSecond line\n";
expect(result).toBe(expected);
});
it("returns empty string for empty segments", () => {
expect(toSrt([])).toBe("");
});
});
describe("toVtt", () => {
it("formats two segments with WEBVTT header and dot millisecond separator", () => {
const result = toVtt(TWO_SEGMENTS);
const expected =
"WEBVTT\n\n" +
"00:00:00.000 --> 00:00:01.500\nHello world\n\n" +
"00:00:02.000 --> 00:00:04.750\nSecond line\n";
expect(result).toBe(expected);
});
it("returns WEBVTT header with trailing newlines for empty segments", () => {
expect(toVtt([])).toBe("WEBVTT\n\n");
});
});