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:
@@ -1,5 +1,4 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import sharp from "sharp";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
@@ -8,8 +7,7 @@ import {
|
||||
encodeJp2,
|
||||
encodeQoi,
|
||||
} from "../../../apps/api/src/lib/format-encoders.js";
|
||||
|
||||
const FIXTURES = join(__dirname, "../../fixtures");
|
||||
import { fixtures, readFixture } from "../../fixtures/index.js";
|
||||
|
||||
async function createTestPng(width = 50, height = 50): Promise<Buffer> {
|
||||
return sharp({
|
||||
@@ -52,7 +50,7 @@ describe("encodeQoi", () => {
|
||||
});
|
||||
|
||||
it("encodes fixture image to QOI", async () => {
|
||||
const input = await readFile(join(FIXTURES, "test-200x150.png"));
|
||||
const input = readFixture(fixtures.image.base.png200);
|
||||
const result = await encodeQoi(input);
|
||||
expect(result.length).toBeGreaterThan(100);
|
||||
});
|
||||
@@ -170,7 +168,7 @@ describe("encodeJp2", () => {
|
||||
});
|
||||
|
||||
it("produces valid output at different quality levels", async () => {
|
||||
const input = await readFile(join(FIXTURES, "test-200x150.png"));
|
||||
const input = readFixture(fixtures.image.base.png200);
|
||||
try {
|
||||
const low = await encodeJp2(input, 10);
|
||||
const high = await encodeJp2(input, 90);
|
||||
|
||||
Reference in New Issue
Block a user