fix(mail): search every owned job
CI and Deploy / test (pull_request) Successful in 5m13s
CI and Deploy / deploy (pull_request) Has been skipped

Replace ineffective pageSize=100 selectors with a bounded owner-filtered search endpoint for composing and moving linked threads.
This commit is contained in:
cesnimda
2026-08-15 20:13:14 +02:00
parent dc511296a4
commit a08ba9b45d
9 changed files with 167 additions and 57 deletions
@@ -66,6 +66,7 @@ describe('CorrespondenceInboxPage', () => {
},
] } as any);
if (url === '/email/drafts') return Promise.resolve({ data: [] } as any);
if (url === '/jobapplications/choices') return Promise.resolve({ data: [] } as any);
if (url === '/email/message') return Promise.resolve({ data: {
id: 'message-1', threadId: 'thread-1', subject: 'Interview invite', from: 'Maria Recruiter <maria@acme.test>', to: 'user@example.test',
date: new Date().toISOString(), snippet: 'Interview', bodyText: 'Please choose an interview time.', labels: ['INBOX'], attachments: [{ fileName: 'agenda.pdf' }],
@@ -328,9 +329,9 @@ describe('CorrespondenceInboxPage', () => {
{ provider: 'gmail', displayName: 'Gmail', connected: true, address: 'owner@gmail.test', canRead: true, canSend: true },
{ provider: 'microsoft', displayName: 'Outlook', connected: true, address: 'owner@outlook.test', canRead: true, canSend: false },
] } as any);
if (url === '/jobapplications') return Promise.resolve({ data: { items: [
{ id: 42, jobTitle: 'Backend Engineer', company: { name: 'Acme Systems' } },
] } } as any);
if (url === '/jobapplications/choices') return Promise.resolve({ data: [
{ id: 42, jobTitle: 'Backend Engineer', companyName: 'Acme Systems' },
] } as any);
return original!(url, config);
});
mockedApi.post.mockImplementation((url: string) => {
@@ -371,6 +372,34 @@ describe('CorrespondenceInboxPage', () => {
}));
});
test('searches the complete server-side job choice set while composing', async () => {
const original = mockedApi.get.getMockImplementation();
mockedApi.get.mockImplementation((url: string, config?: any) => {
if (url === '/email/providers') return Promise.resolve({ data: [
{ provider: 'gmail', displayName: 'Gmail', connected: true, address: 'owner@gmail.test', canRead: true, canSend: true },
] } as any);
if (url === '/jobapplications/choices') {
return Promise.resolve({ data: config?.params?.q === 'Historic'
? [{ id: 7, jobTitle: 'Historic target role', companyName: 'Archive Co' }]
: [{ id: 42, jobTitle: 'Recent role', companyName: 'Acme Systems' }] } as any);
}
return original!(url, config);
});
renderPage();
const compose = await screen.findByRole('button', { name: /compose new email/i });
await waitFor(() => expect(compose).toBeEnabled());
fireEvent.click(compose);
fireEvent.change(screen.getByRole('combobox', { name: /^job$/i }), { target: { value: 'Historic' } });
await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith('/jobapplications/choices', {
params: { q: 'Historic', limit: 20 },
}));
fireEvent.click(await screen.findByRole('option', { name: /Archive Co.*Historic target role/i }));
fireEvent.click(screen.getByRole('button', { name: /start draft/i }));
expect(screen.getByText(/Archive Co.*Historic target role/i)).toBeInTheDocument();
});
test('does not offer retry when delivery is uncertain', async () => {
const original = mockedApi.get.getMockImplementation();
mockedApi.get.mockImplementation((url: string, config?: any) => {