From 598f75ef638ce4de81dc2f4a04c81fad66a3bd15 Mon Sep 17 00:00:00 2001 From: SnapOtter Date: Fri, 24 Apr 2026 23:50:47 +0800 Subject: [PATCH] fix: increase test timeouts for slow CI operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - adversarial resize 50000x50000: 60s → 120s - format-matrix HEIF tests: 30s (default) → 90s --- tests/integration/adversarial.test.ts | 2 +- tests/integration/format-matrix.test.ts | 146 ++++++++++++------------ 2 files changed, 77 insertions(+), 71 deletions(-) diff --git a/tests/integration/adversarial.test.ts b/tests/integration/adversarial.test.ts index 5a665f40..a890a2ac 100644 --- a/tests/integration/adversarial.test.ts +++ b/tests/integration/adversarial.test.ts @@ -487,7 +487,7 @@ describe("Extreme dimension requests", () => { // May succeed (Sharp allows large), fail at processing (422), or be // rejected by validation (400). Must not crash. expect([200, 400, 422]).toContain(res.statusCode); - }, 60_000); + }, 120_000); it("rejects crop region larger than image dimensions", async () => { const res = await postTool("crop", [ diff --git a/tests/integration/format-matrix.test.ts b/tests/integration/format-matrix.test.ts index acb5f33e..67ee1ca6 100644 --- a/tests/integration/format-matrix.test.ts +++ b/tests/integration/format-matrix.test.ts @@ -349,82 +349,88 @@ describe("Cross-format matrix", () => { // Skip "Convert to PNG" when input is already PNG (no-op conversion) if (tool.id === "convert" && fmt.name === "PNG") continue; - it(`${tool.label}`, async () => { - if (!existsSync(fixturePath)) return; + const perTestTimeout = fmt.needsHeifDecoder ? 90_000 : undefined; - const buffer = readFileSync(fixturePath); - const { body: payload, contentType } = buildPayload(fmt, tool, buffer); + it( + `${tool.label}`, + async () => { + if (!existsSync(fixturePath)) return; - const res = await app.inject({ - method: "POST", - url: `/api/v1/tools/${tool.id}`, - headers: { - authorization: `Bearer ${adminToken}`, - "content-type": contentType, - }, - body: payload, - }); + const buffer = readFileSync(fixturePath); + const { body: payload, contentType } = buildPayload(fmt, tool, buffer); - // ------------------------------------------------------------------ - // Assert status code - // ------------------------------------------------------------------ - if (needsFallback(fmt)) { - // Formats with optional decoders: accept success or graceful error - expect(ACCEPTABLE_FALLBACK_CODES).toContain(res.statusCode); - } else { - // Core formats must always succeed - expect(res.statusCode).toBe(200); - } + const res = await app.inject({ + method: "POST", + url: `/api/v1/tools/${tool.id}`, + headers: { + authorization: `Bearer ${adminToken}`, + "content-type": contentType, + }, + body: payload, + }); - // ------------------------------------------------------------------ - // If successful, validate the response shape - // ------------------------------------------------------------------ - if (res.statusCode === 200) { - const body = JSON.parse(res.body); - - switch (tool.responseType) { - case "download": - expect(body.downloadUrl).toBeDefined(); - expect(typeof body.downloadUrl).toBe("string"); - expect(body.processedSize).toBeGreaterThan(0); - expect(body.originalSize).toBeGreaterThan(0); - break; - - case "info": - expect(body.width).toBeGreaterThan(0); - expect(body.height).toBeGreaterThan(0); - expect(body.fileSize).toBeGreaterThan(0); - expect(body.format).toBeDefined(); - expect(body.channels).toBeGreaterThan(0); - break; - - case "base64": - // image-to-base64 returns { results: [...], errors: [...] } - expect(Array.isArray(body.results)).toBe(true); - expect(body.results.length + body.errors.length).toBeGreaterThan(0); - if (body.results.length > 0) { - const r = body.results[0]; - expect(r.base64).toBeDefined(); - expect(typeof r.base64).toBe("string"); - expect(r.base64.length).toBeGreaterThan(0); - expect(r.dataUri).toMatch(/^data:/); - expect(r.width).toBeGreaterThan(0); - expect(r.height).toBeGreaterThan(0); - } - break; + // ------------------------------------------------------------------ + // Assert status code + // ------------------------------------------------------------------ + if (needsFallback(fmt)) { + // Formats with optional decoders: accept success or graceful error + expect(ACCEPTABLE_FALLBACK_CODES).toContain(res.statusCode); + } else { + // Core formats must always succeed + expect(res.statusCode).toBe(200); } - } - // ------------------------------------------------------------------ - // If the API returned an error, verify it is a clean JSON error - // (not a raw crash / stack trace / HTML error page) - // ------------------------------------------------------------------ - if (res.statusCode !== 200) { - const body = JSON.parse(res.body); - expect(body.error).toBeDefined(); - expect(typeof body.error).toBe("string"); - } - }); + // ------------------------------------------------------------------ + // If successful, validate the response shape + // ------------------------------------------------------------------ + if (res.statusCode === 200) { + const body = JSON.parse(res.body); + + switch (tool.responseType) { + case "download": + expect(body.downloadUrl).toBeDefined(); + expect(typeof body.downloadUrl).toBe("string"); + expect(body.processedSize).toBeGreaterThan(0); + expect(body.originalSize).toBeGreaterThan(0); + break; + + case "info": + expect(body.width).toBeGreaterThan(0); + expect(body.height).toBeGreaterThan(0); + expect(body.fileSize).toBeGreaterThan(0); + expect(body.format).toBeDefined(); + expect(body.channels).toBeGreaterThan(0); + break; + + case "base64": + // image-to-base64 returns { results: [...], errors: [...] } + expect(Array.isArray(body.results)).toBe(true); + expect(body.results.length + body.errors.length).toBeGreaterThan(0); + if (body.results.length > 0) { + const r = body.results[0]; + expect(r.base64).toBeDefined(); + expect(typeof r.base64).toBe("string"); + expect(r.base64.length).toBeGreaterThan(0); + expect(r.dataUri).toMatch(/^data:/); + expect(r.width).toBeGreaterThan(0); + expect(r.height).toBeGreaterThan(0); + } + break; + } + } + + // ------------------------------------------------------------------ + // If the API returned an error, verify it is a clean JSON error + // (not a raw crash / stack trace / HTML error page) + // ------------------------------------------------------------------ + if (res.statusCode !== 200) { + const body = JSON.parse(res.body); + expect(body.error).toBeDefined(); + expect(typeof body.error).toBe("string"); + } + }, + perTestTimeout, + ); } }); }