Skip to content

Commit

Permalink
Avoid issues causing flaky tests with pointer events
Browse files Browse the repository at this point in the history
When clicking on multiselects sometimes user event complained about
`pointer-events` css property being `none`. Avoid this issue by not
checking for `pointer-event` at all.
  • Loading branch information
bjoernricks committed May 8, 2024
1 parent 0beabef commit f7400ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/web/components/testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import {PointerEventsCheckLevel} from '@testing-library/user-event';

import {isDefined} from 'gmp/utils/identity';

import {
Expand Down Expand Up @@ -72,7 +74,7 @@ export const getSelectElements = element => {
export const openSelectElement = async select => {
await act(async () => {
select = select || getSelectElement();
await userEvent.click(select);
await clickElement(select);
});
};

Expand All @@ -81,7 +83,9 @@ export const openSelectElement = async select => {
*/
export const clickElement = async element => {
await act(async () => {
await userEvent.click(element);
await userEvent.click(element, {
pointerEventsCheck: PointerEventsCheckLevel.Never,
});
});
};

Expand Down
6 changes: 4 additions & 2 deletions src/web/utils/testing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
queryAllByAttribute,
getElementError,
} from '@testing-library/react/pure';
import userEvent from '@testing-library/user-event';
import userEvent, {PointerEventsCheckLevel} from '@testing-library/user-event';

import {ThemeProvider, theme} from '@greenbone/opensight-ui-components';

Expand Down Expand Up @@ -108,7 +108,9 @@ export const render = ui => {
<Main>{ui}</Main>,
);
return {
userEvent: userEvent.setup(),
userEvent: userEvent.setup({
pointerEventsCheck: PointerEventsCheckLevel.Never,
}),
baseElement,
container,
element: hasValue(container) ? container.firstChild : undefined,
Expand Down

0 comments on commit f7400ff

Please sign in to comment.