diff --git a/src/components/Tool/FixEmailAddresses/EmailValidationForm.tsx b/src/components/Tool/FixEmailAddresses/EmailValidationForm.tsx
index 9470db14db..98636c499c 100644
--- a/src/components/Tool/FixEmailAddresses/EmailValidationForm.tsx
+++ b/src/components/Tool/FixEmailAddresses/EmailValidationForm.tsx
@@ -121,6 +121,9 @@ const EmailValidationForm = ({ personId }: EmailValidationFormProps) => {
onCompleted: () => {
enqueueSnackbar(t('Added email address'), { variant: 'success' });
},
+ onError: () => {
+ enqueueSnackbar(t('Failed to add email address'), { variant: 'error' });
+ },
});
};
diff --git a/src/components/Tool/FixEmailAddresses/FixEmailAddresses.test.tsx b/src/components/Tool/FixEmailAddresses/FixEmailAddresses.test.tsx
index bb73318635..33668ed05e 100644
--- a/src/components/Tool/FixEmailAddresses/FixEmailAddresses.test.tsx
+++ b/src/components/Tool/FixEmailAddresses/FixEmailAddresses.test.tsx
@@ -107,7 +107,7 @@ describe('FixEmailAddresses-Home', () => {
expect(getByTestId('starOutlineIcon-testid-0')).toBeInTheDocument();
});
- it('should add an new email address and update GraphQL and reset form', async () => {
+ it('should add an new email address, firing a GraphQL mutation and resetting the form', async () => {
const { getByTestId, getAllByLabelText } = render();
await waitFor(() => {
expect(getByTestId('textfield-testid-0')).toBeInTheDocument();
@@ -172,7 +172,53 @@ describe('FixEmailAddresses-Home', () => {
expect(getByTestId('starIcon-testid2-0')).toBeInTheDocument();
});
- describe('add email address', () => {
+ it('should render no contacts with no data', async () => {
+ const { getByText, getByTestId } = render(
+ ,
+ );
+ await waitFor(() =>
+ expect(getByTestId('fixEmailAddresses-null-state')).toBeInTheDocument(),
+ );
+ expect(
+ getByText('No people with email addresses need attention'),
+ ).toBeInTheDocument();
+ });
+
+ it('should modify first email of first contact', async () => {
+ const { getByTestId } = render();
+ await waitFor(() => {
+ expect(getByTestId('textfield-testid-0')).toBeInTheDocument();
+ });
+ const firstInput = getByTestId('textfield-testid-0');
+
+ expect(firstInput).toHaveValue('email1@gmail.com');
+ userEvent.type(firstInput, '123');
+ expect(firstInput).toHaveValue('email1@gmail.com123');
+ });
+
+ describe('setContactFocus()', () => {
+ it('should open up contact details', async () => {
+ const { getByText, queryByTestId } = render();
+ await waitFor(() =>
+ expect(queryByTestId('loading')).not.toBeInTheDocument(),
+ );
+ expect(setContactFocus).not.toHaveBeenCalled();
+
+ const contactName = getByText('Test Contact');
+
+ expect(contactName).toBeInTheDocument();
+ userEvent.click(contactName);
+ expect(setContactFocus).toHaveBeenCalledWith(contactId);
+ });
+ });
+
+ describe('Add email address - Testing cache', () => {
interface AddEmailAddressProps {
postSaveResponse: object;
emailAddressNodes: object[];
@@ -302,50 +348,4 @@ describe('FixEmailAddresses-Home', () => {
});
});
});
-
- it('should render no contacts with no data', async () => {
- const { getByText, getByTestId } = render(
- ,
- );
- await waitFor(() =>
- expect(getByTestId('fixEmailAddresses-null-state')).toBeInTheDocument(),
- );
- expect(
- getByText('No people with email addresses need attention'),
- ).toBeInTheDocument();
- });
-
- it('should modify first email of first contact', async () => {
- const { getByTestId } = render();
- await waitFor(() => {
- expect(getByTestId('textfield-testid-0')).toBeInTheDocument();
- });
- const firstInput = getByTestId('textfield-testid-0');
-
- expect(firstInput).toHaveValue('email1@gmail.com');
- userEvent.type(firstInput, '123');
- expect(firstInput).toHaveValue('email1@gmail.com123');
- });
-
- describe('setContactFocus()', () => {
- it('should open up contact details', async () => {
- const { getByText, queryByTestId } = render();
- await waitFor(() =>
- expect(queryByTestId('loading')).not.toBeInTheDocument(),
- );
- expect(setContactFocus).not.toHaveBeenCalled();
-
- const contactName = getByText('Test Contact');
-
- expect(contactName).toBeInTheDocument();
- userEvent.click(contactName);
- expect(setContactFocus).toHaveBeenCalledWith(contactId);
- });
- });
});