Skip to content

LG-13864 Create profile after USPS enrollment#11034

Merged
shanechesnutt-ft merged 1 commit intomainfrom
sc/LG-13864
Aug 9, 2024
Merged

LG-13864 Create profile after USPS enrollment#11034
shanechesnutt-ft merged 1 commit intomainfrom
sc/LG-13864

Conversation

@shanechesnutt-ft
Copy link
Contributor

@shanechesnutt-ft shanechesnutt-ft commented Aug 6, 2024

🎫 Ticket

LG-13864

🛠 Summary of changes

  • Change the order of events when the enter password form is submitted in the IPP flow. The USPS enrollment request will be made before a profile is created. Currently, when the USPS enrollment request fails the following issues occur:
  1. Users are no longer about to retry enter password form because the IdvStepConcern before action no_pending_profile check automatically navigates the user back to the account page.
  2. Users are stuck in a loop in account page where they cannot re-attempt verification.

These issues stem from the user having a profile with an enrollment in the establishing state after a USPS enrollment failure occurs.

📜 Testing Plan

Scenario: USPS enrollment failure during ID-IPP enrollment

  • Login through the oidc sinatra application selecting the Identity Verified level of service.
  • Create a new account
  • Continue through the in-person enrollment flow
  • Once on the /verify/in_person/state_id page use the first name of usps client error when filling out the form and submit
  • Continue through the flow until reaching the /verify/enter_password
  • Re-enter password and submit the form
  • Verify that the There was an internal error processing your request. Please try again. error message appears on the /verify/enter_password page and you are able to re-enter your password.

Scenario: User drops off after USPS enrollment failure during ID-IPP enrollment

  • Login through the oidc sinatra application selecting the Identity Verified level of service.
  • Create a new account
  • Continue through the in-person enrollment flow
  • Once on the /verify/in_person/state_id page use the first name of usps client error when filling out the form and submit
  • Continue through the flow until reaching the /verify/enter_password
  • Re-enter password and submit the form
  • Verify that the There was an internal error processing your request. Please try again. error message appears on the /verify/enter_password page and you are able to re-enter your password.
  • Navigate to the /account page.
  • Click on the Continue identity verification link
  • Ensure the flow work for in-person verification

@shanechesnutt-ft shanechesnutt-ft force-pushed the sc/LG-13864 branch 2 times, most recently from 00487b8 to a4824c2 Compare August 7, 2024 13:58
@shanechesnutt-ft shanechesnutt-ft marked this pull request as ready for review August 7, 2024 14:08
@shanechesnutt-ft shanechesnutt-ft requested review from a team and jennyverdeyen August 7, 2024 14:08
Copy link
Contributor

@n1zyy n1zyy left a comment

Choose a reason for hiding this comment

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

This looks good to me. A profile is meant to represent a proofing attempt. IMHO it's fair to say that if the proofing attempt never really got off the ground, we won't create the profile in the first place.

I wouldn't mind getting @jmhooper or @matthinz to weigh in on this as they have much deeper experience with Profiles, but it's a yes from me.

I'm leaving a comment voicing support vs. giving an approval only because I haven't tested this and Team Joy is awesome about doing thorough testing.

My two inline comments are unrelated to the core issue here and totally optional.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unimportant nit: I think these two lines read kind of confusingly: "If the user already as an in-person enrollment, schedule an in-person enrollment for them." I'm not sure if there's an easy way to fix this with a rename, though?

Copy link
Contributor

Choose a reason for hiding this comment

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

I also find this confusing. Maybe we could rename has_in_person_enrollment? to has_unscheduled_in_person_enrollment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with that the naming could be better... my only issue is that the has_in_person_enrollment? checks for pending or establishing in-person enrollments. Unscheduled should only care about establishing in-person enrollments right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would needs_in_person_verification? be a clearer method name? I got that idea from the in_person_verification_needed param for profile_maker’s save_profile method.

It could also be renamed has_begun_in_person_proofing?, but I worry that’s too vague. Technically, a user who has a failed in_person_enrollment has also begun in person proofing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unscheduled should only care about establishing in-person enrollments right?

I have a n00b question. If unscheduled only refers to establishing in_person_enrollments, why schedule an enrollment when a user has a pending or establishing in_person_enrollment? Could this conditional be refactored to only check if the user has an establishing in_person_enrollment?

The enrollment helper’s schedule_in_person_enrollment returns if the user doesn’t have an establishing in_person_enrollment, which makes me think that this refactor wouldn’t actually change the method’s behavior.

Let me know if I’m missing something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Idle musing: it's easy to miss what this is doing, and instead just skim this and see it as doing normal steps, in which case it's unclear why an error would be expected. We had experimented a bit with descriptively-named helper methods to make some of this clearer, though I don't know where that ended up. I wonder if it would make sense to put this in a method like complete_up_to_enter_password_step_with_usps_client_error and just call that in the before here? (It's totally possible this is a bad idea. Just mentioning it in case it resonates.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I feel like it is unclear as well... I think this is because I was working around the fact that we are using the mock proofer in the tests. Maybe I should change the tests to use the real proofer, and mock the http endpoint. That would make the test setup have an explicit step for mocking the OptInIPPApplicant endpoint to return a 400 response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this is turning out to be a bigger fish than I want to fry right now... I ended up adding a comment above that line that states why the first_name is set to usps client error. I think it would be nice to improve these feature tests at a later date.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it would make sense to put this in a method like complete_up_to_enter_password_step_with_usps_client_error and just call that in the before here?

I get wanting to make the test easier to follow. In the spirit of write everything twice, I wanted to point out that making a helper method which isn't used much could be a premature optimization.

Copy link
Contributor

@matthinz matthinz left a comment

Choose a reason for hiding this comment

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

I agree with @n1zyy's assessment here: looks good to me! I will leave it to Team Joy to approve

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

I left a lot of comments. 😅 Hope they're helpful! I was mostly curious about the conversation about potentially renaming current_user.has_in_person_enrollment?.

Test coverage looks good. Thanks for fixing this so quickly. 👏🏻

Copy link
Contributor

Choose a reason for hiding this comment

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

Would you be up for calling the subject inside each it block, instead of in the before block? I tend to think of before blocks as a home for setup. It feels kind of odd to have what we're testing in the before block, rather than in the it block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I moved this to before block because I felt like it would dry up the it blocks a bit. My understanding is that before blocks are for both setup and execution of code under test. That being said I don't mind putting subject call in the it block it, it just feels like a lot of unnecessary duplication.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Instead of having let(:profile) { subject.profile } on both L197 and L241, you could just define profile once at the top of the "with establishing in person enrollment" context block.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above: could the subject be called in the it block instead of in the before block?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would needs_in_person_verification? be a clearer method name? I got that idea from the in_person_verification_needed param for profile_maker’s save_profile method.

It could also be renamed has_begun_in_person_proofing?, but I worry that’s too vague. Technically, a user who has a failed in_person_enrollment has also begun in person proofing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unscheduled should only care about establishing in-person enrollments right?

I have a n00b question. If unscheduled only refers to establishing in_person_enrollments, why schedule an enrollment when a user has a pending or establishing in_person_enrollment? Could this conditional be refactored to only check if the user has an establishing in_person_enrollment?

The enrollment helper’s schedule_in_person_enrollment returns if the user doesn’t have an establishing in_person_enrollment, which makes me think that this refactor wouldn’t actually change the method’s behavior.

Let me know if I’m missing something.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it would make sense to put this in a method like complete_up_to_enter_password_step_with_usps_client_error and just call that in the before here?

I get wanting to make the test easier to follow. In the spirit of write everything twice, I wanted to point out that making a helper method which isn't used much could be a premature optimization.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding test coverage for this! 👏🏻

Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻

@shanechesnutt-ft shanechesnutt-ft force-pushed the sc/LG-13864 branch 3 times, most recently from 1a8fc6c to b4653c7 Compare August 8, 2024 19:56
Copy link
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, good work. 👍🏻 (I think we should try and get another Joy engineer to approve this before we merge it, too. I'll post in slack.)

@gina-yamada
Copy link
Contributor

gina-yamada commented Aug 9, 2024

@shanechesnutt-ft I worked through both scenarios in your testing plan. The flow is working as I'd expect now. I also went on to enter a good first name and eventually all the way to successfully create a barcode. Going to review code changes now (more to come) but this is looking good. As on-call engineer this week, I am very excited for this to go in. Thank you

I tested main. I am able to create a barcode when I use a random first name.

When I tested on main and use usps client error I got error undefined method due datefor nil inapp/presenters/account_show_presenter.rb` inside of
formatted_ipp_due_date.

This error does not occur on Shane's branch (after main was merged in)- it is fixed. Shane and I walked through this. Shane's logic will help with the behavior I observed and what looks like pesky bugs that have popped up.

@WilliamBirdsall
Copy link
Contributor

Code LGTM. Added method on user seems helpful!

Copy link
Contributor

@WilliamBirdsall WilliamBirdsall left a comment

Choose a reason for hiding this comment

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

Ran through testing steps, looks good!

@gina-yamada gina-yamada self-requested a review August 9, 2024 15:51
changelog: Internal, In-person Proofing, Ensure the USPS schedule
enrollment request executes before a profile is created during the
in-person proofing flow.
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.

6 participants