mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: expand coverage across all layers -- 1,268 new tests, fix replace-color div-by-zero
14-agent parallel test expansion covering integration, unit, E2E, E2E-Docker, cross-format matrix, adversarial, GUI navigation/tools/settings/visual/a11y/perf. - Integration: expand 23 tool test files with HEIC, stress, batch, edge cases - Unit: close coverage gaps in image-engine, stores, lib (metadata, auto-enhance, connection-store, lazy-with-retry, collage/file-store HEIC preview) - AI bridge: 141 new tests for dispatcher buffering, crash recovery, OOM/segfault - Cross-format: 794 parameterized tests (16 formats x 12 tools + no-crash matrix) - Adversarial: memory stress (50x large file), zero-byte, corrupted headers, unicode - E2E-Docker: expand 8 spec files with dimension verification, pipeline chains - GUI E2E: tool UI settings/interactions for all 47 tools, remove all test.skip, RBAC per-role verification, visual screenshot naming, cross-browser smoke tests, a11y ARIA/focus/contrast, performance budgets, 15-tool stability test - Fix: replace-color.ts tolerance=0 caused division-by-zero producing NaN pixels Total: 8,958 tests passing across 202 files. Zero failures, zero skips.
This commit is contained in:
@@ -3,11 +3,13 @@ import { join } from "node:path";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
// ─── Essential Tools ────────────────────────────────────────────────
|
||||
// Tests for: resize, crop, rotate, convert, compress
|
||||
// Tests for: resize, crop, rotate, convert, compress, strip-metadata,
|
||||
// edit-metadata, info, sharpening, color-adjustments, color-blindness
|
||||
// These are the core Sharp-based image manipulation tools.
|
||||
|
||||
const FIXTURES = join(process.cwd(), "tests", "fixtures");
|
||||
const FORMATS = join(FIXTURES, "formats");
|
||||
const CONTENT = join(FIXTURES, "content");
|
||||
|
||||
let token: string;
|
||||
|
||||
@@ -27,6 +29,10 @@ function formatFixture(name: string): Buffer {
|
||||
return readFileSync(join(FORMATS, name));
|
||||
}
|
||||
|
||||
function contentFixture(name: string): Buffer {
|
||||
return readFileSync(join(CONTENT, name));
|
||||
}
|
||||
|
||||
/** 200x150 PNG for dimension-sensitive tests. */
|
||||
const PNG_200x150 = fixture("test-200x150.png");
|
||||
|
||||
@@ -36,6 +42,21 @@ const JPG_100x100 = fixture("test-100x100.jpg");
|
||||
/** HEIC image for format decode testing. */
|
||||
const HEIC_200x150 = fixture("test-200x150.heic");
|
||||
|
||||
/** SVG image for vector input testing. */
|
||||
const SVG_100x100 = fixture("test-100x100.svg");
|
||||
|
||||
/** Tiny 1x1 PNG for edge case testing. */
|
||||
const PNG_1x1 = fixture("test-1x1.png");
|
||||
|
||||
/** Large sample JPEG for stress testing. */
|
||||
const JPG_SAMPLE_LARGE = contentFixture("stress-large.jpg");
|
||||
|
||||
/** Sample photo JPEG. */
|
||||
const JPG_SAMPLE = fixture("sample-photo.jpg");
|
||||
|
||||
/** JPEG with EXIF data. */
|
||||
const JPG_WITH_EXIF = fixture("test-with-exif.jpg");
|
||||
|
||||
// ─── Resize ──────────────────────────────────────────────────────────
|
||||
|
||||
test.describe("Resize", () => {
|
||||
@@ -964,6 +985,488 @@ test.describe("Color Blindness Simulation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Strip Metadata ────────────────────────────────────────────────
|
||||
|
||||
test.describe("Strip Metadata", () => {
|
||||
test("strip metadata with default settings", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/strip-metadata", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_WITH_EXIF },
|
||||
settings: JSON.stringify({}),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
expect(body.processedSize).toBeGreaterThan(0);
|
||||
// Stripping metadata should not increase file size
|
||||
expect(body.processedSize).toBeLessThanOrEqual(body.originalSize);
|
||||
});
|
||||
|
||||
test("strip metadata from PNG image", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/strip-metadata", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
|
||||
settings: JSON.stringify({}),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
});
|
||||
|
||||
test("strip metadata from HEIC image", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/strip-metadata", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.heic", mimeType: "image/heic", buffer: HEIC_200x150 },
|
||||
settings: JSON.stringify({}),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
});
|
||||
|
||||
test("strip then verify no EXIF via info tool", async ({ request }) => {
|
||||
// Strip metadata
|
||||
const stripRes = await request.post("/api/v1/tools/strip-metadata", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_WITH_EXIF },
|
||||
settings: JSON.stringify({}),
|
||||
},
|
||||
});
|
||||
expect(stripRes.ok()).toBe(true);
|
||||
const stripBody = await stripRes.json();
|
||||
|
||||
// Download the stripped file
|
||||
const dlRes = await request.get(stripBody.downloadUrl, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
expect(dlRes.ok()).toBe(true);
|
||||
const strippedBuffer = Buffer.from(await dlRes.body());
|
||||
|
||||
// Verify via info tool
|
||||
const infoRes = await request.post("/api/v1/tools/info", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "stripped.jpg", mimeType: "image/jpeg", buffer: strippedBuffer },
|
||||
},
|
||||
});
|
||||
expect(infoRes.ok()).toBe(true);
|
||||
const infoBody = await infoRes.json();
|
||||
expect(infoBody.hasExif).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Edit Metadata ─────────────────────────────────────────────────
|
||||
|
||||
test.describe("Edit Metadata", () => {
|
||||
test("set artist field on JPEG", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/edit-metadata", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_100x100 },
|
||||
settings: JSON.stringify({ artist: "SnapOtter E2E" }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
expect(body.processedSize).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("set all EXIF fields at once", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/edit-metadata", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_100x100 },
|
||||
settings: JSON.stringify({
|
||||
title: "Test Image",
|
||||
description: "Docker E2E test",
|
||||
artist: "SnapOtter",
|
||||
copyright: "CC0-1.0",
|
||||
}),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
expect(body.processedSize).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("edit metadata on PNG image", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/edit-metadata", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
|
||||
settings: JSON.stringify({ title: "PNG metadata test" }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
});
|
||||
|
||||
test("edit metadata round-trip verification", async ({ request }) => {
|
||||
const editRes = await request.post("/api/v1/tools/edit-metadata", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_100x100 },
|
||||
settings: JSON.stringify({ artist: "Round Trip Author" }),
|
||||
},
|
||||
});
|
||||
expect(editRes.ok()).toBe(true);
|
||||
const editBody = await editRes.json();
|
||||
|
||||
// Download the edited image
|
||||
const dlRes = await request.get(editBody.downloadUrl, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
expect(dlRes.ok()).toBe(true);
|
||||
const editedBuffer = Buffer.from(await dlRes.body());
|
||||
|
||||
// Check info on the edited image
|
||||
const infoRes = await request.post("/api/v1/tools/info", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "edited.jpg", mimeType: "image/jpeg", buffer: editedBuffer },
|
||||
},
|
||||
});
|
||||
expect(infoRes.ok()).toBe(true);
|
||||
const infoBody = await infoRes.json();
|
||||
expect(infoBody.hasExif).toBe(true);
|
||||
});
|
||||
|
||||
test("edit metadata on HEIC image", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/edit-metadata", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.heic", mimeType: "image/heic", buffer: HEIC_200x150 },
|
||||
settings: JSON.stringify({ artist: "HEIC metadata test" }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
// ─── SVG Input Support ─────────────────────────────────────────────
|
||||
|
||||
test.describe("SVG Input", () => {
|
||||
test("resize SVG input", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/resize", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.svg", mimeType: "image/svg+xml", buffer: SVG_100x100 },
|
||||
settings: JSON.stringify({ width: 200, fit: "contain" }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
expect(body.processedSize).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("rotate SVG input", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/rotate", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.svg", mimeType: "image/svg+xml", buffer: SVG_100x100 },
|
||||
settings: JSON.stringify({ angle: 90 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
});
|
||||
|
||||
test("compress SVG input (rasterized)", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/compress", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.svg", mimeType: "image/svg+xml", buffer: SVG_100x100 },
|
||||
settings: JSON.stringify({ quality: 60 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
});
|
||||
|
||||
test("convert SVG to JPEG", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/convert", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.svg", mimeType: "image/svg+xml", buffer: SVG_100x100 },
|
||||
settings: JSON.stringify({ format: "jpg", quality: 80 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toContain(".jpg");
|
||||
expect(body.processedSize).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Tiny File Edge Cases ──────────────────────────────────────────
|
||||
|
||||
test.describe("Tiny file (1x1 pixel)", () => {
|
||||
test("resize 1x1 PNG to larger dimensions", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/resize", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_1x1 },
|
||||
settings: JSON.stringify({ width: 100, height: 100, fit: "fill" }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
expect(body.processedSize).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("crop 1x1 PNG to same size succeeds", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/crop", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_1x1 },
|
||||
settings: JSON.stringify({ left: 0, top: 0, width: 1, height: 1 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
});
|
||||
|
||||
test("rotate 1x1 PNG by 90 degrees", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/rotate", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_1x1 },
|
||||
settings: JSON.stringify({ angle: 90 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
});
|
||||
|
||||
test("convert 1x1 PNG to WebP", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/convert", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_1x1 },
|
||||
settings: JSON.stringify({ format: "webp" }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toContain(".webp");
|
||||
});
|
||||
|
||||
test("compress 1x1 PNG", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/compress", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_1x1 },
|
||||
settings: JSON.stringify({ quality: 50 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
});
|
||||
|
||||
test("info returns 1x1 dimensions", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/info", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_1x1 },
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.width).toBe(1);
|
||||
expect(body.height).toBe(1);
|
||||
expect(body.format).toBe("png");
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Large File Processing ─────────────────────────────────────────
|
||||
|
||||
test.describe("Large file processing", () => {
|
||||
test("resize large JPEG image", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/resize", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "stress.jpg", mimeType: "image/jpeg", buffer: JPG_SAMPLE_LARGE },
|
||||
settings: JSON.stringify({ width: 800, fit: "contain" }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
expect(body.processedSize).toBeGreaterThan(0);
|
||||
// Resized should be smaller than original
|
||||
expect(body.processedSize).toBeLessThan(body.originalSize);
|
||||
});
|
||||
|
||||
test("compress large JPEG with aggressive quality", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/compress", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "stress.jpg", mimeType: "image/jpeg", buffer: JPG_SAMPLE_LARGE },
|
||||
settings: JSON.stringify({ quality: 20 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
expect(body.processedSize).toBeLessThan(body.originalSize);
|
||||
});
|
||||
|
||||
test("convert large JPEG to WebP", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/convert", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "stress.jpg", mimeType: "image/jpeg", buffer: JPG_SAMPLE_LARGE },
|
||||
settings: JSON.stringify({ format: "webp" }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toContain(".webp");
|
||||
expect(body.processedSize).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("rotate large JPEG 270 degrees", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/rotate", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "stress.jpg", mimeType: "image/jpeg", buffer: JPG_SAMPLE_LARGE },
|
||||
settings: JSON.stringify({ angle: 270 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
expect(body.processedSize).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("info on large JPEG returns dimensions", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/info", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "stress.jpg", mimeType: "image/jpeg", buffer: JPG_SAMPLE_LARGE },
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.width).toBeGreaterThan(0);
|
||||
expect(body.height).toBeGreaterThan(0);
|
||||
expect(body.fileSize).toBeGreaterThan(1_000_000); // At least 1MB
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Download and Verify Output ────────────────────────────────────
|
||||
|
||||
test.describe("Output download verification", () => {
|
||||
test("resized file is downloadable and valid", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/resize", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
|
||||
settings: JSON.stringify({ width: 100, fit: "contain" }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
|
||||
// Download the result
|
||||
const dlRes = await request.get(body.downloadUrl, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
expect(dlRes.ok()).toBe(true);
|
||||
const buffer = Buffer.from(await dlRes.body());
|
||||
expect(buffer.length).toBeGreaterThan(0);
|
||||
|
||||
// Verify dimensions via info tool
|
||||
const infoRes = await request.post("/api/v1/tools/info", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "resized.png", mimeType: "image/png", buffer: buffer },
|
||||
},
|
||||
});
|
||||
expect(infoRes.ok()).toBe(true);
|
||||
const infoBody = await infoRes.json();
|
||||
expect(infoBody.width).toBe(100);
|
||||
});
|
||||
|
||||
test("cropped file dimensions match request", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/crop", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
|
||||
settings: JSON.stringify({ left: 10, top: 10, width: 80, height: 60 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
|
||||
const dlRes = await request.get(body.downloadUrl, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
expect(dlRes.ok()).toBe(true);
|
||||
const buffer = Buffer.from(await dlRes.body());
|
||||
|
||||
const infoRes = await request.post("/api/v1/tools/info", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "cropped.png", mimeType: "image/png", buffer: buffer },
|
||||
},
|
||||
});
|
||||
expect(infoRes.ok()).toBe(true);
|
||||
const infoBody = await infoRes.json();
|
||||
expect(infoBody.width).toBe(80);
|
||||
expect(infoBody.height).toBe(60);
|
||||
});
|
||||
|
||||
test("90-degree rotation swaps width and height", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/rotate", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
|
||||
settings: JSON.stringify({ angle: 90 }),
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
|
||||
const dlRes = await request.get(body.downloadUrl, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
expect(dlRes.ok()).toBe(true);
|
||||
const buffer = Buffer.from(await dlRes.body());
|
||||
|
||||
const infoRes = await request.post("/api/v1/tools/info", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "rotated.png", mimeType: "image/png", buffer: buffer },
|
||||
},
|
||||
});
|
||||
expect(infoRes.ok()).toBe(true);
|
||||
const infoBody = await infoRes.json();
|
||||
// 200x150 rotated 90 degrees should become 150x200
|
||||
expect(infoBody.width).toBe(150);
|
||||
expect(infoBody.height).toBe(200);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Auth Failure ──────────────────────────────────────────────────
|
||||
|
||||
test.describe("Auth failure", () => {
|
||||
@@ -1016,4 +1519,24 @@ test.describe("Auth failure", () => {
|
||||
});
|
||||
expect(res.status()).toBe(401);
|
||||
});
|
||||
|
||||
test("strip-metadata without token returns 401", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/strip-metadata", {
|
||||
multipart: {
|
||||
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_WITH_EXIF },
|
||||
settings: JSON.stringify({}),
|
||||
},
|
||||
});
|
||||
expect(res.status()).toBe(401);
|
||||
});
|
||||
|
||||
test("edit-metadata without token returns 401", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/edit-metadata", {
|
||||
multipart: {
|
||||
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_100x100 },
|
||||
settings: JSON.stringify({ artist: "Test" }),
|
||||
},
|
||||
});
|
||||
expect(res.status()).toBe(401);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user