fix(scale): page mail and batch roles
This commit is contained in:
@@ -44,7 +44,7 @@ describe('CorrespondenceInboxPage', () => {
|
||||
{ provider: 'gmail', displayName: 'Gmail', connected: true, address: 'owner@gmail.test', canRead: true, canSend: false },
|
||||
{ provider: 'microsoft', displayName: 'Outlook', connected: false, address: null, canRead: false, canSend: false },
|
||||
] } as any);
|
||||
if (url === '/correspondence') return Promise.resolve({ data: [
|
||||
if (url === '/correspondence/page') return Promise.resolve({ data: { items: [
|
||||
{
|
||||
id: 1,
|
||||
jobApplicationId: 42,
|
||||
@@ -64,7 +64,7 @@ describe('CorrespondenceInboxPage', () => {
|
||||
labelCount: 2,
|
||||
attachmentCount: 1,
|
||||
},
|
||||
] } as any);
|
||||
], page: 1, pageSize: 50, total: 1, totalPages: 1 } } 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: {
|
||||
@@ -101,10 +101,12 @@ describe('CorrespondenceInboxPage', () => {
|
||||
fireEvent.click((await screen.findAllByRole('option', { name: /Inbound/i }))[0]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockedApi.get).toHaveBeenLastCalledWith('/correspondence', expect.objectContaining({
|
||||
expect(mockedApi.get).toHaveBeenLastCalledWith('/correspondence/page', expect.objectContaining({
|
||||
params: expect.objectContaining({
|
||||
q: 'Maria',
|
||||
direction: 'inbound',
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
}),
|
||||
}));
|
||||
});
|
||||
@@ -137,6 +139,44 @@ describe('CorrespondenceInboxPage', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('navigates beyond the first correspondence page', async () => {
|
||||
const original = mockedApi.get.getMockImplementation();
|
||||
mockedApi.get.mockImplementation((url: string, config?: any) => {
|
||||
if (url === '/correspondence/page') {
|
||||
const page = config?.params?.page ?? 1;
|
||||
return Promise.resolve({ data: {
|
||||
items: [{
|
||||
id: page,
|
||||
jobApplicationId: 42,
|
||||
companyName: page === 2 ? 'Second page company' : 'First page company',
|
||||
jobTitle: 'Engineer',
|
||||
from: 'Recruiter',
|
||||
direction: 'inbound',
|
||||
subject: `Page ${page}`,
|
||||
channel: 'Email',
|
||||
date: new Date().toISOString(),
|
||||
contentPreview: `Page ${page} message`,
|
||||
labelCount: 0,
|
||||
attachmentCount: 0,
|
||||
}],
|
||||
page,
|
||||
pageSize: 50,
|
||||
total: 51,
|
||||
totalPages: 2,
|
||||
} } as any);
|
||||
}
|
||||
return original!(url, config);
|
||||
});
|
||||
|
||||
renderPage();
|
||||
fireEvent.click(await screen.findByRole('button', { name: /go to page 2/i }));
|
||||
|
||||
expect(await screen.findByText(/second page company/i)).toBeInTheDocument();
|
||||
expect(mockedApi.get).toHaveBeenCalledWith('/correspondence/page', expect.objectContaining({
|
||||
params: expect.objectContaining({ page: 2, pageSize: 50 }),
|
||||
}));
|
||||
});
|
||||
|
||||
test('unlinks a Gmail thread only after confirmation and returns it to review', async () => {
|
||||
mockedApi.post.mockResolvedValue({ data: { threadId: 'thread-1', jobApplicationId: 42, removedMessages: 1, decision: 'review' } } as any);
|
||||
renderPage();
|
||||
@@ -154,7 +194,7 @@ describe('CorrespondenceInboxPage', () => {
|
||||
note: 'Unlinked from Job email hub',
|
||||
nextDecision: 'review',
|
||||
}));
|
||||
await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith('/correspondence', expect.anything()));
|
||||
await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith('/correspondence/page', expect.anything()));
|
||||
expect(await screen.findByText(/returned to recruitment review/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -452,6 +492,6 @@ describe('CorrespondenceInboxPage', () => {
|
||||
);
|
||||
|
||||
expect(await screen.findByRole('heading', { name: /recruitment message review/i })).toBeInTheDocument();
|
||||
expect(mockedApi.get).not.toHaveBeenCalledWith('/correspondence', expect.anything());
|
||||
expect(mockedApi.get).not.toHaveBeenCalledWith('/correspondence/page', expect.anything());
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user