aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/design-system/src/components
diff options
context:
space:
mode:
authorstanislavh <stanislav.honcharov@sonarsource.com>2024-02-21 09:19:48 +0100
committersonartech <sonartech@sonarsource.com>2024-02-21 20:02:34 +0000
commitb9fdc3abf600f2ef02c0f4b5321fb7aae0140ac6 (patch)
treef69c67e68290c37dc8ceee76b1f1f0bbfd426bde /server/sonar-web/design-system/src/components
parent607fc18c8d07c8bf29392124241597c90db6af42 (diff)
downloadsonarqube-b9fdc3abf600f2ef02c0f4b5321fb7aae0140ac6.tar.gz
sonarqube-b9fdc3abf600f2ef02c0f4b5321fb7aae0140ac6.zip
SONAR-21692 Remove act warnings from Toggler, IssuesSidebar, IssuesAppGuides, MultiSelectMenu, DropdownMenu
Diffstat (limited to 'server/sonar-web/design-system/src/components')
-rw-r--r--server/sonar-web/design-system/src/components/__tests__/DropdownMenu-test.tsx32
-rw-r--r--server/sonar-web/design-system/src/components/input/__tests__/MultiSelectMenu-test.tsx14
2 files changed, 5 insertions, 41 deletions
diff --git a/server/sonar-web/design-system/src/components/__tests__/DropdownMenu-test.tsx b/server/sonar-web/design-system/src/components/__tests__/DropdownMenu-test.tsx
index cc495447c0d..087a89bcdb3 100644
--- a/server/sonar-web/design-system/src/components/__tests__/DropdownMenu-test.tsx
+++ b/server/sonar-web/design-system/src/components/__tests__/DropdownMenu-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { act, screen, waitFor } from '@testing-library/react';
+import { screen } from '@testing-library/react';
import { noop } from 'lodash';
import { render, renderWithRouter } from '../../helpers/testUtils';
import {
@@ -35,15 +35,6 @@ import {
import { Tooltip } from '../Tooltip';
import { MenuIcon } from '../icons/MenuIcon';
-beforeEach(() => {
- jest.useFakeTimers();
-});
-
-afterEach(() => {
- jest.runOnlyPendingTimers();
- jest.useRealTimers();
-});
-
it('should render a full menu correctly', () => {
renderDropdownMenu();
expect(screen.getByRole('menuitem', { name: 'My header' })).toBeInTheDocument();
@@ -52,7 +43,7 @@ it('should render a full menu correctly', () => {
});
it('menu items should work with tooltips', async () => {
- const { user } = render(
+ render(
<Tooltip overlay="test tooltip">
<ItemButton onClick={jest.fn()}>button</ItemButton>
</Tooltip>,
@@ -61,24 +52,7 @@ it('menu items should work with tooltips', async () => {
);
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
-
- await user.hover(screen.getByRole('menuitem'));
- expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
-
- act(() => {
- jest.runAllTimers();
- });
- expect(screen.getByRole('tooltip')).toBeVisible();
-
- await user.unhover(screen.getByRole('menuitem'));
- expect(screen.getByRole('tooltip')).toBeVisible();
-
- act(() => {
- jest.runAllTimers();
- });
- await waitFor(() => {
- expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
- });
+ await expect(screen.getByRole('menuitem')).toHaveATooltipWithContent('test tooltip');
});
function renderDropdownMenu() {
diff --git a/server/sonar-web/design-system/src/components/input/__tests__/MultiSelectMenu-test.tsx b/server/sonar-web/design-system/src/components/input/__tests__/MultiSelectMenu-test.tsx
index c08df73c4b0..582ba68bf18 100644
--- a/server/sonar-web/design-system/src/components/input/__tests__/MultiSelectMenu-test.tsx
+++ b/server/sonar-web/design-system/src/components/input/__tests__/MultiSelectMenu-test.tsx
@@ -24,15 +24,6 @@ import { MultiSelectMenu } from '../MultiSelectMenu';
const elements = ['foo', 'bar', 'baz'];
-beforeEach(() => {
- jest.useFakeTimers();
-});
-
-afterEach(() => {
- jest.runOnlyPendingTimers();
- jest.useRealTimers();
-});
-
it('should allow selecting and deselecting a new option', async () => {
const user = userEvent.setup({ delay: null });
const onSelect = jest.fn();
@@ -40,7 +31,6 @@ it('should allow selecting and deselecting a new option', async () => {
renderMultiselect({ elements, onSelect, onUnselect, allowNewElements: true });
await user.keyboard('new option');
- jest.runAllTimers(); // skip the debounce
expect(await screen.findByText('new option')).toBeInTheDocument();
@@ -89,9 +79,9 @@ it('should ignore the left and right arrow keys', async () => {
expect(onSelect).toHaveBeenCalledWith('baz');
});
-it('should show no results', () => {
+it('should show no results', async () => {
renderMultiselect();
- expect(screen.getByText('no results')).toBeInTheDocument();
+ expect(await screen.findByText('no results')).toBeInTheDocument();
});
function renderMultiselect(props: Partial<MultiSelectMenu['props']> = {}) {