fix(api): unblock FormData Content-Type test typecheck

Avoid CFA null narrowing on the fetch-mock capture so tsc -b passes on this tip.
This commit is contained in:
Arthur Bassi 2026-07-22 13:39:51 -03:00
parent fada679b5c
commit e2687672e2

View file

@ -47,13 +47,12 @@ describe("api.post FormData Content-Type", () => {
await api.post("workorders/9/media", { body: form, throwHttpErrors: false });
expect(capturedContentType).not.toBe("application/json");
// Browser sets multipart/form-data; boundary=... when Content-Type was stripped.
// In jsdom/fetch mock the runtime may leave it null or set multipart — both are OK
// as long as it is not forced JSON.
const contentType: string | null = capturedContentType;
if (contentType !== null) {
expect(contentType.toLowerCase()).toContain("multipart/form-data");
// Fetch mock assigns inside a nested callback; CFA may keep the outer binding as null.
// Contract under test: do not force JSON Content-Type for FormData bodies.
const observedContentType = capturedContentType as string | null;
expect(observedContentType).not.toBe("application/json");
if (observedContentType) {
expect(observedContentType.toLowerCase()).toContain("multipart/form-data");
}
});
});