LG-7205: Log click on in-person troubleshooting option#6907
Conversation
**Why**: To have better insight into the user's journey through in-person proofing. changelog: Upcoming Features, In-person proofing, Improve analytics for in-person proofing actions
| options={[{ text: t('idv.troubleshooting.options.verify_in_person') }]} | ||
| options={[ | ||
| { | ||
| url: '#location', |
There was a problem hiding this comment.
A bit of a cheat, but working as intended: Because FormSteps reflects the step as encoded in the URL hash fragment, we can link directly to the step, rather than using the submit button (BlockSubmitButton) to navigate as a submission of the step.
This was a workaround to an issue where onClick wasn't being called due to the fact that we were only spreading props on the link version of the option, not the button version:
| }); | ||
|
|
||
| const links = /** @type {HTMLAnchorElement[]} */ (getAllByRole('link')); | ||
| const links = getAllByRole('link') as HTMLAnchorElement[]; |
There was a problem hiding this comment.
If we update these tests later, then I'd like to see this refactored to be more white-box or black-box rather than straddling the two by using getAllByRole with white-box checks. Combining the two like this reduces the assurance that the elements will behave as expected.
Probably would be good enough here to add an expect that the fetched elements are instances of HTMLAnchorElement, or to fetch using the tag name.
There was a problem hiding this comment.
Yeah this inconsistency is necessary to appease both Testing Library and TypeScript:
- Testing Library because it intentionally doesn't provide element querying utilities to encourage testing as the users (and assistive technology) would interact with the application.
- TypeScript because it wouldn't expect
#targetto exist on anything other than an anchor element.
It would be nice if there were some way to test to see that the link opens in a new tab without referencing the attribute value directly like this, so we could avoid casting the result of getByRole.
Why: To have better insight into the user's journey through in-person proofing.
Testing Instructions:
tail -n2 log/events.log