-
Notifications
You must be signed in to change notification settings - Fork 252
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
userEvent.click error when parent has inline style pointer-event definition and child css file pointer-event definition #662
Comments
Looks like a problem with the environment https://codesandbox.io/s/cool-fog-ocs84?file=/src/__tests__/example.test.tsx |
@jarretmoses If you figure out what is causing this I would be keen to know, as I am experiencing the same. |
@Jayphen its happening to me specifically on some antd setups I have. Was convinced it was when a child pointer event was set via css and then a parent via inline style but I couldn’t recreate it on my own so I’m stumped at the moment. |
I discovered that for me it was a misconfiguration of Fela (css in js lib) in my test harness causing styles to persist between tests. |
I am also encountering this issue when testing antd components (especially when trying to click on Confirmation dialogues and such) |
Same issue as @WilliamPriorielloGarda. |
@elado I was able to go up to 13.0.16. The changes in 13.1.x is what was problematic on my side. With version 13 we get access to the keyboard API as well. |
I think the logic here is faulty somehow 32e9712#diff-a681e050ffe760739876a36e05c9cfb1bb1ce0b6dae27c54152e16b9f6fac2f4 |
any news on this? as I'm getting this error quite a bit when trying to use the library with antd |
In my case, it was happening when I tried to click disabled buttons. |
In my case, it happened due to the Div as parent node -> userEvent.click works ✔️ <div><button /></div> Fieldset as parent node -> user.click does not work and this error appears ❌ fieldset is not disabled <fieldset>
<legend>...</legend>
<button />
<button />
</fieldset> |
Please consider the possibility that your components or your tests might be flawed and this error just highlights a false assumption. As explained on the PR introducing the error message you can wait for the element to be available. await waitFor(() => userEvent.click(element)) Should you find any bug please create a reproduction at codesandbox. |
Thanks for the tip, I will do it in the next issues. I forgot some details, I just edited the sandbox. I do not know if I still doing something wrong. https://codesandbox.io/s/userevent-662-fieldset-forked-sdz8w?file=/src/App.js |
@fscgustavo Thanks a lot for adding this. |
This is a bit strange - this is actually working because of the relatively unusual codesandbox test runner environment. If you download that sandbox and try to run the tests locally (standard CRA jest config), the tests fail. AFAIK most JSDom-based test environments don't typically include CSS files actually being loaded (e.g. jest's docs suggest you probably don't want to - https://jestjs.io/docs/webpack#handling-static-assets). Codesandbox's test runner is just sending everything to sandpack (their bundler), so it behaves more like webpack and actually loads the styles (sandpack style loader). In an environment like most people's (I assume), CSS styles probably won't be being actually added to the application, will they? So this problem does exist. I suppose one could write a different jest transform (or equivalent for other runners) which actually does inject styles like a real loader, although it would probably slow things down for little benefit (given that JSDom doesn't do layout). So #731 (and related global config) is probably worth it to allow working around this issue without it being as hacky-looking as |
|
I've just updated |
I'm seeing a potentially different issue, we're using |
I have encounter similar issue but when using Storybook v8.0.6 interaction testing. The await ctx.step('Clicking "Cancel" or "Continue" should close the dialog', async () => {
await userEvent.click(parent.getByRole('button', { name: cancel }))
await expect(alertDialog).toBeNull()
await userEvent.click(openButton)
await userEvent.click(parent.getByRole('button', { name: continuee }))
await expect(alertDialog).toBeNull()
}) It looks like import { PointerEventsCheckLevel } from '@testing-library/user-event'
await userEvent.click(openButton, { pointerEventsCheck: PointerEventsCheckLevel.EachTarget }) |
This works. |
## Summary Upgrades `@testing-library/user-event` to `^14.5.2`. See the release notes for `v14` for breaking changes: https://github.com/testing-library/user-event/releases/tag/v14.0.0 I was facing an [issue](testing-library/user-event#662) with `v13.5.0` with `userEvent.click()` in a PR (#189729) and was able to verify that `v14.4.3` onwards fixes it so I decided to update that package. What a rabbit hole 😅 ! - In `user-event` `v14` events return a promise, so this PR updates usage of the likes of `userEvent.click` with `await userEvent.click`. Regex to search for `userEvent` calls that miss `await` except `.setup`: `(?<!await\s)userEvent\.(?!setup\b)` - The way to handle pointer events needed changing from `, undefined, { skipPointerEventsCheck: true });` to `, { pointerEventsCheck: 0 });`. - I tried a bit to do the refactor with codemods, but there were quite some edge cases so it ended up being done manually. - I looked into all failing tests and tried my best to update them, but for some of them I lacked the context to make them work again. If you're a code owner and find a skipped test in this PR please give it a try to fix and push in this PR or let me know if it's fine for you to fix in follow ups. List of files where I had to skip tests (`git diff main...HEAD -G'\.skip' --name-only`): ### `packages/kbn-dom-drag-drop` - `packages/kbn-dom-drag-drop/src/droppable.test.tsx` ### `x-pack/plugins/cases` - `x-pack/plugins/cases/public/components/templates/form.test.tsx` - `x-pack/plugins/cases/public/components/user_actions/user_actions_list.test.tsx` ### `x-pack/plugins/cloud_security_posture` - `x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_form.test.tsx` ### `x-pack/plugins/lens` - `x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.test.tsx` ### `x-pack/plugins/observability_solution` - `x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/fields/request_body_field.test.tsx` ### `x-pack/plugins/security_solution` - `x-pack/plugins/security_solution/public/management/components/console/components/command_input/integration_tests/command_input.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/kill_process_action.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/release_action.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/status_action.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/upload_action.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_response_actions_list/integration_tests/response_actions_log.test.tsx` - `x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/event_filters_flyout.test.tsx` - `x-pack/plugins/security_solution/public/management/pages/response_actions/view/response_actions_list_page.test.tsx` ---- I plan to do a talk on Kibana Demo Days to walk through some of the breaking changes and learnings. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
@testing-library/user-event
version: 13.1.5What you did: Upgraded my project to the current version of @testing-library/user-event
What happened: 1 test started throwing an error
'unable to click element as it has or inherits pointer-events set to "none".
. Which is related to this commit 6b2ce66.'unable to click element as it has or inherits pointer-events set to "none".
Reproduction repository: https://github.com/jarretmoses/user-event-pointer-event-bug
Problem description: In the version of user-event 13.1.3 intentional errors started to be thrown for click events when they infact shouldn't The bug is occurring when a parent element has
pointer-events: none
set inline but then the child haspointer-events: auto
in a css file. In the actual browser this child element can in fact be clicked but the test is not correctly detecting the child elements computed styles.Suggested solution: On initial inspection I am honestly not sure. It seems the code at first glance should work as its using
getComputedStyles
but upon inspecting the output in this instance I do not see my css anywhere. This is a unique situation I've not encountered before and perhaps this is exposing an config setup on my end. I thought jest imported css files but maybe I am mistaken?The text was updated successfully, but these errors were encountered: