mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test(integration): accept 202 async for DNG in format-matrix smoke tests (#291)
* test(integration): accept 202 async for DNG in format-matrix smoke tests Follow-up to #290. Full-resolution DNG decode (3474x2314 vs the old 1024px preview) pushes expensive operations (AVIF encode, image-enhancement) past the 8s sync window on CI runners, so the API correctly returns 202 Accepted and processes the job asynchronously. The format-matrix smoke tests only allowed [200, 400, 422] and required a clean error body on any non-200, so they failed on the 202 (Integration shard 4/4 went red on main). 202 (accepted, async) is a valid clean response for these "no crash / clean response" checks. Make the matrix allowlists 202-tolerant and require an error body only for true error codes: - add 202 to ACCEPTABLE_CODES / ACCEPTABLE_FALLBACK_CODES + inline allowlists - change `if (statusCode !== 200)` error-body checks to `>= 400` Verified locally against Postgres+Redis: DNG tests pass both normally (200) and with SYNC_WAIT_MS=1 forcing 202 (68 passed, 0 failed each run). * test(integration): treat 202 as non-error in DNG conversion else-branches The first pass added 202 to status allowlists and switched `if (!== 200)` error checks to `>= 400`, but missed the `if (200) {...} else {...}` shape in the exotic conversion matrix and the expanded color-blindness test: their `else` caught 202 and then asserted body.error (which async responses lack). Reproduced locally by temporarily lowering the test sync-window floor to force 202 on every DNG op, then fixed every flagged assertion. Change the two `else` branches to `else if (statusCode >= 400)` so 202 (accepted, async) is a valid outcome with no sync body to verify. Verified: forced-202 across all 4 DNG matrix files = 123 passed / 0 failed; normal sync window = 34 DNG tests passed; typecheck + biome clean.
This commit is contained in:
@@ -70,7 +70,7 @@ const ALL_OUTPUT_FORMATS = ["jpg", "png", "webp", "avif", "tiff", "gif"];
|
||||
const EXTENDED_OUTPUT_FORMATS = ["heic", "jxl", "bmp", "ico", "jp2", "qoi"];
|
||||
|
||||
/** Acceptable status codes for exotic formats that may lack decoders */
|
||||
const ACCEPTABLE_CODES = [200, 400, 422];
|
||||
const ACCEPTABLE_CODES = [200, 202, 400, 422];
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Shared state
|
||||
@@ -131,7 +131,7 @@ function assertNoServerCrash(statusCode: number) {
|
||||
function assertSuccessOrCleanError(res: { statusCode: number; body: string }) {
|
||||
assertNoServerCrash(res.statusCode);
|
||||
const body = JSON.parse(res.body);
|
||||
if (res.statusCode !== 200) {
|
||||
if (res.statusCode >= 400) {
|
||||
expect(body.error).toBeDefined();
|
||||
expect(typeof body.error).toBe("string");
|
||||
expect(body.error.length).toBeGreaterThan(0);
|
||||
@@ -308,7 +308,9 @@ describe("Exotic format output conversion matrix", () => {
|
||||
// Verify output URL contains correct extension
|
||||
const ext = outFmt === "jpg" ? ".jpg" : `.${outFmt}`;
|
||||
expect(body.downloadUrl).toContain(ext);
|
||||
} else {
|
||||
} else if (res.statusCode >= 400) {
|
||||
// 202 (accepted, async) has no sync body to verify; only error
|
||||
// codes carry a JSON error.
|
||||
const body = JSON.parse(res.body);
|
||||
expect(body.error).toBeDefined();
|
||||
expect(typeof body.error).toBe("string");
|
||||
@@ -363,7 +365,7 @@ describe("Core format to extended output format matrix", () => {
|
||||
});
|
||||
|
||||
// Extended encoders may not be available
|
||||
expect([200, 400, 422]).toContain(res.statusCode);
|
||||
expect([200, 202, 400, 422]).toContain(res.statusCode);
|
||||
|
||||
if (res.statusCode === 200) {
|
||||
const body = JSON.parse(res.body);
|
||||
|
||||
Reference in New Issue
Block a user