diff --git a/packages/shared/src/constants.ts b/packages/shared/src/constants.ts index 16f6ab79..77b31362 100644 --- a/packages/shared/src/constants.ts +++ b/packages/shared/src/constants.ts @@ -250,12 +250,12 @@ export const TOOLS: Tool[] = [ route: "/content-aware-resize", }, { - id: "content-aware-crop", - name: "Content-Aware Crop", - description: "Extend canvas beyond image bounds with AI-powered fill", + id: "ai-canvas-expand", + name: "AI Canvas Expand", + description: "Expand canvas with AI-powered fill", category: "ai", icon: "Expand", - route: "/content-aware-crop", + route: "/ai-canvas-expand", }, { id: "transparency-fixer", @@ -1248,5 +1248,5 @@ export const PYTHON_SIDECAR_TOOLS = [ "restore-photo", "passport-photo", "transparency-fixer", - "content-aware-crop", + "ai-canvas-expand", ] as const; diff --git a/packages/shared/src/features.ts b/packages/shared/src/features.ts index 1148c1f9..3708f23a 100644 --- a/packages/shared/src/features.ts +++ b/packages/shared/src/features.ts @@ -40,7 +40,7 @@ export const FEATURE_BUNDLES: Record = { name: "Object Eraser & Colorize", description: "Erase objects from photos and colorize B&W images", estimatedSize: "1-2 GB", - enablesTools: ["erase-object", "colorize", "content-aware-crop"], + enablesTools: ["erase-object", "colorize", "ai-canvas-expand"], }, "upscale-enhance": { id: "upscale-enhance", diff --git a/tests/integration/watermark-image.test.ts b/tests/integration/watermark-image.test.ts index 9aca327d..f1685362 100644 --- a/tests/integration/watermark-image.test.ts +++ b/tests/integration/watermark-image.test.ts @@ -210,8 +210,8 @@ describe("watermark-image", () => { // ── Branch coverage: lines 164-168 (processing failure) ─────────── - it("returns 422 when processing fails on corrupted main image", async () => { - // A buffer that passes multipart parsing but fails Sharp processing + it("returns 400 when main image is corrupted", async () => { + // A buffer that passes multipart parsing but fails image validation const corruptedBuffer = Buffer.alloc(100, 0xff); const { body, contentType } = createMultipartPayload([ { name: "file", filename: "main.png", contentType: "image/png", content: corruptedBuffer }, @@ -226,9 +226,9 @@ describe("watermark-image", () => { body, }); - expect(res.statusCode).toBe(422); + expect(res.statusCode).toBe(400); const json = JSON.parse(res.body); - expect(json.error).toContain("Processing failed"); + expect(json.error).toContain("Invalid image"); }); // ── HEIC input handling ─────────────────────────────────────────── @@ -338,7 +338,7 @@ describe("watermark-image", () => { // ── Corrupted watermark image (processing failure) ─────────────── - it("returns 422 when watermark image is corrupted", async () => { + it("returns 400 when watermark image is corrupted", async () => { const corruptedWm = Buffer.alloc(50, 0xaa); const { body, contentType } = createMultipartPayload([ { name: "file", filename: "main.png", contentType: "image/png", content: PNG }, @@ -353,9 +353,9 @@ describe("watermark-image", () => { body, }); - expect(res.statusCode).toBe(422); + expect(res.statusCode).toBe(400); const json = JSON.parse(res.body); - expect(json.error).toContain("Processing failed"); + expect(json.error).toContain("Invalid watermark image"); }); // ── Tiny 1x1 main image ────────────────────────────────────────── diff --git a/tests/unit/web/tool-registry-expanded.test.ts b/tests/unit/web/tool-registry-expanded.test.ts index 41f8915a..6acbaf50 100644 --- a/tests/unit/web/tool-registry-expanded.test.ts +++ b/tests/unit/web/tool-registry-expanded.test.ts @@ -138,6 +138,9 @@ vi.mock("@/components/tools/meme-generator-preview", () => ({ vi.mock("@/components/tools/color-blindness-settings", () => ({ ColorBlindnessSettings: () => null, })); +vi.mock("@/components/tools/ai-canvas-expand-settings", () => ({ + AiCanvasExpandSettings: () => null, +})); import { TOOLS } from "@snapotter/shared"; import type { DisplayMode, ToolRegistryEntry } from "@/lib/tool-registry"; diff --git a/tests/unit/web/tool-registry.test.ts b/tests/unit/web/tool-registry.test.ts index dae9c0a7..e26cfd96 100644 --- a/tests/unit/web/tool-registry.test.ts +++ b/tests/unit/web/tool-registry.test.ts @@ -181,6 +181,9 @@ vi.mock("@/components/tools/meme-generator-preview", () => ({ vi.mock("@/components/tools/color-blindness-settings", () => ({ ColorBlindnessSettings: () => null, })); +vi.mock("@/components/tools/ai-canvas-expand-settings", () => ({ + AiCanvasExpandSettings: () => null, +})); // --------------------------------------------------------------------------- // Import after mocks