LG-12307: don't allow upload when selfie capture is enabled#10232
Conversation
The "IdV: Native camera forced after failed attempts" event was firing even though the previous commit disallows file upload and use of the native camera. This commit prevents this event from firing.
isSelfieDesktopMode is needed in the next commit to allow upload when isSelfieDesktopMode is true.
Without looking at this value, we won't be able to upload yml files if desktop test mode and selfie are both enabled.
spec/javascript/packages/document-capture/context/selfie-capture-spec.jsx
Show resolved
Hide resolved
app/javascript/packages/document-capture/context/failed-capture-attempts.tsx
Outdated
Show resolved
Hide resolved
| @@ -7,6 +7,7 @@ import type { | |||
| RegisterFieldCallback, | |||
There was a problem hiding this comment.
@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.
app/javascript/packages/document-capture/context/failed-capture-attempts.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Can we rename this file to .tsx extension to make sure that all new code is TypeScript ?
There was a problem hiding this comment.
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 .tsx to tsconfig.json. Doing this caused other files to start erroring out when running yarn tsc. I fixed the one that was easy to fix (document-capture-abandon-spec.tsx). But when I tried to fix spec/javascript/support/document-capture.jsx, I found myself reaching into several additional files that then failed and needed adjustments themselves, until the whole change was getting to be quite large. I also found some of the issues I wasn't sure how to fix.
So, I decided to keep what was easy to change, and use // @ts-ignore on the rest.
There was a problem hiding this comment.
Wow, that's a great catch that we weren't type-checking .tsx files. Good call on fixing that.
While I feel pretty uneasy about @ts-ignore generally speaking, I think if it's causing a lot of short-term issues, we could follow-up on it separately. Can you either create a ticket or plan to follow-up with a separate pull request for that, to keep ourselves accountable?
There was a problem hiding this comment.
I agree with Andrew, I think making a separate ticket (or doing a follow-up PR) for this work is a good idea. 👍🏻
There was a problem hiding this comment.
Thank you both!!
I just created a ticket for this: LG-12711.
|
@night-jellyfish , looks like for row3/row5, after failed 3 times and taking id image using native camera, the image is not uploaded to the box most of the time. Update: tried on |
… enabled, only allow images through SDK
spec/javascript/packages/document-capture/components/document-side-acuant-capture-spec.jsx
Outdated
Show resolved
Hide resolved
eileen-nava
left a comment
There was a problem hiding this comment.
Approved. 👍🏻 Two things:
- I only locally tested the mobile scenarios where
doc_auth_selfie_capture_enabled: trueanddoc_auth_selfie_desktop_test_mode: falseordoc_auth_selfie_capture_enabled: trueanddoc_auth_selfie_desktop_test_mode: true. - I agree with writing a ticket or making a follow-up PR to remove
// @ts-ignorefromspec/javascript/support/document-capture.jsx.
| } | ||
|
|
||
| const forceNativeCamera = | ||
| const hasExhaustedAttempts = |
There was a problem hiding this comment.
Nice variable naming here. 👍🏻
There was a problem hiding this comment.
Thank you! Credit goes to @aduth for thinking of this name 😁
| 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; |
There was a problem hiding this comment.
I thought this was nice too! Really readable syntax and we have it elsewhere in our code. However as I was adding tests in d81b08c, I found that that.is.empty returned true even when the length of the array was more than 0. In other words...it doesn't seem to do what I'd expect, or what the docs imply. So I updated it to to.have.lengthOf(0). Less pleasant to read, but more accurate results.
There was a problem hiding this comment.
that.is.empty returned true even when the length of the array was more than 0
WHAT. 😮 That is unexpected. I would be curious to hear more during a 1:1.
There was a problem hiding this comment.
I'd wonder if it's the lack of parentheses? I'm not sure I'd expect Chai's default optional parentheses to not work, but we do use the dirty-chai plugin with the expectation to prefer explicit parantheses.
There was a problem hiding this comment.
Oh my gosh you're right! I just tested and if I do .that.is.empty() it fails where I'd expect it to. If I do .that.is.empty it passes.
That is so confusing since the document from Chai I linked displays it without parens.
There was a problem hiding this comment.
Yeah, that's a TIL, and very confusing. I would have thought dirty-chai just makes the parentheses work, not that it requires them 😕
| rerender({}); | ||
| expect(result.current.failedSubmissionAttempts).to.equal(3); | ||
| expect(result.current.forceNativeCamera).to.equal(false); | ||
| expect(trackEvent).to.not.have.been.calledWith( |
There was a problem hiding this comment.
I agree with Andrew, I think making a separate ticket (or doing a follow-up PR) for this work is a good idea. 👍🏻
…ie-use-new-react-context
…ie-use-new-react-context
🎫 Ticket
LG-12307
🛠 Summary of changes
When doc auth with selfie is required, the FE only allows adding ID and selfie images using the Acuant SDK.
(unless
doc_auth_selfie_desktop_test_mode: true, then we still want to allow uploads)📜 Testing Plan
This one is a bit involved when it comes to testing. This is because between the differences between mobile and desktop, and the two flags:
... there are 8 different states it can be in. To make it a little easier, I made an Excel spreadsheet with the 8 states and what their expected result are.
application.ymlIn addition, note that you can fail the SDK capture by trying to take a photo of your laptop trackpad. If it's too well lit, SDK capture may still pass, but you can put a hand over your phone to cause a shadow that will make it fail.
👀 Screenshots
If relevant, include a screenshot or screen capture of the changes.
Before:
After: