From e1ca06cd955537c62ec4b8fb8d5d1f860ae7dd44 Mon Sep 17 00:00:00 2001 From: SnapOtter Date: Wed, 13 May 2026 15:53:09 +0800 Subject: [PATCH] fix: update unit tests for DecodedPreview return type and outpaint tier arg --- tests/unit/ai/outpaint.test.ts | 1 + tests/unit/web/image-preview-download.test.ts | 3 ++- tests/unit/web/zustand-stores.test.ts | 10 +++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/unit/ai/outpaint.test.ts b/tests/unit/ai/outpaint.test.ts index 3963034a..bc72cdb3 100644 --- a/tests/unit/ai/outpaint.test.ts +++ b/tests/unit/ai/outpaint.test.ts @@ -87,6 +87,7 @@ describe("outpaint", () => { "20", "30", "40", + "balanced", ], expect.any(Object), ); diff --git a/tests/unit/web/image-preview-download.test.ts b/tests/unit/web/image-preview-download.test.ts index e64c0e0a..aa19bbc5 100644 --- a/tests/unit/web/image-preview-download.test.ts +++ b/tests/unit/web/image-preview-download.test.ts @@ -118,6 +118,7 @@ describe("fetchDecodedPreview", () => { fetchMock.mockResolvedValueOnce({ ok: true, blob: () => Promise.resolve(blob), + headers: { get: () => null }, }); const file = new File(["heic-data"], "photo.heic", { type: "image/heic" }); @@ -132,7 +133,7 @@ describe("fetchDecodedPreview", () => { const formData = opts.body as FormData; expect(formData.get("file")).toBe(file); - expect(result).toBe("blob:preview-url"); + expect(result?.url).toBe("blob:preview-url"); expect(createObjectURL).toHaveBeenCalledWith(blob); }); diff --git a/tests/unit/web/zustand-stores.test.ts b/tests/unit/web/zustand-stores.test.ts index 6aa8fe68..bd95b2af 100644 --- a/tests/unit/web/zustand-stores.test.ts +++ b/tests/unit/web/zustand-stores.test.ts @@ -1535,7 +1535,11 @@ describe("useCollageStore", () => { const needsMock = vi.mocked(imagePreview.needsServerPreview); const fetchPreviewMock = vi.mocked(imagePreview.fetchDecodedPreview); needsMock.mockReturnValueOnce(true); - fetchPreviewMock.mockResolvedValueOnce("blob:preview-decoded"); + fetchPreviewMock.mockResolvedValueOnce({ + url: "blob:preview-decoded", + originalWidth: null, + originalHeight: null, + }); const heicFile = new File(["heic-data"], "photo.heic", { type: "image/heic" }); useCollageStore.getState().addImages([heicFile]); @@ -1559,7 +1563,7 @@ describe("useCollageStore", () => { const fetchPreviewMock = vi.mocked(imagePreview.fetchDecodedPreview); needsMock.mockReturnValueOnce(true); - let resolvePreview!: (v: string | null) => void; + let resolvePreview!: (v: import("@/lib/image-preview").DecodedPreview | null) => void; fetchPreviewMock.mockReturnValueOnce( new Promise((resolve) => { resolvePreview = resolve; @@ -1573,7 +1577,7 @@ describe("useCollageStore", () => { useCollageStore.getState().removeImage(0); // Now resolve the preview -- should not crash (idx === -1 path) - resolvePreview("blob:late-preview"); + resolvePreview({ url: "blob:late-preview", originalWidth: null, originalHeight: null }); // Give the promise chain time to settle await new Promise((r) => setTimeout(r, 10));