From 0576d946c508ad56346fc10529f8424c54c7bcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Tue, 11 Aug 2026 11:27:44 +0200 Subject: [PATCH] fix: resolve remaining typescript errors --- .../[assetId]/thumbnail/thumbnail-handler.ts | 1 - tests/db/accounting-migration.test.ts | 2 +- tests/db/usage-accounting.test.ts | 32 +++++++++++-------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts b/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts index c4c8e27..4adcf2a 100644 --- a/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts +++ b/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts @@ -9,7 +9,6 @@ import sharp from "sharp"; type ThumbnailRouteContext = Readonly<{ params: Promise<{ assetId: string }> }>; type ThumbnailImmich = { - listAlbumsForAsset(assetId: string): Promise>; getAlbum(albumId: string): Promise<{ albumThumbnailAssetId: string | null }>; getAsset(assetId: string): Promise<{ albums: Array<{ id: string }> }>; getThumbnail(assetId: string): Promise; diff --git a/tests/db/accounting-migration.test.ts b/tests/db/accounting-migration.test.ts index bf95d50..866d854 100644 --- a/tests/db/accounting-migration.test.ts +++ b/tests/db/accounting-migration.test.ts @@ -222,7 +222,7 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents", status: "authorized", authorizedAt, }); - expect(immich.listAlbumsForAsset).not.toHaveBeenCalled(); + expect(immich.getAlbum).not.toHaveBeenCalled(); expect(immich.getAsset).not.toHaveBeenCalled(); const migratedEvents = await testDb.pool.query<{ diff --git a/tests/db/usage-accounting.test.ts b/tests/db/usage-accounting.test.ts index fdecab1..90b803a 100644 --- a/tests/db/usage-accounting.test.ts +++ b/tests/db/usage-accounting.test.ts @@ -219,17 +219,21 @@ test("requires an active grant for the exact requested album", async () => { test("rechecks exact album membership after database locks before inserting", async () => { const editorialId = await seedEditorial(); const { usageService, immich } = createServices(); - immich.listAlbumsForAsset - .mockResolvedValueOnce([ - { - id: albumId, - albumName: "Presse 2026", - description: null, - albumThumbnailAssetId: assetId, - assetCount: 1, - }, - ]) - .mockResolvedValueOnce([]); + immich.getAsset + .mockResolvedValueOnce({ + id: assetId, + type: "IMAGE" as const, + originalFileName: "jubel.jpg", + originalMimeType: "image/jpeg", + albums: [{ id: albumId }], + }) + .mockResolvedValueOnce({ + id: assetId, + type: "IMAGE" as const, + originalFileName: "jubel.jpg", + originalMimeType: "image/jpeg", + albums: [], + }); await expect(usageService.createNewUsage(newInput(editorialId))).rejects.toMatchObject({ code: "ASSET_NOT_IN_ALBUM", @@ -238,7 +242,7 @@ test("rechecks exact album membership after database locks before inserting", as .select({ value: count() }) .from(usages) .where(eq(usages.editorialAccountId, editorialId)); - expect(immich.listAlbumsForAsset).toHaveBeenCalledTimes(2); + expect(immich.getAlbum).toHaveBeenCalledTimes(2); expect(usageCount.value).toBe(0); }); @@ -292,7 +296,7 @@ test("returns a winner committed while waiting before later mutable state is che authorizedAt: winner.authorizedAt, billable: true, }); - expect(immich.listAlbumsForAsset).toHaveBeenCalledTimes(1); + expect(immich.getAlbum).toHaveBeenCalledTimes(1); expect(immich.getAsset).toHaveBeenCalledTimes(1); } finally { await locker.query("rollback"); @@ -334,7 +338,7 @@ test("reports a conflicting winner committed while waiting before later state er await locker.query("commit"); await expect(pending).rejects.toMatchObject({ code: "IDEMPOTENCY_CONFLICT" }); - expect(immich.listAlbumsForAsset).toHaveBeenCalledTimes(1); + expect(immich.getAlbum).toHaveBeenCalledTimes(1); expect(immich.getAsset).toHaveBeenCalledTimes(1); } finally { await locker.query("rollback");