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:
@@ -6,16 +6,14 @@
|
||||
* Consolidated adjust-colors tool replaces the old brightness-contrast, saturation, etc.
|
||||
*/
|
||||
|
||||
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 JPG = readFileSync(join(FIXTURES, "test-100x100.jpg"));
|
||||
const WEBP = readFileSync(join(FIXTURES, "test-50x50.webp"));
|
||||
const PNG = readFixture(fixtures.image.base.png200);
|
||||
const JPG = readFixture(fixtures.image.base.jpg100);
|
||||
const WEBP = readFixture(fixtures.image.base.webp50);
|
||||
|
||||
let testApp: TestApp;
|
||||
let app: TestApp["app"];
|
||||
@@ -322,7 +320,7 @@ describe("Exposure adjustments", () => {
|
||||
// ── HEIC input ──────────────────────────────────────────────────
|
||||
describe("HEIC input", () => {
|
||||
it("processes HEIC input with brightness adjustment", { timeout: 120_000 }, async () => {
|
||||
const HEIC = readFileSync(join(FIXTURES, "test-200x150.heic"));
|
||||
const HEIC = readFixture(fixtures.image.base.heic200);
|
||||
const res = await postTool(
|
||||
"adjust-colors",
|
||||
{ brightness: 30 },
|
||||
@@ -373,13 +371,13 @@ describe("Combined exposure adjustments", () => {
|
||||
// ── Tiny and stress inputs ──────────────────────────────────────
|
||||
describe("Edge size inputs", () => {
|
||||
it("processes 1x1 pixel image", async () => {
|
||||
const TINY = readFileSync(join(FIXTURES, "test-1x1.png"));
|
||||
const TINY = readFixture(fixtures.image.edge.px1);
|
||||
const res = await postTool("adjust-colors", { brightness: 50 }, TINY, "tiny.png", "image/png");
|
||||
expect(res.statusCode).toBe(200);
|
||||
});
|
||||
|
||||
it("processes stress-large.jpg", async () => {
|
||||
const LARGE = readFileSync(join(FIXTURES, "content", "stress-large.jpg"));
|
||||
const LARGE = readFixture(fixtures.image.stressLarge);
|
||||
const res = await postTool("adjust-colors", { contrast: 30 }, LARGE, "large.jpg", "image/jpeg");
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
@@ -513,7 +511,7 @@ describe("HEIF input", () => {
|
||||
"processes HEIF input (motorcycle.heif)",
|
||||
{ timeout: 120_000 },
|
||||
async () => {
|
||||
const HEIF = readFileSync(join(FIXTURES, "content", "motorcycle.heif"));
|
||||
const HEIF = readFixture(fixtures.image.motorcycle);
|
||||
const res = await postTool(
|
||||
"adjust-colors",
|
||||
{ brightness: 20 },
|
||||
@@ -532,7 +530,7 @@ describe("HEIF input", () => {
|
||||
// ── Animated GIF input ──────────────────────────────────────────
|
||||
describe("Animated GIF input", () => {
|
||||
it("processes animated GIF", async () => {
|
||||
const GIF = readFileSync(join(FIXTURES, "animated.gif"));
|
||||
const GIF = readFixture(fixtures.image.animated.gif);
|
||||
const res = await postTool("adjust-colors", { saturation: 30 }, GIF, "anim.gif", "image/gif");
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
@@ -543,7 +541,7 @@ describe("Animated GIF input", () => {
|
||||
// ── SVG input ───────────────────────────────────────────────────
|
||||
describe("SVG input", () => {
|
||||
it("processes SVG input", async () => {
|
||||
const SVG = readFileSync(join(FIXTURES, "test-100x100.svg"));
|
||||
const SVG = readFixture(fixtures.image.base.svg100);
|
||||
const res = await postTool("adjust-colors", { contrast: 20 }, SVG, "icon.svg", "image/svg+xml");
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
@@ -554,7 +552,7 @@ describe("SVG input", () => {
|
||||
// ── TIFF input ─────────────────────────────────────────────────
|
||||
describe("TIFF input", () => {
|
||||
it("processes TIFF input with saturation adjustment", async () => {
|
||||
const TIFF = readFileSync(join(FIXTURES, "formats", "sample.tiff"));
|
||||
const TIFF = readFixture(fixtures.image.formats("tiff"));
|
||||
const res = await postTool(
|
||||
"adjust-colors",
|
||||
{ saturation: 40 },
|
||||
@@ -836,7 +834,7 @@ describe("Temperature/tint exact boundaries", () => {
|
||||
// ── AVIF input ─────────────────────────────────────────────────
|
||||
describe("AVIF input", () => {
|
||||
it("processes AVIF input with saturation adjustment", async () => {
|
||||
const AVIF = readFileSync(join(FIXTURES, "formats", "sample.avif"));
|
||||
const AVIF = readFixture(fixtures.image.formats("avif"));
|
||||
const res = await postTool(
|
||||
"adjust-colors",
|
||||
{ saturation: 50 },
|
||||
|
||||
Reference in New Issue
Block a user