fix(mail-ingest): send an uploaded .eml as multipart; publish the booking origin as a contract

- The upload posted its FormData through the client's JSON default, so the
  form went as JSON and the server saw no file (400). It goes through
  postMultipart now, like every other upload.
- reservation-origin.ts becomes reservation-origin.contract.ts: the booking
  import sets an origin, and a contract is what another domain may import.
- CI: the client's strict type check holds the whole program with strict
  checks and outgrew the default ~4 GB heap; it gets 8 GB like the server's.
This commit is contained in:
Maurice
2026-11-13 20:49:08 +01:00
parent 4337969c2c
commit 29816f81a9
10 changed files with 40 additions and 9 deletions
+21
View File
@@ -0,0 +1,21 @@
// FE-MAILINGEST-API-001
import { describe, expect, it, vi } from 'vitest';
vi.mock('./client', () => ({
default: { get: vi.fn(), post: vi.fn(), patch: vi.fn(), put: vi.fn(), delete: vi.fn() },
postMultipart: vi.fn(async () => ({ duplicate: false })),
}));
import apiClient, { postMultipart } from './client';
import { mailIngestApi } from './mailIngest';
describe('mailIngestApi.upload', () => {
it('FE-MAILINGEST-API-001: sends the .eml as a multipart form, never through the JSON post', async () => {
const file = new File(['From: a@b.c\r\n\r\nhi'], 'booking.eml', { type: 'message/rfc822' });
expect(await mailIngestApi.upload(file)).toEqual({ duplicate: false });
const [url, form] = vi.mocked(postMultipart).mock.calls[0];
expect(url).toBe('/mail-ingest/upload');
expect((form as FormData).get('file')).toBe(file);
expect(apiClient.post).not.toHaveBeenCalled();
});
});