fix: harden production flows and user messaging

This commit is contained in:
Leon Tonhäuser committed 2026-08-11 16:07:13 +02:00
1 parent 52dce168dd
commit 86dfe8053d
43 files changed
+3520 -358

No files matched your search

+14 -1
View File
@@ -28,11 +28,13 @@ function createCatalog(options?: {
return { items: [], total: 0, nextPage: null, previousPage: null };
}),
};
const consumeRateLimit = vi.fn().mockResolvedValue({ allowed: true, retryAfterSeconds: 0 });
return {
catalog: createAlbumCatalog({ grants, immich }),
catalog: createAlbumCatalog({ grants, immich, consumeRateLimit }),
grants,
immich,
consumeRateLimit,
};
}
@@ -141,3 +143,14 @@ test("does not expose a caller-controlled asset type in the catalog contract", a
expect(immich.searchPhotos).toHaveBeenCalledWith(expect.objectContaining({ type: "IMAGE" }));
});
test("rate-limits description searches per authenticated editorial", async () => {
const { catalog, consumeRateLimit, immich } = createCatalog();
consumeRateLimit.mockResolvedValue({ allowed: false, retryAfterSeconds: 19 });
await expect(
catalog.searchVisiblePhotos("editorial-1", { description: "Tor", page: 1 }),
).rejects.toMatchObject({ code: "RATE_LIMITED", retryAfterSeconds: 19 });
expect(consumeRateLimit).toHaveBeenCalledWith("search:editorial-1", expect.any(Object));
expect(immich.searchPhotos).not.toHaveBeenCalled();
});