mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: migrate 207 test files to typed fixture registry (phase 5)
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.
This commit is contained in:
@@ -15,13 +15,10 @@
|
||||
*/
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||
import { fixtures, readFixture } from "../fixtures/index.js";
|
||||
import { buildTestApp, createMultipartPayload, loginAsAdmin, type TestApp } from "./test-server.js";
|
||||
|
||||
const FIXTURES = join(__dirname, "..", "fixtures");
|
||||
|
||||
// ── Binary gates ──────────────────────────────────────────────────────
|
||||
function hasBinary(name: string): boolean {
|
||||
const res = spawnSync("which", [name], { encoding: "utf8" });
|
||||
@@ -86,7 +83,7 @@ describe("cross-modality launch smoke", () => {
|
||||
name: "file",
|
||||
filename: "test.png",
|
||||
contentType: "image/png",
|
||||
content: readFileSync(join(FIXTURES, "test-200x150.png")),
|
||||
content: readFixture(fixtures.image.base.png200),
|
||||
},
|
||||
{ name: "settings", content: JSON.stringify({ angle: 90, flipH: false, flipV: false }) },
|
||||
]);
|
||||
@@ -101,7 +98,7 @@ describe("cross-modality launch smoke", () => {
|
||||
|
||||
// ── Image: rotate (Sharp, no external binary) ─────────────────────
|
||||
it("image modality: rotate", async () => {
|
||||
const file = readFileSync(join(FIXTURES, "test-200x150.png"));
|
||||
const file = readFixture(fixtures.image.base.png200);
|
||||
const res = await postTool(app, adminToken, "rotate", file, "test.png", "image/png", {
|
||||
angle: 90,
|
||||
flipH: false,
|
||||
@@ -118,7 +115,7 @@ describe("cross-modality launch smoke", () => {
|
||||
it.skipIf(!HAS_FFMPEG)(
|
||||
"video modality: mute-video",
|
||||
async () => {
|
||||
const file = readFileSync(join(FIXTURES, "media", "tiny.mp4"));
|
||||
const file = readFixture(fixtures.video.tiny("mp4"));
|
||||
const res = await postTool(app, adminToken, "mute-video", file, "tiny.mp4", "video/mp4", {});
|
||||
if (isAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
@@ -133,7 +130,7 @@ describe("cross-modality launch smoke", () => {
|
||||
it.skipIf(!HAS_FFMPEG)(
|
||||
"audio modality: convert-audio",
|
||||
async () => {
|
||||
const file = readFileSync(join(FIXTURES, "media", "tiny.wav"));
|
||||
const file = readFixture(fixtures.audio.tiny("wav"));
|
||||
const res = await postTool(app, adminToken, "convert-audio", file, "tone.wav", "audio/wav", {
|
||||
format: "mp3",
|
||||
bitrate: 128,
|
||||
@@ -151,7 +148,7 @@ describe("cross-modality launch smoke", () => {
|
||||
it.skipIf(!HAS_QPDF)(
|
||||
"document modality: rotate-pdf",
|
||||
async () => {
|
||||
const file = readFileSync(join(FIXTURES, "documents", "tiny.pdf"));
|
||||
const file = readFixture(fixtures.document.tiny("pdf"));
|
||||
const res = await postTool(
|
||||
app,
|
||||
adminToken,
|
||||
@@ -172,7 +169,7 @@ describe("cross-modality launch smoke", () => {
|
||||
|
||||
// ── Data/File: csv-json (pure JS, no binary) ─────────────────────
|
||||
it("data modality: csv-json", async () => {
|
||||
const file = readFileSync(join(FIXTURES, "data", "tiny.csv"));
|
||||
const file = readFixture(fixtures.data.csv);
|
||||
const res = await postTool(app, adminToken, "csv-json", file, "tiny.csv", "text/csv", {
|
||||
direction: "csv-to-json",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user