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
+48 -1
View File
@@ -5,7 +5,7 @@ vi.mock("@/stores/connection-store", () => ({
useConnectionStore: { getState: () => ({ setDisconnected: vi.fn() }) },
}));
import { retryDynamicImport } from "@/lib/lazy-with-retry";
import { isChunkError, lazyWithRetry, retryDynamicImport } from "@/lib/lazy-with-retry";
describe("retryDynamicImport", () => {
beforeEach(() => {
@@ -70,3 +70,50 @@ describe("retryDynamicImport", () => {
expect(importFn).toHaveBeenCalledTimes(1);
});
});
describe("isChunkError", () => {
it("returns false for non-Error values", () => {
expect(isChunkError("string")).toBe(false);
expect(isChunkError(null)).toBe(false);
expect(isChunkError(undefined)).toBe(false);
expect(isChunkError(42)).toBe(false);
});
it("returns true for dynamically imported module error", () => {
expect(isChunkError(new Error("Failed to fetch dynamically imported module /foo.js"))).toBe(
true,
);
});
it("returns true for loading chunk error", () => {
expect(isChunkError(new Error("Loading chunk 123 failed"))).toBe(true);
});
it("returns true for loading CSS chunk error", () => {
expect(isChunkError(new Error("Loading CSS chunk abc-def failed"))).toBe(true);
});
it("returns true for failed to fetch error", () => {
expect(isChunkError(new TypeError("Failed to fetch"))).toBe(true);
});
it("returns true for unable to preload error", () => {
expect(isChunkError(new Error("Unable to preload CSS for /assets/foo.css"))).toBe(true);
});
it("returns false for unrelated errors", () => {
expect(isChunkError(new Error("Something else went wrong"))).toBe(false);
expect(isChunkError(new Error("Network timeout"))).toBe(false);
});
});
describe("lazyWithRetry", () => {
it("returns a React lazy component", () => {
const Comp = () => null;
const importFn = vi.fn().mockResolvedValue({ default: Comp });
const LazyComp = lazyWithRetry(importFn as any);
// React.lazy returns an object with $$typeof symbol
expect(LazyComp).toBeDefined();
expect(typeof LazyComp).toBe("object");
});
});