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
@@ -1485,6 +1485,93 @@ describe("Stitch", () => {
expect(result.downloadUrl).toBeDefined();
});
// ── HEIF format input ─────────────────────────────────────────────
it("handles HEIF input in stitching", 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({ 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);
});
// ── Animated GIF input ────────────────────────────────────────────
it("handles animated GIF input in stitching", 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({ 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);
});
// ── SVG input ─────────────────────────────────────────────────────
it("handles SVG input in stitching", 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({ 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);
});
// ── Branch coverage: vertical crop with very different sizes ───────
it("stitches vertically with crop mode using very different image sizes", async () => {