mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: deepen integration tests for 8 complex tools (HEIC, large file, batch, edge cases)
This commit is contained in:
@@ -773,4 +773,84 @@ describe("Compare", () => {
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.similarity).toBe(100);
|
||||
});
|
||||
|
||||
// ── HEIF format input ─────────────────────────────────────────────
|
||||
|
||||
it("compares HEIF image with PNG", async () => {
|
||||
const HEIF = readFileSync(join(FIXTURES, "content", "motorcycle.heif"));
|
||||
const { body, contentType } = createMultipartPayload([
|
||||
{ name: "file", filename: "a.heif", contentType: "image/heif", content: HEIF },
|
||||
{ name: "file", filename: "b.png", contentType: "image/png", content: PNG },
|
||||
]);
|
||||
|
||||
const res = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/v1/tools/compare",
|
||||
headers: {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
"content-type": contentType,
|
||||
},
|
||||
body,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.similarity).toBeGreaterThanOrEqual(0);
|
||||
expect(result.similarity).toBeLessThanOrEqual(100);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
expect(result.dimensions.width).toBeGreaterThan(0);
|
||||
expect(result.dimensions.height).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
// ── Animated GIF input ────────────────────────────────────────────
|
||||
|
||||
it("compares animated GIF with PNG", async () => {
|
||||
const GIF = readFileSync(join(FIXTURES, "animated.gif"));
|
||||
const { body, contentType } = createMultipartPayload([
|
||||
{ name: "file", filename: "a.gif", contentType: "image/gif", content: GIF },
|
||||
{ name: "file", filename: "b.png", contentType: "image/png", content: PNG },
|
||||
]);
|
||||
|
||||
const res = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/v1/tools/compare",
|
||||
headers: {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
"content-type": contentType,
|
||||
},
|
||||
body,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.similarity).toBeGreaterThanOrEqual(0);
|
||||
expect(result.similarity).toBeLessThanOrEqual(100);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
});
|
||||
|
||||
// ── SVG input ─────────────────────────────────────────────────────
|
||||
|
||||
it("compares SVG image with PNG", async () => {
|
||||
const SVG = readFileSync(join(FIXTURES, "test-100x100.svg"));
|
||||
const { body, contentType } = createMultipartPayload([
|
||||
{ name: "file", filename: "a.svg", contentType: "image/svg+xml", content: SVG },
|
||||
{ name: "file", filename: "b.png", contentType: "image/png", content: PNG },
|
||||
]);
|
||||
|
||||
const res = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/v1/tools/compare",
|
||||
headers: {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
"content-type": contentType,
|
||||
},
|
||||
body,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.similarity).toBeGreaterThanOrEqual(0);
|
||||
expect(result.similarity).toBeLessThanOrEqual(100);
|
||||
expect(result.downloadUrl).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user