feat(web): page admin des sources de métadonnées et de l'automatisation
Configuration des providers (activation, priorité, clé API), réglages d'automatisation (watch des bibliothèques, auto-enrichissement, planifications scan/enrichissement) et déclenchement manuel, avec client API, mocks et styles associés. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -30,4 +30,58 @@ describe("api fallback helpers", () => {
|
||||
expect(init.method).toBe("DELETE");
|
||||
expect(headers.has("Content-Type")).toBe(false);
|
||||
});
|
||||
|
||||
it("sends metadata source updates to the admin endpoint", async () => {
|
||||
const fetchMock = vi.fn().mockResolvedValue(
|
||||
new Response(JSON.stringify({ isbnPriorityEnabled: false, sources: [] }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" }
|
||||
})
|
||||
);
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
await api.updateMetadataSources({
|
||||
isbnPriorityEnabled: false,
|
||||
sources: [{ provider: "openlibrary", enabled: true, priority: 1 }]
|
||||
});
|
||||
|
||||
expect(fetchMock.mock.calls[0][0]).toBe("/admin/metadata-sources");
|
||||
const init = fetchMock.mock.calls[0][1] as RequestInit;
|
||||
expect(init.method).toBe("PUT");
|
||||
expect(JSON.parse(init.body as string)).toEqual({
|
||||
isbnPriorityEnabled: false,
|
||||
sources: [{ provider: "openlibrary", enabled: true, priority: 1 }]
|
||||
});
|
||||
});
|
||||
|
||||
it("sends automation settings to the admin endpoint", async () => {
|
||||
const fetchMock = vi.fn().mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
watchLibraries: true,
|
||||
autoEnrichNewBooks: true,
|
||||
scanSchedule: { frequency: "daily", time: "03:00", dayOfWeek: 1 },
|
||||
enrichSchedule: { frequency: "disabled", time: "04:00", dayOfWeek: 1 }
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}
|
||||
)
|
||||
);
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
await api.updateAutomationSettings({
|
||||
watchLibraries: true,
|
||||
scanSchedule: { frequency: "daily", time: "03:00", dayOfWeek: 1 }
|
||||
});
|
||||
|
||||
expect(fetchMock.mock.calls[0][0]).toBe("/admin/automation");
|
||||
const init = fetchMock.mock.calls[0][1] as RequestInit;
|
||||
expect(init.method).toBe("PUT");
|
||||
expect(JSON.parse(init.body as string)).toEqual({
|
||||
watchLibraries: true,
|
||||
scanSchedule: { frequency: "daily", time: "03:00", dayOfWeek: 1 }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user