mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Codemod rewrites all five ad-hoc fixture-path styles to import from the typed registry (tests/fixtures/index.ts): - join(__dirname, "..", "fixtures", ...) inline patterns (100 files) - const FIXTURES = join(__dirname, ...) + join(FIXTURES, ...) (92 files) - process.cwd()-based paths (10 files) - path.resolve(__dirname, ...) patterns (5 files) Registry extended with 8 new keys (portraitJpg, portraitHeic, motorcycle, svgLogo, barcodeAvif, qrAvif, crossFormatChat, multipageTiff) and directory accessors (fixtureDir, fixtureRoot). Dynamic directory scanners (format-matrix-generated, format-matrix-multimodal, hostile-inputs) preserved via fixtureDir imports. No fixtures swapped, bytes identical. Parity gate: dropped 0, net-new 388.
25 lines
1.0 KiB
TypeScript
25 lines
1.0 KiB
TypeScript
import { readFile } from "node:fs/promises";
|
|
import { resolveGs } from "@snapotter/doc-engine";
|
|
import { ffmpegAvailable } from "@snapotter/media-engine";
|
|
import { describe, expect, it } from "vitest";
|
|
import { pdfFirstPagePreview, videoPosterPreview } from "../../apps/api/src/modality/preview.js";
|
|
import { fixtures, readFixture } from "../fixtures/index.js";
|
|
|
|
describe.skipIf(!ffmpegAvailable())("video poster preview (requires ffmpeg)", () => {
|
|
it("renders a webp poster", async () => {
|
|
const buf = readFixture(fixtures.video.tiny("mp4"));
|
|
const poster = await videoPosterPreview(buf);
|
|
expect(poster).not.toBeNull();
|
|
expect(poster?.length).toBeGreaterThan(50);
|
|
});
|
|
});
|
|
|
|
describe.skipIf(!resolveGs())("pdf first-page preview (requires ghostscript)", () => {
|
|
it("renders a png of page 1", async () => {
|
|
const buf = readFixture(fixtures.document.pdf3);
|
|
const png = await pdfFirstPagePreview(buf);
|
|
expect(png).not.toBeNull();
|
|
expect(png?.subarray(1, 4).toString()).toBe("PNG");
|
|
});
|
|
});
|