mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: settle 202 jobs instead of returning without asserting (#652)
A 202 means the sync window expired while the job was still running. Tests treated it as a terminal pass: `if (isAsyncFallback(res)) return;` checked the envelope and returned, asserting nothing about the outcome and leaving the job running into the next test, which is the leak cancelAcceptedJobAndWait exists to prevent. Because the window only expires under load, coverage tracked runner load. On CI 44 tests took this path and verified nothing; the same tests on a dev machine asserted in full (one measured 6.4s locally against 31s on CI). settleAsyncFallback waits for a terminal state and asserts the job finished, and that a failure carries a message rather than being a crash. A clean failure stays valid, since the exotic-format fixtures are meant to be rejected. All 82 call sites moved over. per-fork-env no longer floors SYNC_WAIT_MS, so forcing it to 0 drives every request through its 202 path. 570 tests were validated that way and matched their normal-window results exactly. The 29-34s band dropped from 44 tests (23.4% of test time) to 6 (3.0%). Total test time rose 5.8% and CI wall went 12.8 to 13.1 min: the forks were doing real work during that wait, so this buys determinism, not speed. Per-shard totals unchanged at 9903 tests, 9435 passed, 468 skipped.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
import sharp from "sharp";
|
||||
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { fixtures, readFixture } from "../../../fixtures/index.js";
|
||||
import { settleAsyncFallback } from "../../settle-job.js";
|
||||
import {
|
||||
buildTestApp,
|
||||
createMultipartPayload,
|
||||
@@ -69,25 +70,11 @@ async function postTool(
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Under parallel CI load the sync window (30s) can expire before the worker
|
||||
* finishes, returning 202 {jobId, async: true}. That is a legitimate "accepted
|
||||
* & processing" outcome per the API contract. Return true so tests can skip
|
||||
* assertions that only apply to the synchronous 200 path.
|
||||
*/
|
||||
function isAsyncFallback(res: { statusCode: number; body: string }): boolean {
|
||||
if (res.statusCode !== 202) return false;
|
||||
const body = JSON.parse(res.body);
|
||||
expect(body.async).toBe(true);
|
||||
expect(body.jobId).toBeDefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── Auto mode (default) ───────────────────────────────────────────
|
||||
describe("Auto mode", () => {
|
||||
it("enhances with default settings", async () => {
|
||||
const res = await postTool({});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -96,7 +83,7 @@ describe("Auto mode", () => {
|
||||
|
||||
it("enhances with explicit auto mode", async () => {
|
||||
const res = await postTool({ mode: "auto" });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -107,7 +94,7 @@ describe("Auto mode", () => {
|
||||
describe("Enhancement modes", () => {
|
||||
it("enhances in portrait mode", async () => {
|
||||
const res = await postTool({ mode: "portrait" });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -115,7 +102,7 @@ describe("Enhancement modes", () => {
|
||||
|
||||
it("enhances in landscape mode", async () => {
|
||||
const res = await postTool({ mode: "landscape" });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -123,7 +110,7 @@ describe("Enhancement modes", () => {
|
||||
|
||||
it("enhances in low-light mode", async () => {
|
||||
const res = await postTool({ mode: "low-light" });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -131,7 +118,7 @@ describe("Enhancement modes", () => {
|
||||
|
||||
it("enhances in food mode", async () => {
|
||||
const res = await postTool({ mode: "food" });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -139,7 +126,7 @@ describe("Enhancement modes", () => {
|
||||
|
||||
it("enhances in document mode", async () => {
|
||||
const res = await postTool({ mode: "document" });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -150,7 +137,7 @@ describe("Enhancement modes", () => {
|
||||
describe("Intensity parameter", () => {
|
||||
it("enhances at minimum intensity (0)", async () => {
|
||||
const res = await postTool({ intensity: 0 });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -158,7 +145,7 @@ describe("Intensity parameter", () => {
|
||||
|
||||
it("enhances at maximum intensity (100)", async () => {
|
||||
const res = await postTool({ intensity: 100 });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -166,7 +153,7 @@ describe("Intensity parameter", () => {
|
||||
|
||||
it("enhances at mid intensity (50, default)", async () => {
|
||||
const res = await postTool({ intensity: 50 });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
});
|
||||
});
|
||||
@@ -184,7 +171,7 @@ describe("Selective corrections", () => {
|
||||
denoise: false,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -201,7 +188,7 @@ describe("Selective corrections", () => {
|
||||
denoise: true,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -218,7 +205,7 @@ describe("Selective corrections", () => {
|
||||
denoise: false,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
});
|
||||
});
|
||||
@@ -227,7 +214,7 @@ describe("Selective corrections", () => {
|
||||
describe("Output verification", () => {
|
||||
it("output differs from input", async () => {
|
||||
const res = await postTool({ mode: "auto", intensity: 80 });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -242,7 +229,7 @@ describe("Output verification", () => {
|
||||
|
||||
it("preserves image dimensions", async () => {
|
||||
const res = await postTool({ mode: "auto" });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -272,7 +259,7 @@ describe("Analyze endpoint", () => {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
// Analysis should return corrections object
|
||||
@@ -300,7 +287,7 @@ describe("Analyze endpoint", () => {
|
||||
describe("Multiple input formats", () => {
|
||||
it("enhances JPEG input", async () => {
|
||||
const res = await postTool({ mode: "auto" }, JPG, "test.jpg", "image/jpeg");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -308,7 +295,7 @@ describe("Multiple input formats", () => {
|
||||
|
||||
it("enhances WebP input", async () => {
|
||||
const res = await postTool({ mode: "auto" }, WEBP, "test.webp", "image/webp");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -319,7 +306,7 @@ describe("Multiple input formats", () => {
|
||||
describe("Mode and intensity combinations", () => {
|
||||
it("applies portrait mode at high intensity", async () => {
|
||||
const res = await postTool({ mode: "portrait", intensity: 90 });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -333,7 +320,7 @@ describe("Mode and intensity combinations", () => {
|
||||
|
||||
it("applies low-light mode at low intensity", async () => {
|
||||
const res = await postTool({ mode: "low-light", intensity: 10 });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.processedSize).toBeGreaterThan(0);
|
||||
@@ -341,7 +328,7 @@ describe("Mode and intensity combinations", () => {
|
||||
|
||||
it("applies food mode at zero intensity (no-op)", async () => {
|
||||
const res = await postTool({ mode: "food", intensity: 0 });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
});
|
||||
});
|
||||
@@ -361,7 +348,7 @@ describe("Analyze endpoint details", () => {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.corrections).toBeDefined();
|
||||
@@ -381,7 +368,7 @@ describe("Analyze endpoint details", () => {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.corrections).toBeDefined();
|
||||
@@ -403,7 +390,7 @@ describe("Full corrections suite", () => {
|
||||
denoise: true,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -415,7 +402,7 @@ describe("Full corrections suite", () => {
|
||||
describe("Format preservation", () => {
|
||||
it("preserves JPEG format for JPEG input", async () => {
|
||||
const res = await postTool({ mode: "auto" }, JPG, "test.jpg", "image/jpeg");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -594,7 +581,7 @@ describe("Alpha channel preservation", () => {
|
||||
"rgba.png",
|
||||
"image/png",
|
||||
);
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -630,7 +617,7 @@ describe("Alpha channel preservation", () => {
|
||||
"semi.png",
|
||||
"image/png",
|
||||
);
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -679,7 +666,7 @@ describe("Tiny file handling", () => {
|
||||
it("enhances a 1x1 pixel image", async () => {
|
||||
const tiny = readFixture(fixtures.image.edge.px1);
|
||||
const res = await postTool({ mode: "auto" }, tiny, "tiny.png", "image/png");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.processedSize).toBeGreaterThan(0);
|
||||
@@ -698,7 +685,7 @@ describe("Empty file handling", () => {
|
||||
describe("Document mode variations", () => {
|
||||
it("enhances JPEG in document mode at high intensity", async () => {
|
||||
const res = await postTool({ mode: "document", intensity: 90 }, JPG, "doc.jpg", "image/jpeg");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -711,7 +698,7 @@ describe("Document mode variations", () => {
|
||||
"landscape.webp",
|
||||
"image/webp",
|
||||
);
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
});
|
||||
});
|
||||
@@ -760,7 +747,7 @@ describe("SVG input", () => {
|
||||
describe("Animated GIF input", () => {
|
||||
it("enhances animated GIF input", async () => {
|
||||
const res = await postTool({ mode: "auto" }, GIF, "animated.gif", "image/gif");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -781,7 +768,7 @@ describe("Selective correction edge cases", () => {
|
||||
denoise: false,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
});
|
||||
|
||||
@@ -797,7 +784,7 @@ describe("Selective correction edge cases", () => {
|
||||
denoise: false,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
});
|
||||
});
|
||||
@@ -811,7 +798,7 @@ describe("Partial corrections object", () => {
|
||||
contrast: false,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -821,7 +808,7 @@ describe("Partial corrections object", () => {
|
||||
const res = await postTool({
|
||||
corrections: {},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -832,7 +819,7 @@ describe("Partial corrections object", () => {
|
||||
describe("Output format for different input formats", () => {
|
||||
it("preserves WebP format for WebP input", async () => {
|
||||
const res = await postTool({ mode: "auto" }, WEBP, "test.webp", "image/webp");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -847,7 +834,7 @@ describe("Output format for different input formats", () => {
|
||||
|
||||
it("preserves PNG format for PNG input", async () => {
|
||||
const res = await postTool({ mode: "auto" }, PNG, "test.png", "image/png");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -865,7 +852,7 @@ describe("Output format for different input formats", () => {
|
||||
describe("Output dimension verification", () => {
|
||||
it("preserves JPEG input dimensions", async () => {
|
||||
const res = await postTool({ mode: "auto" }, JPG, "test.jpg", "image/jpeg");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -881,7 +868,7 @@ describe("Output dimension verification", () => {
|
||||
|
||||
it("preserves WebP input dimensions", async () => {
|
||||
const res = await postTool({ mode: "landscape" }, WEBP, "test.webp", "image/webp");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -900,7 +887,7 @@ describe("Output dimension verification", () => {
|
||||
describe("Response structure", () => {
|
||||
it("returns all expected fields in 200 response", async () => {
|
||||
const res = await postTool({ mode: "auto" });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -931,7 +918,7 @@ describe("Analyze endpoint format coverage", () => {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.corrections).toBeDefined();
|
||||
@@ -957,7 +944,7 @@ describe("Analyze endpoint format coverage", () => {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.corrections).toBeDefined();
|
||||
@@ -980,7 +967,7 @@ describe("Mode with selective corrections", () => {
|
||||
denoise: false,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -999,7 +986,7 @@ describe("Mode with selective corrections", () => {
|
||||
denoise: true,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
});
|
||||
});
|
||||
@@ -1027,7 +1014,7 @@ describe("Large file with modes", () => {
|
||||
"stress-large.jpg",
|
||||
"image/jpeg",
|
||||
);
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.processedSize).toBeGreaterThan(0);
|
||||
@@ -1041,7 +1028,7 @@ describe("Large file with modes", () => {
|
||||
"stress-large.jpg",
|
||||
"image/jpeg",
|
||||
);
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.processedSize).toBeGreaterThan(0);
|
||||
@@ -1052,7 +1039,7 @@ describe("Large file with modes", () => {
|
||||
describe("Deep Enhance", () => {
|
||||
it("accepts deepEnhance setting and returns 200", async () => {
|
||||
const res = await postTool({ deepEnhance: true });
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -1061,7 +1048,7 @@ describe("Deep Enhance", () => {
|
||||
|
||||
it("works without deepEnhance (default false)", async () => {
|
||||
const res = await postTool({});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -1095,7 +1082,7 @@ describe("Darkening regression", () => {
|
||||
"midgray.jpg",
|
||||
"image/jpeg",
|
||||
);
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -1131,7 +1118,7 @@ describe("Darkening regression", () => {
|
||||
const originalMean = originalStats.channels[0].mean;
|
||||
|
||||
const res = await postTool({ mode: "auto", intensity: 50 }, bright, "bright.jpg", "image/jpeg");
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
|
||||
@@ -1158,7 +1145,7 @@ describe("Portrait image enhancement", () => {
|
||||
"portrait.jpg",
|
||||
"image/jpeg",
|
||||
);
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
@@ -1182,7 +1169,7 @@ describe("Portrait image enhancement", () => {
|
||||
"portrait-color.jpg",
|
||||
"image/jpeg",
|
||||
);
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.processedSize).toBeGreaterThan(0);
|
||||
@@ -1212,7 +1199,7 @@ describe("Batch processing", () => {
|
||||
},
|
||||
});
|
||||
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.headers["content-type"]).toBe("application/zip");
|
||||
|
||||
@@ -1261,7 +1248,7 @@ describe("Analyze endpoint response structure", () => {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result).toHaveProperty("scores");
|
||||
@@ -1321,7 +1308,7 @@ describe("Low-light image analysis", () => {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
if (isAsyncFallback(res)) return;
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.suggestedMode).toBe("low-light");
|
||||
|
||||
Reference in New Issue
Block a user