diff --git a/tests/integration/generated/format-matrix-3.test.ts b/tests/integration/generated/format-matrix-3.test.ts index a694489d..ac0cdbaf 100644 --- a/tests/integration/generated/format-matrix-3.test.ts +++ b/tests/integration/generated/format-matrix-3.test.ts @@ -60,6 +60,7 @@ describe("Multipage TIFF handling", () => { // Multipage TIFF should either succeed or return a clean error expect([200, 202, 400, 422]).toContain(res.statusCode); + if (await settleAsyncFallback(res)) return; if (res.statusCode === 200) { const body = JSON.parse(res.body); diff --git a/tests/integration/generated/format-matrix-4.test.ts b/tests/integration/generated/format-matrix-4.test.ts index 15298832..fd9fc59c 100644 --- a/tests/integration/generated/format-matrix-4.test.ts +++ b/tests/integration/generated/format-matrix-4.test.ts @@ -507,6 +507,7 @@ describe("Image-to-PDF cross-format matrix", () => { expect([200, 202, 400, 422]).toContain(res.statusCode); + if (await settleAsyncFallback(res)) return; if (res.statusCode === 200) { const body = JSON.parse(res.body); expect(body.downloadUrl).toBeDefined(); diff --git a/tests/integration/generated/format-matrix-comprehensive-1.test.ts b/tests/integration/generated/format-matrix-comprehensive-1.test.ts index 084285bb..05fa7370 100644 --- a/tests/integration/generated/format-matrix-comprehensive-1.test.ts +++ b/tests/integration/generated/format-matrix-comprehensive-1.test.ts @@ -10,6 +10,7 @@ import { existsSync, readFileSync } from "node:fs"; import { join } from "node:path"; import { describe, expect, it, vi } from "vitest"; import { fixtureDir } from "../../fixtures/index.js"; +import { settleAsyncFallback } from "../settle-job.js"; import { createMultipartPayload } from "../test-server.js"; import { ACCEPTABLE_FALLBACK_CODES, @@ -147,6 +148,7 @@ describe("Image enhancement across all 16 primary formats", () => { expect(res.statusCode).toBe(200); } + if (await settleAsyncFallback(res)) return; if (res.statusCode === 200) { const body = JSON.parse(res.body); expect(body.corrections).toBeDefined(); diff --git a/tests/integration/generated/format-matrix-comprehensive-3.test.ts b/tests/integration/generated/format-matrix-comprehensive-3.test.ts index 5514658e..dc50b3d8 100644 --- a/tests/integration/generated/format-matrix-comprehensive-3.test.ts +++ b/tests/integration/generated/format-matrix-comprehensive-3.test.ts @@ -7,6 +7,7 @@ */ import { describe, expect, it, vi } from "vitest"; +import { settleAsyncFallback } from "../settle-job.js"; import { createMultipartPayload } from "../test-server.js"; import { ACCEPTABLE_FALLBACK_CODES, @@ -327,6 +328,7 @@ describe("SVG through raster tools", () => { expect([200, 202, 400, 422]).toContain(res.statusCode); const body = JSON.parse(res.body); + if (await settleAsyncFallback(res)) return; if (res.statusCode === 200) { if (tool.id === "info") { expect(body.width).toBeGreaterThan(0); diff --git a/tests/integration/generated/format-matrix-expanded.test.ts b/tests/integration/generated/format-matrix-expanded.test.ts index df36a0ca..330317c1 100644 --- a/tests/integration/generated/format-matrix-expanded.test.ts +++ b/tests/integration/generated/format-matrix-expanded.test.ts @@ -35,6 +35,7 @@ import { existsSync, readFileSync } from "node:fs"; import { join } from "node:path"; import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { fixtureDir, fixtures } from "../../fixtures/index.js"; +import { settleAsyncFallback } from "../settle-job.js"; import { buildTestApp, createMultipartPayload, @@ -414,6 +415,7 @@ describe("Edit-metadata cross-format", () => { expect([200, 202, 400, 422]).toContain(res.statusCode); } + if (await settleAsyncFallback(res)) return; if (res.statusCode === 200) { const body = JSON.parse(res.body); expect(body.downloadUrl).toBeDefined(); @@ -465,6 +467,7 @@ describe("Edit-metadata cross-format", () => { expect([200, 202, 400, 422]).toContain(res.statusCode); const body = JSON.parse(res.body); + if (await settleAsyncFallback(res)) return; if (res.statusCode === 200) { // inspect returns metadata fields; at minimum it is an object expect(typeof body).toBe("object"); diff --git a/tests/setup/per-fork-env.ts b/tests/setup/per-fork-env.ts index df70f3c3..f3ceb0f5 100644 --- a/tests/setup/per-fork-env.ts +++ b/tests/setup/per-fork-env.ts @@ -27,11 +27,17 @@ process.env.BULLMQ_PREFIX = `snapotter_test_${suffix}`; // test forks; 30s keeps tool routes synchronous (200) in tests while production // stays at 8s. // -// An explicit SYNC_WAIT_MS is now honored verbatim rather than floored. The +// An explicit SYNC_WAIT_MS is honored verbatim rather than floored, so the // constrained docker test image (macOS Docker VM, where Sharp and FFmpeg run -// ~2-3x slower) still widens the window, and forcing it *down* (SYNC_WAIT_MS=0) -// drives every tool through its 202 path, which is the only way to exercise -// that branch on a machine fast enough to never hit it naturally. +// ~2-3x slower) can widen the window. +// +// Careful with 0: per the repo-wide convention it means unlimited, not +// instant. BullMQ's waitUntilFinished only arms its timer under `if (ttl)`, so +// 0 waits forever and every route answers 200. To force the 202 path (the only +// way to exercise it on a machine fast enough never to hit it naturally), pass +// a small positive value such as SYNC_WAIT_MS=1. Note that most specs assert a +// bare 200 and will fail under it; only the ones that call +// settleAsyncFallback are written to survive. const requestedSyncWait = process.env.SYNC_WAIT_MS?.trim(); const hasExplicitSyncWait = Boolean(requestedSyncWait) && Number.isFinite(Number(requestedSyncWait));