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
+149
View File
@@ -1130,4 +1130,153 @@ describe("svg-to-raster", () => {
expect(json.downloadUrl).toBeDefined();
expect(json.previewUrl).toBeDefined();
});
// ── SVGZ (compressed SVG) input ──────────────────────────────────
it("converts a SVGZ (compressed SVG) to PNG", async () => {
const SVGZ = readFileSync(join(FIXTURES, "formats", "sample.svgz"));
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "icon.svgz", contentType: "image/svg+xml", content: SVGZ },
{ name: "settings", content: JSON.stringify({ outputFormat: "png" }) },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/svg-to-raster",
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
body,
});
expect(res.statusCode).toBe(200);
const json = JSON.parse(res.body);
expect(json.downloadUrl).toBeDefined();
expect(json.processedSize).toBeGreaterThan(0);
const dlRes = await app.inject({
method: "GET",
url: json.downloadUrl,
headers: { authorization: `Bearer ${adminToken}` },
});
const meta = await sharp(Buffer.from(dlRes.rawPayload)).metadata();
expect(meta.format).toBe("png");
});
// ── DPI at minimum (36) ──────────────────────────────────────────
it("accepts DPI at minimum boundary (36)", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "test.svg", contentType: "image/svg+xml", content: SVG },
{ name: "settings", content: JSON.stringify({ dpi: 36 }) },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/svg-to-raster",
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
body,
});
expect(res.statusCode).toBe(200);
const json = JSON.parse(res.body);
expect(json.processedSize).toBeGreaterThan(0);
});
// ── DPI below minimum rejects ────────────────────────────────────
it("rejects DPI below minimum (35)", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "test.svg", contentType: "image/svg+xml", content: SVG },
{ name: "settings", content: JSON.stringify({ dpi: 35 }) },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/svg-to-raster",
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
body,
});
expect(res.statusCode).toBe(400);
});
// ── Width at minimum (1) ─────────────────────────────────────────
it("accepts width at minimum (1)", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "test.svg", contentType: "image/svg+xml", content: SVG },
{ name: "settings", content: JSON.stringify({ width: 1 }) },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/svg-to-raster",
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
body,
});
expect(res.statusCode).toBe(200);
const json = JSON.parse(res.body);
expect(json.processedSize).toBeGreaterThan(0);
});
// ── Height at minimum (1) ────────────────────────────────────────
it("accepts height at minimum (1)", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "test.svg", contentType: "image/svg+xml", content: SVG },
{ name: "settings", content: JSON.stringify({ height: 1 }) },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/svg-to-raster",
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
body,
});
expect(res.statusCode).toBe(200);
const json = JSON.parse(res.body);
expect(json.processedSize).toBeGreaterThan(0);
});
// ── DPI at max boundary (2400) ───────────────────────────────────
it("accepts DPI at maximum boundary (2400)", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "test.svg", contentType: "image/svg+xml", content: SVG },
{ name: "settings", content: JSON.stringify({ dpi: 2400, width: 100 }) },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/svg-to-raster",
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
body,
});
expect(res.statusCode).toBe(200);
const json = JSON.parse(res.body);
expect(json.processedSize).toBeGreaterThan(0);
});
// ── Batch with SVGZ input ────────────────────────────────────────
it("batch converts SVGZ files to PNG", async () => {
const SVGZ = readFileSync(join(FIXTURES, "formats", "sample.svgz"));
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "a.svgz", contentType: "image/svg+xml", content: SVGZ },
{ name: "file", filename: "b.svg", contentType: "image/svg+xml", content: SVG },
{ name: "settings", content: JSON.stringify({ outputFormat: "png" }) },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/svg-to-raster/batch",
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
body,
});
expect(res.statusCode).toBe(200);
expect(res.headers["content-type"]).toBe("application/zip");
});
});