chore(modal): add/update test cypress tests for modal #5081
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What: Steps toward closing #3953
This PR adds adds a couple of new tests for modal which test to ensure focustrap is working as expected as well as that pressing escape key with an open modal would close it. I spent some time trying to also verify that pressing enter on the close button (or cancel/confirm) would also close the modal, but for some reason the trigger/type functions for cypress didn't actually close the modal. I tried several combinations of the following:
....trigger('keydown', { keyCode: 13, which: 13 });
....type('{enter}')
Any idea why these won't simulate the keypress event? The functionality does obviously work, just that cypress can't seem to invoke it. I could cheap out and go for
click()
which works fine, but the main point of the issue is to test keyboard interactivity so not sure that would fully exercise the right path in the code.In any case, what's here should help prevent regressions to keyboard interactivity in the future, would be cool to get it merged and circle back to the pressing enter issue if possible.
I also fixed a small issue where one of the examples in the test suite was missing an accessible name.