mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: update corrupted image test expectations from 422 to 400
validateImageBuffer catches corrupt image data before processing reaches the tool handler, so the correct status code is 400 (bad request) rather than 422 (processing failure). Also fix SVGZ watermark validation by returning early for compressed SVG (Sharp cannot read gzip-compressed SVGZ directly) and passing the actual watermark filename to validateImageBuffer for correct format detection.
This commit is contained in:
@@ -158,7 +158,7 @@ describe("Error handling", () => {
|
||||
expect(result.error).toBeDefined();
|
||||
});
|
||||
|
||||
it("returns 422 for corrupted image data", async () => {
|
||||
it("returns 400 for corrupted image data", async () => {
|
||||
const badBuffer = Buffer.from("not an image at all");
|
||||
const { body: payload, contentType } = makeFilePayload(badBuffer, "bad.png", "image/png");
|
||||
const res = await app.inject({
|
||||
@@ -170,7 +170,8 @@ describe("Error handling", () => {
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
expect(res.statusCode).toBe(422);
|
||||
// validateImageBuffer catches corrupt data before processing
|
||||
expect(res.statusCode).toBe(400);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user