fix: update unit tests for DecodedPreview return type and outpaint tier arg

This commit is contained in:
SnapOtter
2026-05-13 15:53:09 +08:00
parent c3dc98834d
commit e1ca06cd95
3 changed files with 10 additions and 4 deletions
+7 -3
View File
@@ -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));