test: expand test coverage across unit, integration, e2e, and e2e-docker suites

Add ~210 new tests filling gaps identified by a comprehensive 14-agent
coverage audit. Unit+integration tests go from 9,388 to 9,484 (all passing).

Unit tests (+36):
- AI bridge: OOM fallback path, custom tier option
- Web lib: api-errors, format date/datetime, tool-i18n coverage

Integration tests (+19):
- Format matrix: ai-canvas-expand and find-duplicates added to cross-format matrix
- Adversarial: SVG XXE attacks, SQL injection in settings, request body size
  limits, race conditions with identical filenames

E2E Docker (+3):
- ai-canvas-expand tool coverage with HEIC input and edge cases

E2E GUI (~150+):
- Navigation: login rate limiting, ai-canvas-expand in parameterized list
- Responsive: dropzone visibility, text readability, dialog bounds at all viewports
- Keyboard: shortcuts verified from automate, files, tool, and fullscreen pages
- Tool UI: undo/state-reset for 16 tools, crop canvas drag handles, rotate/border
  live preview, linked aspect-ratio inputs for resize
- Batch: per-image undo isolation, batch compress/convert/rotate (not just resize)
- Pipeline: tool palette search, step collapse/expand visibility
- Settings: audit log entry verification, system settings persistence, teams CRUD,
  role permission toggling
- RBAC: user/editor 403 on roles/teams endpoints, privilege escalation prevention,
  cross-role tab parity documented as intentional
- Accessibility: skip-to-content link (WCAG 2.4.1), comprehensive color contrast
  for all headings/body/buttons in both themes with DOM-walking background detection
- Resilience: auth expiry 401 redirect, rate limit 429 handling
- Performance: JS heap memory stability for tool navigation, dialog cycling,
  upload/clear cycles, rapid page navigation
This commit is contained in:
SnapOtter
2026-05-15 21:35:02 +08:00
parent d38621d7b9
commit 3b181dd1ac
24 changed files with 3398 additions and 0 deletions
+78
View File
@@ -65,6 +65,7 @@ async function isFeatureInstalled(
"smart-crop": "face-detection",
"erase-object": "object-eraser-colorize",
colorize: "object-eraser-colorize",
"ai-canvas-expand": "object-eraser-colorize",
upscale: "upscale-enhance",
"enhance-faces": "upscale-enhance",
"noise-removal": "upscale-enhance",
@@ -704,6 +705,78 @@ test.describe("Erase Object", () => {
});
});
// ─── AI Canvas Expand ──────────────────────────────────────────────
test.describe("AI Canvas Expand", () => {
test("expand canvas or returns 501", async ({ request }) => {
const result = await callAiTool(request, "ai-canvas-expand", JPG_100x100, {
extendTop: 50,
extendRight: 50,
extendBottom: 50,
extendLeft: 50,
tier: "fast",
});
if (!result.installed) {
expect(result.body.feature).toBe("object-eraser-colorize");
expect(result.body.code).toBe("FEATURE_NOT_INSTALLED");
test.skip();
return;
}
// AI canvas expand is async (returns 202 with jobId)
if (result.status === 202) {
expect(result.body.jobId).toBeTruthy();
expect(result.body.async).toBe(true);
} else {
expect(result.ok).toBe(true);
expect(result.body.downloadUrl).toBeTruthy();
expect(result.body.processedSize).toBeGreaterThan(0);
}
});
test("expand canvas with zero extend returns same-size image or error", async ({ request }) => {
const result = await callAiTool(request, "ai-canvas-expand", TINY_PNG, {
extendTop: 0,
extendRight: 0,
extendBottom: 0,
extendLeft: 0,
tier: "fast",
});
if (!result.installed) {
test.skip();
return;
}
// Zero expansion may succeed with unchanged image or may return validation error
if (result.ok || result.status === 202) {
expect(result.body.downloadUrl || result.body.jobId).toBeTruthy();
} else {
expect(result.body.error).toBeDefined();
}
});
test("expand canvas with HEIC input", async ({ request }) => {
const result = await callAiTool(
request,
"ai-canvas-expand",
HEIC_PORTRAIT,
{ extendRight: 100, tier: "fast" },
"portrait.heic",
"image/heic",
);
if (!result.installed) {
test.skip();
return;
}
if (result.status === 202) {
expect(result.body.jobId).toBeTruthy();
} else if (result.ok) {
expect(result.body.downloadUrl).toBeTruthy();
} else {
// May fail on edge cases -- acceptable
expect(result.body.error).toBeDefined();
}
});
});
// ─── Feature Bundle Status ──────────────────────────────────────────
test.describe("AI Feature Bundle Status", () => {
@@ -716,6 +789,11 @@ test.describe("AI Feature Bundle Status", () => {
{ tool: "erase-object", featureKey: "erase-object", bundle: "object-eraser-colorize" },
{ tool: "ocr", featureKey: "ocr", bundle: "ocr" },
{ tool: "colorize", featureKey: "colorize", bundle: "object-eraser-colorize" },
{
tool: "ai-canvas-expand",
featureKey: "ai-canvas-expand",
bundle: "object-eraser-colorize",
},
{ tool: "enhance-faces", featureKey: "enhance-faces", bundle: "upscale-enhance" },
{ tool: "noise-removal", featureKey: "noise-removal", bundle: "upscale-enhance" },
{ tool: "red-eye-removal", featureKey: "red-eye-removal", bundle: "face-detection" },