LG-4001: Fix async verify step alert flashes not being shown#4554
LG-4001: Fix async verify step alert flashes not being shown#4554
Conversation
|
This is closer to being ready. One new challenge I'm encountering is that we can't use the |
|
Quick update: To better support the phone validation errors, I'm looking to try experimenting with an implementation like one considered earlier on, which is to try to parse the redirected response HTML to discover if any alerts are included in the markup and to show those in the current form (building on |
Implemented in ec5d505. Still need to test in the phone step. Here's how it looks in the preceding verify step: |
zachmargolis
left a comment
There was a problem hiding this comment.
Visually, I was thinking we'd put the error message at the top of the page like our other flashes? But functionality-wise this LGTM
There was a problem hiding this comment.
What about the null-safe navigator? Or is that different because it returns undefined instead of null?
| return textContent ? textContent.trim() : null; | |
| return textContent?.trim(); |
There was a problem hiding this comment.
What about the null-safe navigator? Or is that different because it returns
undefinedinstead ofnull?
Yeah, your suggestion can work, but as you mention, it returns undefined. Purely for the sake of keeping the return type to string or null, the ternary is used.
It could be simplified even further if we'd not mind a return type of string?=:
return dom.querySelector(selector)?.textContent?.trim();There was a problem hiding this comment.
It could be simplified even further if we'd not mind a return type of
string?=:
That works for me!
Yeah, I'd had the same expectation. It was made difficult by the fact that That being said, maybe we could create an option for the target element container for notices, so we could do something like: <div id="form-wait-steps-alert"></div>
<!-- ...Page contents... -->
<%= button_to(form: { data: { error_alert_target: 'form-wait-steps-alert' } }) %> |
I like that option! Could add in a follow-up PR if you wanted to merge this one sooner |
|
Added alert target support in a88ea88.
Couple issues here:
It's kinda difficult to have generic logic know when a step is "done":
|
I could be misunderstanding, but what if we detect I was looking into ways to maybe add an HTTP header we could key off of....but unfortunately because we use |
Yeah, that could work as well. I'd started chipping away at this a bit earlier, where I was originally thinking something along the lines of (pseudo-code): isRedirectedToNextStep = (redirectPath) =>
redirectPath !== location.pathname &&
redirectPath !== location.pathname + '_wait' |
After some tinkering, ultimately I think this will be the most reliable check. And as you mention, since we've got the precedent for scraping the response, it's not a far stretch to implement. Updated in 4aaa63d. Only thing remaining here is that I'd like to have some more JS test coverage in rspec feature tests for the flow. |
app/views/idv/phone/new.html.erb
Outdated
There was a problem hiding this comment.
this is always success because took this out of verify_wait_step_show right?
There was a problem hiding this comment.
this is always success because took this out of
verify_wait_step_showright?
Right, instead of assigning by flash, we statically show the alert on the following step. This makes an assumption that the only case for reaching this view is via successful completion of the verify step.
There was a problem hiding this comment.
maybe we could just delete all rows here instead of stubbing?
There was a problem hiding this comment.
maybe we could just delete all rows here instead of stubbing?
Seems like it'd be an improvement, but in trying this out, this triggers a different behavior, because it seems to kill off the session value and cause a none result instead of a timed_out result.
identity-idp/app/services/idv/phone_step.rb
Lines 22 to 25 in e1be6c2
Another option (probably more ideal anyways) would be to remove the Redis entries loaded here:
identity-idp/app/services/idv/phone_step.rb
Lines 27 to 28 in e1be6c2
But that doesn't appear to be directly exposed.
This code was also partly inherited from the verify step specs, where the mock is restored to simulate an eventual success. Not sure we care to have something similar here, though it'd be made difficult if we outright deleted those entries.
There was a problem hiding this comment.
Ok good point, likely not worth it, probably fine to continue stubbing
**Why**: Redirects from JavaScript-based form-steps-wait behavior will cause flash messages to be dropped. To make "sticky", use existing flow_session error message for error messages, and statically render success on following phone step view.
**Why**: As a user, I expect that I am informed when the server encounters an unhandled error, so that I can retry my request later, and am not left confused by an infinitely-spinning spinner.
**Why**: Needed in cases where e.g. spinner background action fails and button should be reset.
**Why**: To prevent user from thinking background processing is still happening, and to allow user to resubmit.
**Why**: So that user is informed that a problem occurred
**Why**: Avoid lingering state of `errorMessage` scope variable between distinct contexts.
**Why**: Not using flow_sesion for error message. Consistency amongst verify view between CAC and DocAuth flows.
**Why**: Can't parse alert from response if not receiving response body
**Why**: Most reliable indication of whether a polling request should be scheduled is the presence of a refresh tag on the response.
**Why**: Else, flash may persist to subsequent requqest
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
d63c7c0 to
ddaa455
Compare


Related (optionally blocked by): #4553
Why: Redirects from JavaScript-based form-steps-wait behavior will cause flash messages to be dropped. To make "sticky", use existing flow_session error message for error messages, and statically render success on following phone step view.
Why: As a user, I expect that I am informed when the server encounters an unhandled error, so that I can retry my request later, and am not left confused by an infinitely-spinning spinner.