From 232bead0c9b403650c75b1cee8cccf985f2da054 Mon Sep 17 00:00:00 2001 From: Bianca Severino Date: Fri, 12 Mar 2021 11:58:50 -0500 Subject: [PATCH] Only submit full_name with IDV photos if the account name should be changed --- src/id-verification/panels/SummaryPanel.jsx | 8 ++++-- .../tests/panels/SummaryPanel.test.jsx | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/id-verification/panels/SummaryPanel.jsx b/src/id-verification/panels/SummaryPanel.jsx index 92e1eb9..04b27b6 100644 --- a/src/id-verification/panels/SummaryPanel.jsx +++ b/src/id-verification/panels/SummaryPanel.jsx @@ -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) { diff --git a/src/id-verification/tests/panels/SummaryPanel.test.jsx b/src/id-verification/tests/panels/SummaryPanel.test.jsx index c77c895..6b50b6a 100644 --- a/src/id-verification/tests/panels/SummaryPanel.test.jsx +++ b/src/id-verification/tests/panels/SummaryPanel.test.jsx @@ -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();