From f7400ffad63dc698bd3bc1c4fd40a6ad224c0593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Wed, 8 May 2024 11:21:34 +0200 Subject: [PATCH] Avoid issues causing flaky tests with pointer events 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. --- src/web/components/testing.js | 8 ++++++-- src/web/utils/testing.jsx | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/web/components/testing.js b/src/web/components/testing.js index 7c4329af25..d3827c411a 100644 --- a/src/web/components/testing.js +++ b/src/web/components/testing.js @@ -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 { @@ -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); }); }; @@ -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, + }); }); }; diff --git a/src/web/utils/testing.jsx b/src/web/utils/testing.jsx index abd7066e1e..8b56567d54 100644 --- a/src/web/utils/testing.jsx +++ b/src/web/utils/testing.jsx @@ -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'; @@ -108,7 +108,9 @@ export const render = ui => {
{ui}
, ); return { - userEvent: userEvent.setup(), + userEvent: userEvent.setup({ + pointerEventsCheck: PointerEventsCheckLevel.Never, + }), baseElement, container, element: hasValue(container) ? container.firstChild : undefined,