test: expand coverage across all layers -- 1,268 new tests, fix replace-color div-by-zero

14-agent parallel test expansion covering integration, unit, E2E, E2E-Docker,
cross-format matrix, adversarial, GUI navigation/tools/settings/visual/a11y/perf.

- Integration: expand 23 tool test files with HEIC, stress, batch, edge cases
- Unit: close coverage gaps in image-engine, stores, lib (metadata, auto-enhance,
  connection-store, lazy-with-retry, collage/file-store HEIC preview)
- AI bridge: 141 new tests for dispatcher buffering, crash recovery, OOM/segfault
- Cross-format: 794 parameterized tests (16 formats x 12 tools + no-crash matrix)
- Adversarial: memory stress (50x large file), zero-byte, corrupted headers, unicode
- E2E-Docker: expand 8 spec files with dimension verification, pipeline chains
- GUI E2E: tool UI settings/interactions for all 47 tools, remove all test.skip,
  RBAC per-role verification, visual screenshot naming, cross-browser smoke tests,
  a11y ARIA/focus/contrast, performance budgets, 15-tool stability test
- Fix: replace-color.ts tolerance=0 caused division-by-zero producing NaN pixels

Total: 8,958 tests passing across 202 files. Zero failures, zero skips.
This commit is contained in:
SnapOtter
2026-05-09 18:02:58 +08:00
parent 7b1f09f5d0
commit a0556772e8
76 changed files with 13112 additions and 117 deletions
+73
View File
@@ -288,5 +288,78 @@ describe("restorePhoto", () => {
expect.objectContaining({ onProgress }),
);
});
it("omits onProgress when not provided", async () => {
await restorePhoto(FAKE_INPUT, FAKE_OUTPUT_DIR);
const options = vi.mocked(runPythonWithProgress).mock.calls[0][2];
expect(options.onProgress).toBeUndefined();
});
});
describe("sharp conversion errors", () => {
it("propagates sharp toBuffer error", async () => {
vi.mocked(sharp).mockImplementation(
() =>
({
png: vi.fn().mockReturnThis(),
toBuffer: vi.fn().mockRejectedValue(new Error("Damaged TIFF")),
}) as unknown as ReturnType<typeof sharp>,
);
await expect(restorePhoto(FAKE_INPUT, FAKE_OUTPUT_DIR)).rejects.toThrow("Damaged TIFF");
});
});
describe("edge cases", () => {
it("propagates writeFile error", async () => {
vi.mocked(writeFile).mockRejectedValueOnce(new Error("ENOSPC: disk full"));
await expect(restorePhoto(FAKE_INPUT, FAKE_OUTPUT_DIR)).rejects.toThrow("disk full");
});
it("propagates readFile error after successful Python run", async () => {
vi.mocked(readFile).mockRejectedValueOnce(new Error("ENOENT: output missing"));
await expect(restorePhoto(FAKE_INPUT, FAKE_OUTPUT_DIR)).rejects.toThrow("output missing");
});
it("passes empty options as empty JSON object", async () => {
await restorePhoto(FAKE_INPUT, FAKE_OUTPUT_DIR);
const args = vi.mocked(runPythonWithProgress).mock.calls[0][1];
expect(JSON.parse(args[2])).toEqual({});
});
it("handles single-step restoration pipeline", async () => {
vi.mocked(parseStdoutJson).mockReturnValue({
success: true,
width: 400,
height: 300,
steps: ["denoise"],
scratchCoverage: 0,
facesEnhanced: 0,
isGrayscale: false,
colorized: false,
});
const result = await restorePhoto(FAKE_INPUT, FAKE_OUTPUT_DIR);
expect(result.steps).toEqual(["denoise"]);
});
it("propagates segfault from bridge", async () => {
vi.mocked(runPythonWithProgress).mockRejectedValue(
new Error("Process crashed (segmentation fault)"),
);
await expect(restorePhoto(FAKE_INPUT, FAKE_OUTPUT_DIR)).rejects.toThrow("segmentation fault");
});
it("passes mode option", async () => {
await restorePhoto(FAKE_INPUT, FAKE_OUTPUT_DIR, { mode: "light" });
const args = vi.mocked(runPythonWithProgress).mock.calls[0][1];
expect(JSON.parse(args[2])).toEqual({ mode: "light" });
});
});
});