test: deepen integration tests for 8 complex tools (HEIC, large file, batch, edge cases)

This commit is contained in:
SnapOtter
2026-05-01 03:05:08 +08:00
parent 710b580cee
commit c9ed48b30e
7 changed files with 578 additions and 0 deletions
+87
View File
@@ -1454,4 +1454,91 @@ describe("Collage", () => {
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
});
// ── HEIF format input ─────────────────────────────────────────────
it("handles HEIF input images", async () => {
const HEIF = readFileSync(join(FIXTURES, "content", "motorcycle.heif"));
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.heif", contentType: "image/heif", content: HEIF },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({ templateId: "2-h-equal" }),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/collage",
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);
});
// ── Animated GIF input ────────────────────────────────────────────
it("handles animated GIF input images", async () => {
const GIF = readFileSync(join(FIXTURES, "animated.gif"));
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "a.gif", contentType: "image/gif", content: GIF },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({ templateId: "2-h-equal" }),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/collage",
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);
});
// ── SVG input ─────────────────────────────────────────────────────
it("handles SVG input images in collage", async () => {
const SVG = readFileSync(join(FIXTURES, "test-100x100.svg"));
const { body, contentType } = createMultipartPayload([
{ name: "f1", filename: "icon.svg", contentType: "image/svg+xml", content: SVG },
{ name: "f2", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{
name: "settings",
content: JSON.stringify({ templateId: "2-h-equal" }),
},
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/collage",
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);
});
});