test: add OOM and downscaling test coverage across AI features

Add 12 tests for background-removal downscaling (resize gate, portrait
orientation, mask upscale) and OOM model fallback (retry with u2net,
progress callback, no-retry guards, cascading failure).

Add OOM propagation tests to face-detection, noise-removal,
red-eye-removal, and OCR -- the four AI features that were missing them.
This commit is contained in:
SnapOtter
2026-04-28 02:27:04 +08:00
parent c6c78dc76f
commit 60eb3abaa7
5 changed files with 225 additions and 0 deletions
+16
View File
@@ -167,6 +167,14 @@ describe("blurFaces", () => {
await expect(blurFaces(FAKE_INPUT, FAKE_OUTPUT_DIR)).rejects.toThrow("timed out");
});
it("propagates OOM errors from bridge", async () => {
vi.mocked(runPythonWithProgress).mockRejectedValue(
new Error("Process killed (out of memory)"),
);
await expect(blurFaces(FAKE_INPUT, FAKE_OUTPUT_DIR)).rejects.toThrow("out of memory");
});
});
describe("onProgress forwarding", () => {
@@ -282,6 +290,14 @@ describe("detectFaces", () => {
await expect(detectFaces(FAKE_INPUT)).rejects.toThrow("segmentation fault");
});
it("propagates OOM errors from bridge", async () => {
vi.mocked(runPythonWithProgress).mockRejectedValue(
new Error("Process killed (out of memory)"),
);
await expect(detectFaces(FAKE_INPUT)).rejects.toThrow("out of memory");
});
});
describe("onProgress forwarding", () => {