feat(email): confirm hub thread unlink
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import '@testing-library/jest-dom';
|
||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
||||
import { MemoryRouter, Navigate, Route, Routes } from 'react-router-dom';
|
||||
import { ToastProvider } from './toast';
|
||||
import { ConfirmProvider } from './confirm';
|
||||
@@ -120,6 +120,27 @@ describe('CorrespondenceInboxPage', () => {
|
||||
});
|
||||
});
|
||||
|
||||
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();
|
||||
|
||||
fireEvent.click(await screen.findByRole('button', { name: /^unlink thread$/i }));
|
||||
expect(mockedApi.post).not.toHaveBeenCalled();
|
||||
|
||||
const dialog = await screen.findByRole('dialog');
|
||||
expect(within(dialog).getByText(/provider copy is not deleted/i)).toBeInTheDocument();
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: /^unlink thread$/i }));
|
||||
|
||||
await waitFor(() => expect(mockedApi.post).toHaveBeenCalledWith('/gmail/unlink-thread', {
|
||||
jobApplicationId: 42,
|
||||
threadId: 'thread-1',
|
||||
note: 'Unlinked from Job email hub',
|
||||
nextDecision: 'review',
|
||||
}));
|
||||
await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith('/correspondence', expect.anything()));
|
||||
expect(await screen.findByText(/returned to recruitment review/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('falls back to the saved copy when provider detail is unavailable', async () => {
|
||||
const original = mockedApi.get.getMockImplementation();
|
||||
mockedApi.get.mockImplementation((url: string, config?: any) => {
|
||||
|
||||
Reference in New Issue
Block a user