Only submit full_name with IDV photos if the account name should be changed

This commit is contained in:
Bianca Severino
2021-03-12 11:58:50 -05:00
parent bd0c879a51
commit 232bead0c9
2 changed files with 33 additions and 3 deletions

View File

@@ -33,14 +33,16 @@ function SummaryPanel(props) {
function SubmitButton() {
async function handleClick() {
setIsSubmitting(true);
let verificationData = {
const verificationData = {
facePhotoFile,
idPhotoFile,
idPhotoName: nameToBeUsed,
courseRunKey: sessionStorage.getItem('courseRunKey'),
};
if (idPhotoName) {
verificationData.idPhotoName = idPhotoName;
}
if (optimizelyExperimentName) {
verificationData = { ...verificationData, optimizelyExperimentName };
verificationData.optimizelyExperimentName = optimizelyExperimentName;
}
const result = await submitIdVerification(verificationData);
if (result.success) {

View File

@@ -91,6 +91,34 @@ describe('SummaryPanel', () => {
await waitFor(() => expect(contextValue.stopUserMedia).toHaveBeenCalled());
});
it('does not submit a name if name is blank', async () => {
contextValue.idPhotoName = '';
const verificationData = {
facePhotoFile: contextValue.facePhotoFile,
idPhotoFile: contextValue.idPhotoFile,
optimizelyExperimentName: contextValue.optimizelyExperimentName,
courseRunKey: null,
};
await getPanel();
const button = await screen.findByTestId('submit-button');
fireEvent.click(button);
expect(dataService.submitIdVerification).toHaveBeenCalledWith(verificationData);
});
it('does not submit a name if name is unchanged', async () => {
contextValue.idPhotoName = null;
const verificationData = {
facePhotoFile: contextValue.facePhotoFile,
idPhotoFile: contextValue.idPhotoFile,
optimizelyExperimentName: contextValue.optimizelyExperimentName,
courseRunKey: null,
};
await getPanel();
const button = await screen.findByTestId('submit-button');
fireEvent.click(button);
expect(dataService.submitIdVerification).toHaveBeenCalledWith(verificationData);
});
it('shows error when cannot submit', async () => {
dataService.submitIdVerification = jest.fn().mockReturnValue({ success: false });
await getPanel();