test: expand test coverage across all layers (+1,157 tests)

Fix 2 failing unit tests (landing hero text mismatch) and broken
coverage tooling (brace-expansion v5 override breaking minimatch).
Add ~1,097 new test cases via 14-agent parallel expansion:

- Unit: +290 tests (AI bridge, image-engine, stores, API helpers)
- Integration: +504 tests (all tools, cross-format matrix, adversarial)
- E2E: +363 tests (navigation, tool UI, batch/pipeline, settings,
  visual regression, accessibility, performance, cross-browser)

Total: 4,223 unit + 6,057 integration + 1,563 E2E = 11,843 tests
This commit is contained in:
SnapOtter
2026-06-06 19:37:29 +08:00
parent 66e503730d
commit 06d1822491
67 changed files with 20114 additions and 49 deletions
+144
View File
@@ -1194,4 +1194,148 @@ describe("Compose", () => {
// Sharp composite will fail if overlay extends beyond canvas
expect([200, 422]).toContain(res.statusCode);
});
// ── AVIF format input ─────────────────────────────────────────────
it("handles AVIF base image", async () => {
const AVIF = readFileSync(join(FIXTURES, "formats", "sample.avif"));
const TINY = readFileSync(join(FIXTURES, "test-1x1.png"));
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "base.avif", contentType: "image/avif", content: AVIF },
{ name: "overlay", filename: "overlay.png", contentType: "image/png", content: TINY },
{ name: "settings", content: JSON.stringify({ x: 0, y: 0 }) },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/compose",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
expect(result.processedSize).toBeGreaterThan(0);
});
// ── SVGZ overlay (compose uses decodeBuffer which validates first) ──
it("handles SVGZ overlay: succeeds or returns 422 for unsupported format", async () => {
const SVGZ = readFileSync(join(FIXTURES, "formats", "sample.svgz"));
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "base.png", contentType: "image/png", content: PNG },
{ name: "overlay", filename: "overlay.svgz", contentType: "image/svg+xml", content: SVGZ },
{ name: "settings", content: JSON.stringify({ x: 10, y: 10 }) },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/compose",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
// SVGZ (gzip-compressed SVG) may not be recognized by validateImageBuffer
// depending on the validation pipeline; either succeeds or fails gracefully
expect([200, 422]).toContain(res.statusCode);
if (res.statusCode === 200) {
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
}
});
// ── Opacity at exactly 50% with multiple blend modes ────────────
it("combines hard-light blend mode with 50% opacity at position", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "base.png", contentType: "image/png", content: PNG },
{ name: "overlay", filename: "overlay.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({ x: 25, y: 25, opacity: 50, blendMode: "hard-light" }),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/compose",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.processedSize).toBeGreaterThan(0);
});
// ── Exclusion blend with low opacity at edge position ───────────
it("combines exclusion blend mode with 10% opacity at edge", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "base.png", contentType: "image/png", content: PNG },
{ name: "overlay", filename: "overlay.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({ x: 99, y: 0, opacity: 10, blendMode: "exclusion" }),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/compose",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.processedSize).toBeGreaterThan(0);
});
// ── Overlay exactly matches base dimensions at (0,0) ────────────
it("overlays same-dimension images at origin with multiply blend", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "base.png", contentType: "image/png", content: PNG },
{ name: "overlay", filename: "overlay.png", contentType: "image/png", content: PNG },
{
name: "settings",
content: JSON.stringify({ x: 0, y: 0, opacity: 80, blendMode: "multiply" }),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/compose",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
const dlRes = await app.inject({
method: "GET",
url: result.downloadUrl,
headers: { authorization: `Bearer ${adminToken}` },
});
const meta = await sharp(dlRes.rawPayload).metadata();
expect(meta.width).toBe(200);
expect(meta.height).toBe(150);
});
});