fix(web): admin — scan initial après création, retrait des fallbacks mock

La création d'une bibliothèque déclenche un scan initial avec état de
réessai en cas d'échec; suppression des fallbacks mock sur create/scan
pour ne masquer aucune erreur réelle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Git Agent
2026-08-23 16:24:02 +02:00
parent 4aacac12da
commit a6488d160f
3 changed files with 52 additions and 13 deletions

View File

@ -31,6 +31,26 @@ describe("api fallback helpers", () => {
expect(headers.has("Content-Type")).toBe(false);
});
it("surfaces create library API errors without fallback", async () => {
const fetchMock = vi.fn().mockResolvedValue(
new Response(JSON.stringify({ message: "Library path does not exist" }), {
status: 400,
statusText: "Bad Request",
headers: { "Content-Type": "application/json" }
})
);
vi.stubGlobal("fetch", fetchMock);
await expect(api.createLibrary({ name: "Books", path: "/missing", enabled: true })).rejects.toThrow("Library path does not exist");
});
it("does not fallback when scan enqueue fails", async () => {
const fetchMock = vi.fn().mockRejectedValue(new Error("offline"));
vi.stubGlobal("fetch", fetchMock);
await expect(api.scanLibrary(42)).rejects.toThrow("offline");
});
it("sends metadata source updates to the admin endpoint", async () => {
const fetchMock = vi.fn().mockResolvedValue(
new Response(JSON.stringify({ isbnPriorityEnabled: false, sources: [] }), {