diff --git a/apps/web/src/api/client.test.ts b/apps/web/src/api/client.test.ts index a003086..1f8ccf8 100644 --- a/apps/web/src/api/client.test.ts +++ b/apps/web/src/api/client.test.ts @@ -1,5 +1,9 @@ -import { describe, expect, it } from "vitest"; -import { ApiFallbackError, getApiFallback } from "./client"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { api, ApiFallbackError, getApiFallback } from "./client"; + +afterEach(() => { + vi.unstubAllGlobals(); +}); describe("api fallback helpers", () => { it("extracts typed fallback payloads", () => { @@ -9,4 +13,21 @@ describe("api fallback helpers", () => { it("ignores non fallback errors", () => { expect(getApiFallback(new Error("boom"))).toBeUndefined(); }); + + it("does not send JSON content-type for bodyless delete requests", async () => { + const fetchMock = vi.fn().mockResolvedValue( + new Response(JSON.stringify({ ok: true }), { + status: 200, + headers: { "Content-Type": "application/json" } + }) + ); + vi.stubGlobal("fetch", fetchMock); + + await api.deleteLibrary(42); + + const init = fetchMock.mock.calls[0][1] as RequestInit; + const headers = new Headers(init.headers); + expect(init.method).toBe("DELETE"); + expect(headers.has("Content-Type")).toBe(false); + }); }); diff --git a/apps/web/src/api/client.ts b/apps/web/src/api/client.ts index c0f9e21..44298ef 100644 --- a/apps/web/src/api/client.ts +++ b/apps/web/src/api/client.ts @@ -56,15 +56,20 @@ function apiErrorMessage(detail: string, fallback: string): string { return fallback; } +function requestHeaders(options: RequestOptions): Headers { + const headers = new Headers(options.headers); + if (options.body !== undefined && !headers.has("Content-Type")) { + headers.set("Content-Type", "application/json"); + } + return headers; +} + async function request(path: string, options: RequestOptions = {}): Promise { try { const response = await fetch(`${API_BASE}${path}`, { ...options, credentials: "include", - headers: { - "Content-Type": "application/json", - ...options.headers - } + headers: requestHeaders(options) }); if (!response.ok) { diff --git a/apps/web/src/pages/AdminPage.tsx b/apps/web/src/pages/AdminPage.tsx index 0990dc5..2e42aef 100644 --- a/apps/web/src/pages/AdminPage.tsx +++ b/apps/web/src/pages/AdminPage.tsx @@ -158,7 +158,7 @@ export function AdminPage() {
{libraries.map((library) => (
-
+
{library.name} Chemin : {library.path}
diff --git a/apps/web/src/styles/app.css b/apps/web/src/styles/app.css index fc48d90..4f921ea 100644 --- a/apps/web/src/styles/app.css +++ b/apps/web/src/styles/app.css @@ -284,6 +284,26 @@ h2 { align-items: center; } +.library-copy { + display: grid; + gap: 7px; + min-width: 0; +} + +.library-copy strong, +.library-copy span { + display: block; +} + +.library-copy strong { + overflow-wrap: anywhere; +} + +.library-copy span { + color: var(--ink-muted); + overflow-wrap: anywhere; +} + .meter { display: block; width: 100%;