- {verifiedNameEnabled
- ? props.intl.formatMessage(messages['id.verification.name.label'])
- : props.intl.formatMessage(messages['id.verification.account.name.label'])}
+ {props.intl.formatMessage(messages['id.verification.name.label'])}
{renderManagedProfileMessage()}
@@ -242,29 +231,14 @@ function SummaryPanel(props) {
state: { fromSummary: true },
}}
>
- {
- verifiedNameEnabled
- ? (
- Name,
- }}
- />
- )
- : (
- Account Name,
- }}
- />
- )
- }
+ Name,
+ }}
+ />
)}
diff --git a/src/id-verification/tests/IdVerificationContextProvider.test.jsx b/src/id-verification/tests/IdVerificationContextProvider.test.jsx
index 26a9cf3..a2c0f57 100644
--- a/src/id-verification/tests/IdVerificationContextProvider.test.jsx
+++ b/src/id-verification/tests/IdVerificationContextProvider.test.jsx
@@ -32,7 +32,7 @@ describe('IdVerificationContextProvider', () => {
it('renders correctly and calls getExistingIdVerification + getEnrollments', async () => {
const appContext = { authenticatedUser: { userId: 3, roles: [] } };
- const verifiedNameContext = { verifiedName: '', verifiedNameEnabled: false };
+ const verifiedNameContext = { verifiedName: '' };
await act(async () => render((
@@ -54,7 +54,7 @@ describe('IdVerificationContextProvider', () => {
roles: ['enterprise_learner'],
},
};
- const verifiedNameContext = { verifiedName: '', verifiedNameEnabled: false };
+ const verifiedNameContext = { verifiedName: '' };
await act(async () => render((
diff --git a/src/id-verification/tests/VerifiedNameContextProvider.test.jsx b/src/id-verification/tests/VerifiedNameContextProvider.test.jsx
index 6959ba9..4a73ea8 100644
--- a/src/id-verification/tests/VerifiedNameContextProvider.test.jsx
+++ b/src/id-verification/tests/VerifiedNameContextProvider.test.jsx
@@ -5,11 +5,10 @@ import { getVerifiedNameHistory } from '../../account-settings/data/service';
import { VerifiedNameContext, VerifiedNameContextProvider } from '../VerifiedNameContext';
const VerifiedNameContextTestComponent = () => {
- const { verifiedName, verifiedNameEnabled } = useContext(VerifiedNameContext);
+ const { verifiedName } = useContext(VerifiedNameContext);
return (
<>
- {verifiedNameEnabled && ({verifiedName}
)}
- {verifiedNameEnabled ? 'true' : 'false'}
+ {verifiedName && ({verifiedName}
)}
>
);
};
@@ -38,9 +37,8 @@ describe('VerifiedNameContextProvider', () => {
await waitFor(() => expect(getVerifiedNameHistory).toHaveBeenCalledTimes(1));
});
- it('sets verifiedName and verifiedNameEnabled correctly when verified name feature enabled', async () => {
+ it('sets verifiedName', async () => {
const mockReturnValue = {
- verified_name_enabled: true,
results: [{
verified_name: 'Michael',
status: 'approved',
@@ -57,28 +55,5 @@ describe('VerifiedNameContextProvider', () => {
await waitFor(() => expect(getVerifiedNameHistory).toHaveBeenCalledTimes(1));
expect(getByTestId('verified-name')).toHaveTextContent('Michael');
- expect(getByTestId('verified-name-enabled')).toHaveTextContent('true');
- });
-
- it('sets verifiedName and verifiedNameEnabled correctly when verified name feature not enabled', async () => {
- const mockReturnValue = {
- verified_name_enabled: false,
- results: [{
- verified_name: 'Michael',
- status: 'approved',
- created: '2021-08-31T18:33:32.489200Z',
- }],
- };
- getVerifiedNameHistory.mockReturnValueOnce(mockReturnValue);
-
- const { queryByTestId } = render((
-
-
-
- ));
-
- await waitFor(() => expect(getVerifiedNameHistory).toHaveBeenCalledTimes(1));
- expect(queryByTestId('verified-name')).toBeNull();
- expect(queryByTestId('verified-name-enabled')).toHaveTextContent('false');
});
});
diff --git a/src/id-verification/tests/panels/GetNameIdPanel.test.jsx b/src/id-verification/tests/panels/GetNameIdPanel.test.jsx
index 6507f65..d26dd2c 100644
--- a/src/id-verification/tests/panels/GetNameIdPanel.test.jsx
+++ b/src/id-verification/tests/panels/GetNameIdPanel.test.jsx
@@ -32,16 +32,14 @@ describe('GetNameIdPanel', () => {
idPhotoFile: 'test.jpg',
};
- const verifiedNameContextValue = {
- verifiedNameEnabled: false,
- };
+ const verifiedNameContextValue = {};
- const getPanel = async () => {
+ const getPanel = async (idVerificationContextValue = IDVerificationContextValue) => {
await act(async () => render((
-
+
@@ -54,65 +52,28 @@ describe('GetNameIdPanel', () => {
cleanup();
});
- it('edits', async () => {
+ it('shows feedback message when user has an empty name', async () => {
await getPanel();
-
- const yesButton = await screen.findByTestId('name-matches-yes');
- const noButton = await screen.findByTestId('name-matches-no');
- const input = await screen.findByTestId('name-input');
- const nextButton = await screen.findByTestId('next-button');
- const errorMessageQuery = await screen.queryByTestId('id-name-feedback-message');
-
- expect(input).toHaveAttribute('readonly');
- expect(errorMessageQuery).toBeNull();
-
- fireEvent.click(noButton);
- expect(input).not.toHaveAttribute('readonly');
- expect(nextButton.classList.contains('disabled')).toBe(true);
- expect(nextButton).toHaveAttribute('aria-disabled');
-
- fireEvent.change(input, { target: { value: 'test change' } });
- expect(IDVerificationContextValue.setIdPhotoName).toHaveBeenCalled();
- // Ensure the feedback message on name shows when the user says the name does not match ID
+ // Ensure the feedback message on name shows when the user has an empty name
expect(await screen.queryByTestId('id-name-feedback-message')).toBeTruthy();
-
- fireEvent.click(yesButton);
- expect(input).toHaveAttribute('readonly');
- expect(IDVerificationContextValue.setIdPhotoName).toHaveBeenCalled();
});
- it('disables radio buttons + next button and enables input if account name is blank', async () => {
- IDVerificationContextValue.nameOnAccount = '';
- await getPanel();
-
- const yesButton = await screen.findByTestId('name-matches-yes');
- const noButton = await screen.findByTestId('name-matches-no');
- const input = await screen.findByTestId('name-input');
- const nextButton = await screen.findByTestId('next-button');
- const errorMessageQuery = await screen.queryByTestId('id-name-feedback-message');
-
- expect(yesButton).toBeDisabled();
- expect(noButton).toBeDisabled();
- expect(input).not.toHaveAttribute('readonly');
- expect(nextButton.classList.contains('disabled')).toBe(true);
- expect(nextButton).toHaveAttribute('aria-disabled');
- expect(errorMessageQuery).toBeTruthy();
+ it('does not show feedback message when user has an non-empty name', async () => {
+ const idVerificationContextValue = {
+ ...IDVerificationContextValue,
+ idPhotoName: 'test',
+ };
+ await getPanel(idVerificationContextValue);
+ // Ensure the feedback message on name shows when the user has an empty name
+ expect(await screen.queryByTestId('id-name-feedback-message')).toBeNull();
});
- it('blocks the user from changing account name if managed by a third party', async () => {
- IDVerificationContextValue.profileDataManager = 'test-org';
+ it('calls setIdPhotoName with correct name', async () => {
await getPanel();
- const noButton = await screen.findByTestId('name-matches-no');
const input = await screen.findByTestId('name-input');
- const nextButton = await screen.findByTestId('next-button');
-
- fireEvent.click(noButton);
- expect(input).toHaveAttribute('readonly');
- expect(nextButton.classList.contains('disabled')).toBe(true);
- expect(nextButton).toHaveAttribute('aria-disabled');
- const warning = await screen.getAllByText('test-org');
- expect(warning.length).toEqual(1);
+ fireEvent.change(input, { target: { value: 'test' } });
+ expect(IDVerificationContextValue.setIdPhotoName).toHaveBeenCalledWith('test');
});
it('routes to SummaryPanel', async () => {
diff --git a/src/id-verification/tests/panels/SummaryPanel.test.jsx b/src/id-verification/tests/panels/SummaryPanel.test.jsx
index adb3d31..1f2294b 100644
--- a/src/id-verification/tests/panels/SummaryPanel.test.jsx
+++ b/src/id-verification/tests/panels/SummaryPanel.test.jsx
@@ -39,9 +39,7 @@ describe('SummaryPanel', () => {
setReachedSummary: jest.fn(),
};
- const verifiedNameContextValue = {
- verifiedNameEnabled: false,
- };
+ const verifiedNameContextValue = {};
const getPanel = async () => {
await act(async () => render((
@@ -111,7 +109,7 @@ describe('SummaryPanel', () => {
await waitFor(() => expect(appContextValue.stopUserMedia).toHaveBeenCalled());
});
- it('does not submit a name if name is blank', async () => {
+ it('submits a name if name is blank', async () => {
appContextValue.idPhotoName = '';
const verificationData = {
facePhotoFile: appContextValue.facePhotoFile,
@@ -120,6 +118,7 @@ describe('SummaryPanel', () => {
idPhotoMode: appContextValue.idPhotoMode,
optimizelyExperimentName: appContextValue.optimizelyExperimentName,
courseRunKey: null,
+ idPhotoName: appContextValue.nameOnAccount,
};
await getPanel();
const button = await screen.findByTestId('submit-button');
@@ -127,25 +126,8 @@ describe('SummaryPanel', () => {
expect(dataService.submitIdVerification).toHaveBeenCalledWith(verificationData);
});
- it('does not submit a name if name is unchanged', async () => {
+ it('submits a name if a name is unchanged', async () => {
appContextValue.idPhotoName = null;
- const verificationData = {
- facePhotoFile: appContextValue.facePhotoFile,
- idPhotoFile: appContextValue.idPhotoFile,
- portraitPhotoMode: appContextValue.portraitPhotoMode,
- idPhotoMode: appContextValue.idPhotoMode,
- optimizelyExperimentName: appContextValue.optimizelyExperimentName,
- courseRunKey: null,
- };
- await getPanel();
- const button = await screen.findByTestId('submit-button');
- fireEvent.click(button);
- expect(dataService.submitIdVerification).toHaveBeenCalledWith(verificationData);
- });
-
- it('submits a name if a name is unchanged if verified name feature is enabled', async () => {
- appContextValue.idPhotoName = null;
- verifiedNameContextValue.verifiedNameEnabled = true;
const verificationData = {
facePhotoFile: appContextValue.facePhotoFile,
idPhotoFile: appContextValue.idPhotoFile,