Skip to content

LG-12307: don't allow upload when selfie capture is enabled#10232

Merged
night-jellyfish merged 16 commits intomainfrom
brittany/lg-12307-only-capture-sdk-when-selfie-use-new-react-context
Mar 14, 2024
Merged

LG-12307: don't allow upload when selfie capture is enabled#10232
night-jellyfish merged 16 commits intomainfrom
brittany/lg-12307-only-capture-sdk-when-selfie-use-new-react-context

Conversation

@night-jellyfish
Copy link
Copy Markdown
Contributor

🎫 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:

  doc_auth_selfie_capture_enabled
  doc_auth_selfie_desktop_test_mode

... 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.

  • Choose a line in the spreadsheet of possible outcomes
  • Make the needed adjustments to the two flags in your application.yml
  • Start / Restart the server (if this is your second+ time through)
  • Get to the doc auth capture screen (if you follow these directions you should only need one account and can mostly cut the server on this page and just reload)
  • Test the outcome according to the "Expected outcome" column for the line of the spreadsheet you're on
  • Mark how it went under the "When testing PR" column
  • ctrl + c out of the server (don't run make setup)
  • start again

In 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:

image

After:

image

Brittany Greaner added 5 commits March 11, 2024 13:50
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.
@night-jellyfish night-jellyfish requested review from a team, charleyf and kellular and removed request for a team March 12, 2024 01:36
@@ -7,6 +7,7 @@ import type {
RegisterFieldCallback,
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this file to .tsx extension to make sure that all new code is TypeScript ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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 .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.

Copy link
Copy Markdown
Contributor

@aduth aduth Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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. 👍🏻

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you both!!

I just created a ticket for this: LG-12711.

@dawei-nava
Copy link
Copy Markdown
Contributor

dawei-nava commented Mar 12, 2024

@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 main branch, similar issue, so ....

Copy link
Copy Markdown
Contributor

@eileen-nava eileen-nava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. 👍🏻 Two things:

  1. I only locally tested the mobile scenarios where doc_auth_selfie_capture_enabled: true and doc_auth_selfie_desktop_test_mode: false or doc_auth_selfie_capture_enabled: true and doc_auth_selfie_desktop_test_mode: true.
  2. I agree with writing a ticket or making a follow-up PR to remove // @ts-ignore from spec/javascript/support/document-capture.jsx.

}

const forceNativeCamera =
const hasExhaustedAttempts =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice variable naming here. 👍🏻

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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. 👍🏻

@night-jellyfish night-jellyfish merged commit e9ee7b3 into main Mar 14, 2024
@night-jellyfish night-jellyfish deleted the brittany/lg-12307-only-capture-sdk-when-selfie-use-new-react-context branch March 14, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants