From a9e645aaad29aeec7217ade381e1663ed3cb71c4 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Mon, 31 Oct 2022 09:11:44 -0400 Subject: [PATCH 1/2] LG-7943: Avoid showing in-person option for field validation errors changelog: Bug Fixes, In-person proofing, Show in-person option at intended troubleshooting scenarios --- .../packages/document-capture/components/documents-step.jsx | 2 +- .../document-capture/components/document-capture-spec.jsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/javascript/packages/document-capture/components/documents-step.jsx b/app/javascript/packages/document-capture/components/documents-step.jsx index c09f7b30695..8d3e6a2f459 100644 --- a/app/javascript/packages/document-capture/components/documents-step.jsx +++ b/app/javascript/packages/document-capture/components/documents-step.jsx @@ -66,7 +66,7 @@ function DocumentsStep({ /> ))} {isLastStep ? : } - + ); diff --git a/spec/javascripts/packages/document-capture/components/document-capture-spec.jsx b/spec/javascripts/packages/document-capture/components/document-capture-spec.jsx index 12001fe54a8..32e0d8f5b66 100644 --- a/spec/javascripts/packages/document-capture/components/document-capture-spec.jsx +++ b/spec/javascripts/packages/document-capture/components/document-capture-spec.jsx @@ -488,7 +488,7 @@ describe('document-capture/components/document-capture', () => { context('in person steps', () => { it('renders the step indicator', async () => { const endpoint = '/upload'; - const { getByLabelText, getByText, findByText } = render( + const { getByLabelText, getByText, queryByText, findByText } = render( { json: () => ({ success: false, remaining_attempts: 1, errors: [{}] }), }); + expect(queryByText('idv.troubleshooting.options.verify_in_person')).not.to.exist(); + await userEvent.click(getByText('forms.buttons.submit.default')); + expect(queryByText('idv.troubleshooting.options.verify_in_person')).not.to.exist(); + const frontImage = getByLabelText('doc_auth.headings.document_capture_front'); const backImage = getByLabelText('doc_auth.headings.document_capture_back'); await userEvent.upload(frontImage, validUpload); From dfad07154ac91b2cf27c5a50a15e43583f6db368 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Mon, 31 Oct 2022 11:19:56 -0400 Subject: [PATCH 2/2] Collapse hasErrors, showInPersonOption to showAlternativeProofingOptions See: https://github.com/18F/identity-idp/pull/7254#discussion_r1009504812 --- .../components/barcode-attention-warning.tsx | 2 +- .../components/capture-advice.jsx | 2 +- ...t-capture-troubleshooting-options.spec.tsx | 94 +++++++++---------- ...cument-capture-troubleshooting-options.tsx | 14 +-- .../components/review-issues-step.tsx | 3 +- 5 files changed, 51 insertions(+), 64 deletions(-) diff --git a/app/javascript/packages/document-capture/components/barcode-attention-warning.tsx b/app/javascript/packages/document-capture/components/barcode-attention-warning.tsx index 22c978cf583..84b7519f07e 100644 --- a/app/javascript/packages/document-capture/components/barcode-attention-warning.tsx +++ b/app/javascript/packages/document-capture/components/barcode-attention-warning.tsx @@ -60,7 +60,7 @@ function BarcodeAttentionWarning({ onDismiss, pii }: BarcodeAttentionWarningProp } > diff --git a/app/javascript/packages/document-capture/components/capture-advice.jsx b/app/javascript/packages/document-capture/components/capture-advice.jsx index c11c1554b5a..74c0a81a1bf 100644 --- a/app/javascript/packages/document-capture/components/capture-advice.jsx +++ b/app/javascript/packages/document-capture/components/capture-advice.jsx @@ -29,7 +29,7 @@ function CaptureAdvice({ onTryAgain, isAssessedAsGlare, isAssessedAsBlurry }) { } > diff --git a/app/javascript/packages/document-capture/components/document-capture-troubleshooting-options.spec.tsx b/app/javascript/packages/document-capture/components/document-capture-troubleshooting-options.spec.tsx index b479c5800cb..3fac80b249c 100644 --- a/app/javascript/packages/document-capture/components/document-capture-troubleshooting-options.spec.tsx +++ b/app/javascript/packages/document-capture/components/document-capture-troubleshooting-options.spec.tsx @@ -125,75 +125,69 @@ describe('DocumentCaptureTroubleshootingOptions', () => { }); context('in person proofing links', () => { - context('no errors and no inPersonURL', () => { + context('without inPersonURL', () => { it('has no IPP information', () => { const { queryByText } = render(); expect(queryByText('components.troubleshooting_options.new_feature')).to.not.exist(); }); - }); - context('hasErrors but no inPersonURL', () => { - it('has no IPP information', () => { - const { queryByText } = render(); + context('with showAlternativeProofingOptions', () => { + it('has no IPP information', () => { + const { queryByText } = render( + , + ); - expect(queryByText('components.troubleshooting_options.new_feature')).to.not.exist(); + expect(queryByText('components.troubleshooting_options.new_feature')).to.not.exist(); + }); }); }); - context('hasErrors and inPersonURL', () => { + context('with inPersonURL', () => { const wrapper: ComponentType = ({ children }) => ( {children} ); - it('has link to IPP flow', () => { - const { getByText, getByRole } = render( - , - { wrapper }, - ); - - expect(getByText('components.troubleshooting_options.new_feature')).to.exist(); - - const link = getByRole('link', { name: 'idv.troubleshooting.options.verify_in_person' }); - - expect(link).to.exist(); - }); - - it('logs an event when clicking the troubleshooting option', async () => { - const trackEvent = sinon.stub(); - const { getByRole } = render( - - - , - { wrapper }, - ); - - const link = getByRole('link', { name: 'idv.troubleshooting.options.verify_in_person' }); - await userEvent.click(link); + it('has no IPP information', () => { + const { queryByText } = render(); - expect(trackEvent).to.have.been.calledWith( - 'IdV: verify in person troubleshooting option clicked', - ); + expect(queryByText('components.troubleshooting_options.new_feature')).to.not.exist(); }); - }); - - context('hasErrors and inPersonURL but showInPersonOption is false', () => { - const wrapper: ComponentType = ({ children }) => ( - - {children} - - ); - - it('does not have link to IPP flow', () => { - const { queryAllByText, queryAllByRole } = render( - , - { wrapper }, - ); - expect(queryAllByText('components.troubleshooting_options.new_feature').length).to.equal(0); - expect(queryAllByRole('button').length).to.equal(0); + context('with showAlternativeProofingOptions', () => { + it('has link to IPP flow', () => { + const { getByText, getByRole } = render( + , + { + wrapper, + }, + ); + + expect(getByText('components.troubleshooting_options.new_feature')).to.exist(); + + const link = getByRole('link', { name: 'idv.troubleshooting.options.verify_in_person' }); + + expect(link).to.exist(); + }); + + it('logs an event when clicking the troubleshooting option', async () => { + const trackEvent = sinon.stub(); + const { getByRole } = render( + + + , + { wrapper }, + ); + + const link = getByRole('link', { name: 'idv.troubleshooting.options.verify_in_person' }); + await userEvent.click(link); + + expect(trackEvent).to.have.been.calledWith( + 'IdV: verify in person troubleshooting option clicked', + ); + }); }); }); }); diff --git a/app/javascript/packages/document-capture/components/document-capture-troubleshooting-options.tsx b/app/javascript/packages/document-capture/components/document-capture-troubleshooting-options.tsx index 5194da8af16..5ef435a0a60 100644 --- a/app/javascript/packages/document-capture/components/document-capture-troubleshooting-options.tsx +++ b/app/javascript/packages/document-capture/components/document-capture-troubleshooting-options.tsx @@ -24,22 +24,16 @@ interface DocumentCaptureTroubleshootingOptionsProps { showDocumentTips?: boolean; /** - * Whether to include option to verify in person. + * Whether to display alternative options for verifying. */ - showInPersonOption?: boolean; - - /** - * If there are any errors (toggles whether or not to show in person proofing option) - */ - hasErrors?: boolean; + showAlternativeProofingOptions?: boolean; } function DocumentCaptureTroubleshootingOptions({ heading, location = 'document_capture_troubleshooting_options', showDocumentTips = true, - showInPersonOption = true, - hasErrors, + showAlternativeProofingOptions, }: DocumentCaptureTroubleshootingOptionsProps) { const { t } = useI18n(); const { inPersonURL } = useContext(FlowContext); @@ -49,7 +43,7 @@ function DocumentCaptureTroubleshootingOptions({ return ( <> - {hasErrors && inPersonURL && showInPersonOption && ( + {showAlternativeProofingOptions && inPersonURL && ( } >