diff --git a/src/components/Tool/FixEmailAddresses/FixEmailAddressPerson.test.tsx b/src/components/Tool/FixEmailAddresses/FixEmailAddressPerson.test.tsx index 4ba32b081..bf7068d4c 100644 --- a/src/components/Tool/FixEmailAddresses/FixEmailAddressPerson.test.tsx +++ b/src/components/Tool/FixEmailAddresses/FixEmailAddressPerson.test.tsx @@ -6,13 +6,14 @@ import { DateTime } from 'luxon'; import TestWrapper from '__tests__/util/TestWrapper'; import { GqlMockedProvider } from '__tests__/util/graphqlMocking'; import { render, waitFor } from '__tests__/util/testingLibraryReactMock'; +import { PersonEmailAddressInput } from 'src/graphql/types.generated'; import theme from '../../../theme'; import { EmailAddressesMutation } from './AddEmailAddress.generated'; import { FixEmailAddressPerson, FixEmailAddressPersonProps, } from './FixEmailAddressPerson'; -import { EmailAddressData } from './FixEmailAddresses'; +import { EmailAddressData, PersonEmailAddresses } from './FixEmailAddresses'; import { GetInvalidEmailAddressesQuery } from './FixEmailAddresses.generated'; import { mockInvalidEmailAddressesResponse } from './FixEmailAddressesMocks'; @@ -48,6 +49,14 @@ const TestComponent = ({ mocks }: { mocks: ApolloErgonoMockMap }) => { const handleChangeMock = jest.fn(); const handleDeleteModalOpenMock = jest.fn(); const handleChangePrimaryMock = jest.fn(); + const toDelete = [] as PersonEmailAddressInput[]; + const dataState = { + id: { + emailAddresses: testData.emailAddresses as EmailAddressData[], + toDelete, + }, + } as { [key: string]: PersonEmailAddresses }; + return ( @@ -58,10 +67,11 @@ const TestComponent = ({ mocks }: { mocks: ApolloErgonoMockMap }) => { mocks={mocks} > ({ [theme.breakpoints.up('md')]: { @@ -96,6 +96,7 @@ export interface FixEmailAddressPersonProps { name: string; emailAddresses?: EmailAddressData[]; personId: string; + dataState: { [key: string]: PersonEmailAddresses }; toDelete: PersonEmailAddressInput[]; contactId: string; handleChange: ( @@ -112,6 +113,7 @@ export const FixEmailAddressPerson: React.FC = ({ name, emailAddresses, personId, + dataState, contactId, handleChange, handleDelete, @@ -130,7 +132,7 @@ export const FixEmailAddressPerson: React.FC = ({ personId: personId, isPrimary: email.primary, })) || [], - [emailAddresses], + [emailAddresses, dataState], ); const handleContactNameClick = () => { diff --git a/src/components/Tool/FixEmailAddresses/FixEmailAddresses.test.tsx b/src/components/Tool/FixEmailAddresses/FixEmailAddresses.test.tsx index 03b0903af..63f4ab966 100644 --- a/src/components/Tool/FixEmailAddresses/FixEmailAddresses.test.tsx +++ b/src/components/Tool/FixEmailAddresses/FixEmailAddresses.test.tsx @@ -273,17 +273,16 @@ describe('FixPhoneNumbers-Home', () => { ).toBeInTheDocument(); }); - //TODO: Fix during MPDX-7946 - it.skip('should modify first email of first contact', async () => { + 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') as HTMLInputElement; + const firstInput = getByTestId('textfield-testid-0'); - expect(firstInput.value).toBe('email1@gmail.com'); + expect(firstInput).toHaveValue('email1@gmail.com'); userEvent.type(firstInput, '123'); - expect(firstInput.value).toBe('email1@gmail.com123'); + expect(firstInput).toHaveValue('email1@gmail.com123'); }); describe('setContactFocus()', () => { diff --git a/src/components/Tool/FixEmailAddresses/FixEmailAddresses.tsx b/src/components/Tool/FixEmailAddresses/FixEmailAddresses.tsx index 00fb2288f..34516aeb6 100644 --- a/src/components/Tool/FixEmailAddresses/FixEmailAddresses.tsx +++ b/src/components/Tool/FixEmailAddresses/FixEmailAddresses.tsx @@ -104,7 +104,7 @@ export interface EmailAddressData { destroy?: boolean; } -interface PersonEmailAddresses { +export interface PersonEmailAddresses { emailAddresses: EmailAddressData[]; toDelete: PersonEmailAddressInput[]; } @@ -279,6 +279,7 @@ export const FixEmailAddresses: React.FC = ({ name={`${person.firstName} ${person.lastName}`} key={person.id} personId={person.id} + dataState={dataState} emailAddresses={dataState[person.id]?.emailAddresses} toDelete={dataState[person.id]?.toDelete} contactId={person.contactId}