diff --git a/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/AddressSummary/AddressSummary.test.tsx b/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/AddressSummary/AddressSummary.test.tsx index c10fa3d4f48..88647e41a4c 100644 --- a/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/AddressSummary/AddressSummary.test.tsx +++ b/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/AddressSummary/AddressSummary.test.tsx @@ -1,6 +1,7 @@ import React from 'react' import { fireEvent, screen } from '@testing-library/react-native' +import { t } from 'i18next' import { contactInformationKeys } from 'api/contactInformation/queryKeys' import { AddressData, UserContactInformation } from 'api/types' @@ -76,7 +77,11 @@ describe('AddressSummary', () => { describe('when there is no mailing address', () => { it('displays the message for adding a mailing address', () => { - expect(screen.getByText('Add your mailing address')).toBeTruthy() + expect( + screen.getByText( + t('contactInformation.addYour', { field: t(`contactInformation.mailingAddress`).toLowerCase() }), + ), + ).toBeTruthy() }) }) @@ -91,7 +96,11 @@ describe('AddressSummary', () => { describe('when there is no residential address', () => { it('displays the message for adding a home address', () => { renderWithData() - expect(screen.getByText('Add your home address')).toBeTruthy() + expect( + screen.getByText( + t('contactInformation.addYour', { field: t(`contactInformation.residentialAddress`).toLowerCase() }), + ), + ).toBeTruthy() }) }) @@ -209,7 +218,11 @@ describe('AddressSummary', () => { } renderWithData({ mailingAddress: noCountryCodeAddress }) - expect(screen.getByText('Add your mailing address')).toBeTruthy() + expect( + screen.getByText( + t('contactInformation.addYour', { field: t(`contactInformation.mailingAddress`).toLowerCase() }), + ), + ).toBeTruthy() }) }) @@ -237,9 +250,9 @@ describe('AddressSummary', () => { describe('when the address summary is clicked', () => { it('calls onPress', () => { - fireEvent.press(screen.getByRole('link', { name: 'Mailing address' })) + fireEvent.press(screen.getByRole('link', { name: t('contactInformation.mailingAddress') })) expect(mailingAddressOnPressSpy).toBeCalled() - fireEvent.press(screen.getByRole('link', { name: 'Home address' })) + fireEvent.press(screen.getByRole('link', { name: t('contactInformation.residentialAddress') })) expect(residentialAddressOnPressSpy).toBeCalled() }) }) diff --git a/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/AddressValidation/AddressValidation.test.tsx b/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/AddressValidation/AddressValidation.test.tsx index 8ab7ac287dd..16a395fa533 100644 --- a/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/AddressValidation/AddressValidation.test.tsx +++ b/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/AddressValidation/AddressValidation.test.tsx @@ -1,6 +1,7 @@ import React from 'react' import { fireEvent, screen } from '@testing-library/react-native' +import { t } from 'i18next' import { AddressData, ValidateAddressData } from 'api/types' import { SnackbarMessages } from 'components/SnackBar' @@ -89,18 +90,18 @@ describe('AddressValidation', () => { describe('when the address validation scenario type is SHOW_SUGGESTIONS_OVERRIDE', () => { it('displays the alert texts', () => { - const collapsibleAlert = screen.getByText('Verify your address') + const collapsibleAlert = screen.getByText(t('editAddress.validation.verifyAddress.title')) expect(collapsibleAlert).toBeTruthy() fireEvent.press(collapsibleAlert) - expect(screen.getByText("We can't confirm the address you entered with the U.S. Postal Service.")).toBeTruthy() + expect(screen.getByText(t('editAddress.validation.verifyAddress.body.1'))).toBeTruthy() }) }) describe('when use this address button is pressed', () => { it('calls updateAddress', () => { fireEvent.press(screen.getByTestId('youEnteredTestID')) - fireEvent.press(screen.getByRole('button', { name: 'Use this address' })) + fireEvent.press(screen.getByRole('button', { name: t('editAddress.validation.useThisAddress') })) expect(saveAddressSpy).toBeCalled() }) }) diff --git a/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/EditAddressScreen/EditAddressScreen.test.tsx b/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/EditAddressScreen/EditAddressScreen.test.tsx index e11cea97a2a..328fff9f382 100644 --- a/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/EditAddressScreen/EditAddressScreen.test.tsx +++ b/VAMobile/src/screens/HomeScreen/ProfileScreen/ContactInformationScreen/EditAddressScreen/EditAddressScreen.test.tsx @@ -1,6 +1,7 @@ import React from 'react' import { fireEvent, screen, waitFor } from '@testing-library/react-native' +import { t } from 'i18next' import { contactInformationKeys } from 'api/contactInformation' import { AddressData, DeliveryPointValidationTypesConstants, UserContactInformation } from 'api/types' @@ -134,7 +135,7 @@ describe('EditAddressScreen', () => { fireEvent.press(countrySelector) fireEvent.press(screen.getByText('Algeria')) - fireEvent.press(screen.getByRole('button', { name: 'Done' })) + fireEvent.press(screen.getByRole('button', { name: t('done') })) expect(countrySelector.props.children).toEqual('Algeria') }) @@ -148,7 +149,7 @@ describe('EditAddressScreen', () => { fireEvent.press(screen.getByTestId('countryPickerTestID')) fireEvent.press(screen.getByText('Algeria')) - fireEvent.press(screen.getByRole('button', { name: 'Done' })) + fireEvent.press(screen.getByRole('button', { name: t('done') })) expect(screen.getByTestId('stateTestID').props.value).toEqual('') expect(zipCodeInput.props.value).toEqual('') @@ -180,7 +181,7 @@ describe('EditAddressScreen', () => { fireEvent.press(screen.getByTestId('countryPickerTestID')) fireEvent.press(screen.getByText('Algeria')) - fireEvent.press(screen.getByRole('button', { name: 'Done' })) + fireEvent.press(screen.getByRole('button', { name: t('done') })) expect(screen.getByTestId('stateTestID').props.value).toEqual('Northern Territory') expect(screen.getByTestId('zipCodeTestID').props.value).toEqual('5922') @@ -247,7 +248,7 @@ describe('EditAddressScreen', () => { fireEvent.press(militaryPostOfficeSelector) fireEvent.press(screen.getByText('APO')) - fireEvent.press(screen.getByRole('button', { name: 'Done' })) + fireEvent.press(screen.getByRole('button', { name: t('done') })) expect(militaryPostOfficeSelector.props.children).toEqual('APO') }) }) @@ -256,7 +257,7 @@ describe('EditAddressScreen', () => { it('updates the value of state', () => { fireEvent.press(screen.getByTestId('stateTestID')) fireEvent.press(screen.getByText('California')) - fireEvent.press(screen.getByRole('button', { name: 'Done' })) + fireEvent.press(screen.getByRole('button', { name: t('done') })) expect(screen.getByTestId('stateTestID').props.children).toEqual('California') }) }) @@ -425,7 +426,7 @@ describe('EditAddressScreen', () => { renderWithData(false, { mailingAddress: newAddress }) - fireEvent.press(screen.getByRole('button', { name: 'Save' })) + fireEvent.press(screen.getByRole('button', { name: t('save') })) await waitFor(() => expect(goBackSpy).toBeCalled()) }) }) @@ -486,32 +487,32 @@ describe('EditAddressScreen', () => { renderWithData(false, { mailingAddress: newAddress }) - fireEvent.press(screen.getByRole('button', { name: 'Save' })) + fireEvent.press(screen.getByRole('button', { name: t('save') })) await waitFor(() => expect(post as jest.Mock).toBeCalledWith('/v0/user/addresses/validate', newAddress, undefined, abortSignal), ) - await waitFor(() => expect(screen.getByText('Verify your address')).toBeTruthy()) + await waitFor(() => expect(screen.getByText(t('editAddress.validation.verifyAddress.title'))).toBeTruthy()) }) }) describe('when content is invalid for domestic address', () => { it('displays an AlertBox and a field error for each required field', () => { - fireEvent.press(screen.getByRole('button', { name: 'Save' })) - expect(screen.getByText('Please check your mailing address')).toBeTruthy() - expect(screen.getByText('Country is required')).toBeTruthy() - expect(screen.getByText('Street address is required')).toBeTruthy() - expect(screen.getByText('City is required')).toBeTruthy() - expect(screen.getByText('State is required')).toBeTruthy() - expect(screen.getByText('Postal code is required')).toBeTruthy() + fireEvent.press(screen.getByRole('button', { name: t('save') })) + expect(screen.getByText(t('editAddress.alertError'))).toBeTruthy() + expect(screen.getByText(t('editAddress.countryFieldError'))).toBeTruthy() + expect(screen.getByText(t('editAddress.streetAddressLine1FieldError'))).toBeTruthy() + expect(screen.getByText(t('editAddress.cityFieldError'))).toBeTruthy() + expect(screen.getByText(t('editAddress.stateFieldError'))).toBeTruthy() + expect(screen.getByText(t('editAddress.zipCodeFieldError'))).toBeTruthy() }) }) describe('when content is invalid for military address', () => { it('displays an AlertBox and a field error for each required field', () => { - fireEvent.press(screen.getByRole('button', { name: 'Save' })) - expect(screen.getByText('Please check your mailing address')).toBeTruthy() - expect(screen.getByText('Street address is required')).toBeTruthy() - expect(screen.getByText('Postal code is required')).toBeTruthy() + fireEvent.press(screen.getByRole('button', { name: t('save') })) + expect(screen.getByText(t('editAddress.alertError'))).toBeTruthy() + expect(screen.getByText(t('editAddress.streetAddressLine1FieldError'))).toBeTruthy() + expect(screen.getByText(t('editAddress.zipCodeFieldError'))).toBeTruthy() }) }) @@ -519,10 +520,10 @@ describe('EditAddressScreen', () => { it('displays an AlertBox and a field error for each required field', () => { fireEvent.press(screen.getByTestId('countryPickerTestID')) fireEvent.press(screen.getByText('Algeria')) - fireEvent.press(screen.getByRole('button', { name: 'Save' })) - expect(screen.getByText('Street address is required')).toBeTruthy() - expect(screen.getByText('City is required')).toBeTruthy() - expect(screen.getByText('Postal code is required')).toBeTruthy() + fireEvent.press(screen.getByRole('button', { name: t('save') })) + expect(screen.getByText(t('editAddress.streetAddressLine1FieldError'))).toBeTruthy() + expect(screen.getByText(t('editAddress.cityFieldError'))).toBeTruthy() + expect(screen.getByText(t('editAddress.internationalPostCodeFieldError'))).toBeTruthy() }) }) @@ -553,7 +554,7 @@ describe('EditAddressScreen', () => { renderWithData(false, { mailingAddress: newAddress }) - fireEvent.press(screen.getByRole('button', { name: 'Save' })) + fireEvent.press(screen.getByRole('button', { name: t('save') })) const abortController = new AbortController() const abortSignal = abortController.signal @@ -601,7 +602,7 @@ describe('EditAddressScreen', () => { } renderWithData(false, { mailingAddress: newAddress }) - fireEvent.press(screen.getByRole('button', { name: 'Save' })) + fireEvent.press(screen.getByRole('button', { name: t('save') })) const abortController = new AbortController() const abortSignal = abortController.signal @@ -648,7 +649,7 @@ describe('EditAddressScreen', () => { } renderWithData(false, { mailingAddress: newAddress }) - fireEvent.press(screen.getByRole('button', { name: 'Save' })) + fireEvent.press(screen.getByRole('button', { name: t('save') })) const abortController = new AbortController() const abortSignal = abortController.signal