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:
@@ -5,14 +5,12 @@
|
||||
* and shadow options.
|
||||
*/
|
||||
|
||||
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"];
|
||||
@@ -218,7 +216,7 @@ describe("text-overlay", () => {
|
||||
// ── Branch coverage: lines 40-41 (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" }) },
|
||||
@@ -239,7 +237,7 @@ describe("text-overlay", () => {
|
||||
// ── 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 overlay" }) },
|
||||
@@ -310,7 +308,7 @@ describe("text-overlay", () => {
|
||||
// ── JPEG format preserves correctly ───────────────────────────────
|
||||
|
||||
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" }) },
|
||||
@@ -337,7 +335,7 @@ describe("text-overlay", () => {
|
||||
// ── Large file (stress test) ──────────────────────────────────────
|
||||
|
||||
it("handles stress-large.jpg", 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 },
|
||||
{ name: "settings", content: JSON.stringify({ text: "Stress test", fontSize: 100 }) },
|
||||
@@ -398,7 +396,7 @@ describe("text-overlay", () => {
|
||||
// ── 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 overlay" }) },
|
||||
@@ -536,7 +534,7 @@ describe("text-overlay", () => {
|
||||
"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 overlay" }) },
|
||||
@@ -559,7 +557,7 @@ describe("text-overlay", () => {
|
||||
// ── 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 overlay" }) },
|
||||
@@ -580,7 +578,7 @@ describe("text-overlay", () => {
|
||||
// ── 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 overlay" }) },
|
||||
@@ -651,7 +649,7 @@ describe("text-overlay", () => {
|
||||
// ── 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 overlay" }) },
|
||||
@@ -847,7 +845,7 @@ describe("text-overlay", () => {
|
||||
// ── TIFF input with all options ─────────────────────────────────
|
||||
|
||||
it("processes TIFF input with background box and shadow at top position", 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 },
|
||||
{
|
||||
@@ -879,7 +877,7 @@ describe("text-overlay", () => {
|
||||
// ── Stress large file with background box ───────────────────────
|
||||
|
||||
it("handles stress-large.jpg with background box at bottom", 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("text-overlay", () => {
|
||||
// ── 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 overlay" }) },
|
||||
|
||||
Reference in New Issue
Block a user