diff --git a/app/javascript/packages/document-capture/components/acuant-capture.tsx b/app/javascript/packages/document-capture/components/acuant-capture.tsx index 94259387c4e..5d2e6ae332c 100644 --- a/app/javascript/packages/document-capture/components/acuant-capture.tsx +++ b/app/javascript/packages/document-capture/components/acuant-capture.tsx @@ -504,8 +504,10 @@ function AcuantCapture( ); refreshAcuantFailureCookie(); - } else { + } else if (error === 'Camera not supported.') { setOwnErrorMessage(t('doc_auth.errors.camera.failed')); + } else { + setOwnErrorMessage(t('errors.general')); } setIsCapturingEnvironment(false); diff --git a/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx b/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx index b0b38f5c322..176b6a74f6a 100644 --- a/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx +++ b/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx @@ -288,6 +288,35 @@ describe('document-capture/components/acuant-capture', () => { expect(document.activeElement).to.equal(button); }); + it('shows a generic error if camera starts but cropping error occurs', async () => { + const trackEvent = sinon.spy(); + const { container, getByLabelText, findByText } = render( + + + + + + + , + ); + + initialize({ + start: sinon.stub().callsArgWithAsync(1, undefined, 'start-fail-code'), + }); + + const button = getByLabelText('Image'); + await userEvent.click(button); + await findByText('errors.general'); + + expect(window.AcuantCameraUI.end).to.have.been.calledOnce(); + expect(container.querySelector('.full-screen')).to.be.null(); + expect(trackEvent).to.have.been.calledWith('IdV: Image capture failed', { + field: 'test', + error: 'Cropping failure', + }); + expect(document.activeElement).to.equal(button); + }); + it('shows sequence break error', async () => { const trackEvent = sinon.spy(); const { container, getByLabelText, findByText } = render(