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
+293
View File
@@ -1829,4 +1829,297 @@ describe("Stitch", () => {
expect(meta.height).toBe(110); // 100 + 2*5
expect(meta.channels).toBe(4); // corner radius adds alpha
});
// ── AVIF format input ─────────────────────────────────────────────
it("handles AVIF input in stitching", async () => {
const AVIF = readFileSync(join(FIXTURES, "formats", "sample.avif"));
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.avif", contentType: "image/avif", content: AVIF },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({ direction: "horizontal" }),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/stitch",
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 input ───────────────────────────────────────────────────
it("handles SVGZ (compressed SVG) input in stitching", async () => {
const SVGZ = readFileSync(join(FIXTURES, "formats", "sample.svgz"));
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "icon.svgz", contentType: "image/svg+xml", content: SVGZ },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({ direction: "horizontal" }),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/stitch",
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);
});
// ── Grid with 1 column (single column layout) ───────────────────
it("stitches grid with gridColumns=2 and exactly 2 images", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.jpg", contentType: "image/jpeg", content: JPG },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({
direction: "grid",
gridColumns: 2,
resizeMode: "original",
}),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/stitch",
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();
// 2 cols, 1 row of 100x100
expect(meta.width).toBe(200);
expect(meta.height).toBe(100);
});
// ── Center alignment explicit in vertical mode ──────────────────
it("applies center alignment explicitly in vertical mode", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.png", contentType: "image/png", content: PNG },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({
direction: "vertical",
resizeMode: "original",
alignment: "center",
}),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/stitch",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
});
// ── Start alignment in vertical mode ────────────────────────────
it("applies start alignment in vertical mode", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.png", contentType: "image/png", content: PNG },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({
direction: "vertical",
resizeMode: "original",
alignment: "start",
}),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/stitch",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
});
// ── End alignment in horizontal mode ────────────────────────────
it("applies end alignment in horizontal mode", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.png", contentType: "image/png", content: PNG },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({
direction: "horizontal",
resizeMode: "original",
alignment: "end",
}),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/stitch",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
});
// ── Combined: all settings together ─────────────────────────────
it("combines all settings: direction, resize, alignment, gap, border, cornerRadius, bg, format", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.png", contentType: "image/png", content: PNG },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({
direction: "vertical",
resizeMode: "stretch",
alignment: "end",
gap: 8,
border: 4,
cornerRadius: 10,
backgroundColor: "#FF00FF",
format: "webp",
quality: 75,
}),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/stitch",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.processedSize).toBeGreaterThan(0);
const dlRes = await app.inject({
method: "GET",
url: result.downloadUrl,
headers: { authorization: `Bearer ${adminToken}` },
});
const meta = await sharp(dlRes.rawPayload).metadata();
expect(meta.format).toBe("webp");
});
// ── Quality at boundary (1 = minimum) ───────────────────────────
it("accepts quality at minimum (1) for jpeg output", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.png", contentType: "image/png", content: PNG },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({
direction: "horizontal",
format: "jpeg",
quality: 1,
}),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/stitch",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.processedSize).toBeGreaterThan(0);
});
// ── Quality below minimum rejects ───────────────────────────────
it("rejects quality below minimum (0)", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.png", contentType: "image/png", content: PNG },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({
direction: "horizontal",
quality: 0,
}),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/stitch",
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect(res.statusCode).toBe(400);
});
});