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:
SnapOtter
2026-06-20 04:20:17 +08:00
parent 0705de8f1b
commit b1afcfdf3c
210 changed files with 28707 additions and 1447 deletions
+13 -15
View File
@@ -5,14 +5,12 @@
* opacity, font size, tiled mode, and input validation.
*/
import { readFileSync } from "node:fs";
import { join } from "node:path";
import sharp from "sharp";
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");
const PNG = readFileSync(join(FIXTURES, "test-200x150.png"));
const PNG = readFixture(fixtures.image.base.png200);
let testApp: TestApp;
let app: TestApp["app"];
@@ -205,7 +203,7 @@ describe("watermark-text", () => {
// ── Branch coverage: lines 45-46 (metadata fallback for width/height) ──
it("handles tiny 1x1 image input", async () => {
const TINY = readFileSync(join(FIXTURES, "test-1x1.png"));
const TINY = readFixture(fixtures.image.edge.px1);
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "tiny.png", contentType: "image/png", content: TINY },
{ name: "settings", content: JSON.stringify({ text: "Tiny", position: "center" }) },
@@ -226,7 +224,7 @@ describe("watermark-text", () => {
// ── Branch coverage: line 61 (tiled with maxElements cap) ─────────
it("handles tiled watermark on a large image", async () => {
const LARGE = readFileSync(join(FIXTURES, "content", "stress-large.jpg"));
const LARGE = readFixture(fixtures.image.stressLarge);
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "large.jpg", contentType: "image/jpeg", content: LARGE },
{
@@ -255,7 +253,7 @@ describe("watermark-text", () => {
// ── HEIC input handling ───────────────────────────────────────────
it("handles HEIC input", { timeout: 120_000 }, async () => {
const HEIC = readFileSync(join(FIXTURES, "test-200x150.heic"));
const HEIC = readFixture(fixtures.image.base.heic200);
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "photo.heic", contentType: "image/heic", content: HEIC },
{ name: "settings", content: JSON.stringify({ text: "HEIC Test" }) },
@@ -324,7 +322,7 @@ describe("watermark-text", () => {
// ── JPEG format preserves as JPEG ─────────────────────────────────
it("preserves JPEG format", async () => {
const JPG = readFileSync(join(FIXTURES, "test-100x100.jpg"));
const JPG = readFixture(fixtures.image.base.jpg100);
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "test.jpg", contentType: "image/jpeg", content: JPG },
{ name: "settings", content: JSON.stringify({ text: "JPEG" }) },
@@ -410,7 +408,7 @@ describe("watermark-text", () => {
// ── WebP input ───────────────────────────────────────────────────
it("processes WebP input", async () => {
const WEBP = readFileSync(join(FIXTURES, "test-50x50.webp"));
const WEBP = readFixture(fixtures.image.base.webp50);
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "test.webp", contentType: "image/webp", content: WEBP },
{ name: "settings", content: JSON.stringify({ text: "WebP" }) },
@@ -524,7 +522,7 @@ describe("watermark-text", () => {
"handles HEIF input (motorcycle.heif)",
{ timeout: 120_000 },
async () => {
const HEIF = readFileSync(join(FIXTURES, "content", "motorcycle.heif"));
const HEIF = readFixture(fixtures.image.motorcycle);
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "photo.heif", contentType: "image/heif", content: HEIF },
{ name: "settings", content: JSON.stringify({ text: "HEIF Test" }) },
@@ -547,7 +545,7 @@ describe("watermark-text", () => {
// ── Animated GIF input ──────────────────────────────────────────
it("handles animated GIF input", async () => {
const GIF = readFileSync(join(FIXTURES, "animated.gif"));
const GIF = readFixture(fixtures.image.animated.gif);
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "anim.gif", contentType: "image/gif", content: GIF },
{ name: "settings", content: JSON.stringify({ text: "GIF Test" }) },
@@ -568,7 +566,7 @@ describe("watermark-text", () => {
// ── SVG input ───────────────────────────────────────────────────
it("handles SVG input", async () => {
const SVG = readFileSync(join(FIXTURES, "test-100x100.svg"));
const SVG = readFixture(fixtures.image.base.svg100);
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "icon.svg", contentType: "image/svg+xml", content: SVG },
{ name: "settings", content: JSON.stringify({ text: "SVG Test" }) },
@@ -675,7 +673,7 @@ describe("watermark-text", () => {
// ── TIFF input format ───────────────────────────────────────────
it("processes TIFF input format", async () => {
const TIFF = readFileSync(join(FIXTURES, "formats", "sample.tiff"));
const TIFF = readFixture(fixtures.image.formats("tiff"));
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "test.tiff", contentType: "image/tiff", content: TIFF },
{ name: "settings", content: JSON.stringify({ text: "TIFF Test" }) },
@@ -814,7 +812,7 @@ describe("watermark-text", () => {
// ── Stress file with all options ────────────────────────────────
it("applies full options to stress-large.jpg at bottom-right", async () => {
const LARGE = readFileSync(join(FIXTURES, "content", "stress-large.jpg"));
const LARGE = readFixture(fixtures.image.stressLarge);
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "large.jpg", contentType: "image/jpeg", content: LARGE },
{
@@ -909,7 +907,7 @@ describe("watermark-text", () => {
// ── AVIF input format ──────────────────────────────────────────
it("processes AVIF input", async () => {
const AVIF = readFileSync(join(FIXTURES, "formats", "sample.avif"));
const AVIF = readFixture(fixtures.image.formats("avif"));
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "test.avif", contentType: "image/avif", content: AVIF },
{ name: "settings", content: JSON.stringify({ text: "AVIF Test" }) },