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
+8
View File
@@ -235,6 +235,14 @@ describe("extractText", () => {
await expect(extractText(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(extractText(FAKE_INPUT, FAKE_OUTPUT_DIR)).rejects.toThrow("out of memory");
});
it("propagates parseStdoutJson errors", async () => {
vi.mocked(parseStdoutJson).mockImplementation(() => {
throw new Error("No JSON response from Python script");