Only submit full_name with IDV photos if the account name should be changed
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user