mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-22 14:51:45 +00:00
Merge branch 'dev' into search-auto-complete
This commit is contained in:
@@ -21,6 +21,7 @@ const wsMock = await import('../../../src/api/websocket');
|
||||
|
||||
// Import the API client AFTER the mock is set up so it picks up our getSocketId mock
|
||||
const {
|
||||
apiClient,
|
||||
authApi,
|
||||
tripsApi,
|
||||
placesApi,
|
||||
@@ -465,19 +466,17 @@ describe('API client interceptors', () => {
|
||||
});
|
||||
|
||||
it('FE-API-022: authApi.uploadAvatar sends multipart/form-data', async () => {
|
||||
let contentType = '';
|
||||
server.use(
|
||||
http.post('/api/auth/avatar', ({ request }) => {
|
||||
contentType = request.headers.get('Content-Type') ?? '';
|
||||
return HttpResponse.json({ avatar_url: '/uploads/avatar.jpg' });
|
||||
})
|
||||
);
|
||||
// jsdom's FormData ≠ undici's FormData — MSW body serialisation of FormData
|
||||
// hangs under CI resource constraints. Spy + mock at the axios level to verify
|
||||
// the correct args are passed without going through the network stack.
|
||||
const postSpy = vi.spyOn(apiClient, 'post').mockResolvedValueOnce({ data: { avatar_url: '/uploads/avatar.jpg' } } as any);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('avatar', new Blob(['img'], { type: 'image/jpeg' }), 'avatar.jpg');
|
||||
|
||||
await authApi.uploadAvatar(formData);
|
||||
expect(contentType).toMatch(/multipart\/form-data/);
|
||||
expect(postSpy).toHaveBeenCalledWith('/auth/avatar', expect.any(FormData), expect.anything());
|
||||
postSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('FE-API-023: authApi.mcpTokens.create posts name to /api/auth/mcp-tokens', async () => {
|
||||
@@ -887,9 +886,11 @@ describe('API namespace smoke tests', () => {
|
||||
});
|
||||
|
||||
it('backupApi.uploadRestore uploads and restores a backup', async () => {
|
||||
server.use(http.post('/api/backup/upload-restore', () => HttpResponse.json({ ok: true })));
|
||||
// FormData POST hangs on CI — mock at the axios level (see FE-API-022 comment).
|
||||
const postSpy = vi.spyOn(apiClient, 'post').mockResolvedValueOnce({ data: { ok: true } } as any);
|
||||
const file = new File(['data'], 'backup.zip', { type: 'application/zip' });
|
||||
await expect(backupApi.uploadRestore(file)).resolves.toMatchObject({ ok: true });
|
||||
postSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('backupApi.restore restores a named backup', async () => {
|
||||
|
||||
Reference in New Issue
Block a user