-
Notifications
You must be signed in to change notification settings - Fork 167
LG-12307: don't allow upload when selfie capture is enabled #10232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
288cd84
3b37ac9
94a1aaf
53d47b9
aeecf5f
54f48c7
2eca1f8
35ccbe5
51aa7f7
4680c34
f542847
5d94d3e
d81b08c
6b5ff50
52cb866
992ce68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we rename this file to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! I did this in 4680c34, but it did start to cause larger issues. In order to get elements like the context providers in this file to be recognized by the TS linter, I had to add the path with So, I decided to keep what was easy to change, and use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, that's a great catch that we weren't type-checking While I feel pretty uneasy about
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with Andrew, I think making a separate ticket (or doing a follow-up PR) for this work is a good idea. 👍🏻
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you both!! I just created a ticket for this: LG-12711. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { DeviceContext, SelfieCaptureContext } from '@18f/identity-document-capture'; | ||
| import DocumentSideAcuantCapture from '@18f/identity-document-capture/components/document-side-acuant-capture'; | ||
| import { render } from '../../../support/document-capture'; | ||
|
|
||
| describe('DocumentSideAcuantCapture', () => { | ||
| const DEFAULT_PROPS = { | ||
| errors: [], | ||
| registerField: () => undefined, | ||
| }; | ||
|
|
||
| context('when selfie is _not_ enabled', () => { | ||
| it('_does_ display a photo upload button', () => { | ||
| const { queryAllByText } = render( | ||
| <SelfieCaptureContext.Provider value={{ isSelfieCaptureEnabled: false }}> | ||
| <DeviceContext.Provider value={{ isMobile: true }}> | ||
|
night-jellyfish marked this conversation as resolved.
Outdated
|
||
| <DocumentSideAcuantCapture {...DEFAULT_PROPS} side="front" /> | ||
| <DocumentSideAcuantCapture {...DEFAULT_PROPS} side="back" /> | ||
| </DeviceContext.Provider> | ||
| </SelfieCaptureContext.Provider>, | ||
| ); | ||
|
|
||
| const takeOrUploadPictureText = queryAllByText( | ||
| 'doc_auth.buttons.take_or_upload_picture_html', | ||
| ); | ||
| expect(takeOrUploadPictureText).to.have.lengthOf(2); | ||
| }); | ||
| }); | ||
|
|
||
| context('when selfie _is_ enabled', () => { | ||
| it('does _not_ display a photo upload button', () => { | ||
| const { queryAllByText } = render( | ||
| <SelfieCaptureContext.Provider value={{ isSelfieCaptureEnabled: true }}> | ||
| <DeviceContext.Provider value={{ isMobile: true }}> | ||
| <DocumentSideAcuantCapture {...DEFAULT_PROPS} side="front" /> | ||
| <DocumentSideAcuantCapture {...DEFAULT_PROPS} side="back" /> | ||
| <DocumentSideAcuantCapture {...DEFAULT_PROPS} side="selfie" /> | ||
| </DeviceContext.Provider> | ||
| </SelfieCaptureContext.Provider>, | ||
| ); | ||
|
|
||
| const takePictureText = queryAllByText('doc_auth.buttons.take_picture'); | ||
| expect(takePictureText).to.have.lengthOf(3); | ||
|
|
||
| const notExpectedText = 'doc_auth.buttons.take_or_upload_picture_html'; | ||
| expect(queryAllByText(notExpectedText)).to.be.an('array').that.is.empty; | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| import { useContext } from 'react'; | ||
| import { renderHook } from '@testing-library/react-hooks'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { DeviceContext, AnalyticsContext } from '@18f/identity-document-capture'; | ||
| import { | ||
| DeviceContext, | ||
| AnalyticsContext, | ||
| SelfieCaptureContext, | ||
| } from '@18f/identity-document-capture'; | ||
| import { Provider as AcuantContextProvider } from '@18f/identity-document-capture/context/acuant'; | ||
| import AcuantCapture from '@18f/identity-document-capture/components/acuant-capture'; | ||
| import FailedCaptureAttemptsContext, { | ||
|
|
@@ -164,6 +168,58 @@ describe('FailedCaptureAttemptsContext testing of forceNativeCamera logic', () = | |
| expect(result.current.failedCaptureAttempts).to.equal(1); | ||
| expect(result.current.forceNativeCamera).to.equal(false); | ||
| }); | ||
|
|
||
| describe('when selfie is enabled', () => { | ||
| it('forceNativeCamera is always false, no matter how many times any attempt fails', () => { | ||
| const trackEvent = sinon.spy(); | ||
| const { result, rerender } = renderHook(() => useContext(FailedCaptureAttemptsContext), { | ||
| wrapper: ({ children }) => ( | ||
| <SelfieCaptureContext.Provider value={{ isSelfieCaptureEnabled: true }}> | ||
| <Provider | ||
| maxCaptureAttemptsBeforeNativeCamera={2} | ||
| maxSubmissionAttemptsBeforeNativeCamera={2} | ||
| > | ||
| {children} | ||
| </Provider> | ||
| </SelfieCaptureContext.Provider> | ||
| ), | ||
| }); | ||
|
|
||
| result.current.onFailedCaptureAttempt({ | ||
| isAssessedAsGlare: true, | ||
| isAssessedAsBlurry: false, | ||
| }); | ||
| rerender(true); | ||
| expect(result.current.forceNativeCamera).to.equal(false); | ||
| result.current.onFailedCaptureAttempt({ | ||
| isAssessedAsGlare: false, | ||
| isAssessedAsBlurry: true, | ||
| }); | ||
| rerender(true); | ||
| expect(result.current.forceNativeCamera).to.equal(false); | ||
| result.current.onFailedCaptureAttempt({ | ||
| isAssessedAsGlare: false, | ||
| isAssessedAsBlurry: true, | ||
| }); | ||
| rerender({}); | ||
| expect(result.current.failedCaptureAttempts).to.equal(3); | ||
| expect(result.current.forceNativeCamera).to.equal(false); | ||
|
|
||
| result.current.onFailedSubmissionAttempt(); | ||
| rerender(true); | ||
| expect(result.current.forceNativeCamera).to.equal(false); | ||
| result.current.onFailedSubmissionAttempt(); | ||
| rerender(true); | ||
| expect(result.current.forceNativeCamera).to.equal(false); | ||
| result.current.onFailedSubmissionAttempt(); | ||
| rerender({}); | ||
| expect(result.current.failedSubmissionAttempts).to.equal(3); | ||
| expect(result.current.forceNativeCamera).to.equal(false); | ||
| expect(trackEvent).to.not.have.been.calledWith( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
||
| 'IdV: Native camera forced after failed attempts', | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('maxCaptureAttemptsBeforeNativeCamera logging tests', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kellular and @daviddsilvanava - This is replacing #10165 and thanks to other work from Timnit, by now shouldn't have the UX issues we talked about on that PR.