LG-13864 Create profile after USPS enrollment#11034
Conversation
00487b8 to
a4824c2
Compare
n1zyy
left a comment
There was a problem hiding this comment.
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.
app/services/idv/session.rb
Outdated
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I also find this confusing. Maybe we could rename has_in_person_enrollment? to has_unscheduled_in_person_enrollment?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
spec/features/idv/in_person_spec.rb
Outdated
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
eileen-nava
left a comment
There was a problem hiding this comment.
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. 👏🏻
spec/services/idv/session_spec.rb
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
spec/services/idv/session_spec.rb
Outdated
There was a problem hiding this comment.
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.
spec/services/idv/session_spec.rb
Outdated
There was a problem hiding this comment.
Same comment as above: could the subject be called in the it block instead of in the before block?
app/services/idv/session.rb
Outdated
There was a problem hiding this comment.
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.
app/services/idv/session.rb
Outdated
There was a problem hiding this comment.
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.
spec/features/idv/in_person_spec.rb
Outdated
There was a problem hiding this comment.
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.
spec/features/idv/in_person_spec.rb
Outdated
There was a problem hiding this comment.
Thanks for adding test coverage for this! 👏🏻
1a8fc6c to
b4653c7
Compare
eileen-nava
left a comment
There was a problem hiding this comment.
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.)
|
@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 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. |
b4653c7 to
434afb9
Compare
|
Code LGTM. Added method on user seems helpful! |
WilliamBirdsall
left a comment
There was a problem hiding this comment.
Ran through testing steps, looks good!
changelog: Internal, In-person Proofing, Ensure the USPS schedule enrollment request executes before a profile is created during the in-person proofing flow.
434afb9 to
4a5e059
Compare
🎫 Ticket
LG-13864
🛠 Summary of changes
IdvStepConcernbefore actionno_pending_profilecheck automatically navigates the user back to the account page.These issues stem from the user having a profile with an enrollment in the
establishingstate after a USPS enrollment failure occurs.📜 Testing Plan
Scenario: USPS enrollment failure during ID-IPP enrollment
Identity Verifiedlevel of service./verify/in_person/state_idpage use the first name ofusps client errorwhen filling out the form and submit/verify/enter_passwordThere was an internal error processing your request. Please try again.error message appears on the/verify/enter_passwordpage and you are able to re-enter your password.Scenario: User drops off after USPS enrollment failure during ID-IPP enrollment
Identity Verifiedlevel of service./verify/in_person/state_idpage use the first name ofusps client errorwhen filling out the form and submit/verify/enter_passwordThere was an internal error processing your request. Please try again.error message appears on the/verify/enter_passwordpage and you are able to re-enter your password./accountpage.Continue identity verificationlink