Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RealPress not firing click events on button elements #95

Closed
marcysutton opened this issue Jun 4, 2021 · 2 comments · Fixed by #132
Closed

RealPress not firing click events on button elements #95

marcysutton opened this issue Jun 4, 2021 · 2 comments · Fixed by #132
Labels

Comments

@marcysutton
Copy link

Hi there, thanks for the great project! I was excited to find it since I ran into issues with Cypress not firing native events (and it not being on their roadmap). This tool is promising for keyboard accessibility testing! But as far as I can tell, the Enter key still doesn't work the same way browsers do as of version 1.5.1. Specifically, hitting the Enter key on a Button element should fire a native click event and handler callback function. In Cypress-Real-Events, the event is getting lost somewhere in the stack. The tests added in #69 work for putting text into an Input element, but not firing a callback function on an interactive element's click handler.

I looked into the code a bit and saw RealPress is successfully catching the user event and firing off Input.dispatchKeyEvent to the DevTools protocol. But on multiple repos where I tested it, the click handler attached to a button won't fire on the Enter key. This is important for writing keyboard accessibility tests that mimic user behavior, so we can differentiate between things like <div tabindex="0" onclick="handleClick()"> and <button onclick="handleClick()>, where the div will fail to function without a key handler but the button will click on Enter.

How to test

I've added a failing test for this behavior in my fork, I'd be happy to submit a PR for it: marcysutton@70f8b73

Here's a live test page I made where you can compare the user experience with your keyboard to what Cypress-Real-Events is doing: https://marcy.codes/testing/cypress-real-events/

Screenshots

In my test page, when a user presses the Enter key on a button element it appends text to a DIV:
Cypress Test page showing a focused button and event details appended to the screen

With Cypress-Real-Events, the text is never appended to the DIV when .realPress('Enter') is fired on the button:
Cypress App opened to a RealPress test showing the button failing to operate


If you have any tips (and if I'm not missing something obvious), I could potentially work on a PR. I'd love to get this working. Thanks!

@dmtrKovalenko
Copy link
Owner

Thanks for this qualified reproduction, this helps a lot! 🙏

@dmtrKovalenko
Copy link
Owner

🎉 This issue has been resolved in version 1.5.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants