From 68a83b73c9357243dbb44267e83342f7174181ea Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 12 Dec 2025 11:16:05 +0000 Subject: [PATCH] "fix" provisioningwizard tests --- .../Wizard/ProvisioningWizard.test.tsx | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/public/app/features/provisioning/Wizard/ProvisioningWizard.test.tsx b/public/app/features/provisioning/Wizard/ProvisioningWizard.test.tsx index 922d8609673..583b5a1ec88 100644 --- a/public/app/features/provisioning/Wizard/ProvisioningWizard.test.tsx +++ b/public/app/features/provisioning/Wizard/ProvisioningWizard.test.tsx @@ -1,7 +1,7 @@ import { QueryStatus } from '@reduxjs/toolkit/query'; -import { screen, waitFor } from '@testing-library/react'; +import { fireEvent, screen, waitFor } from '@testing-library/react'; import { UserEvent } from '@testing-library/user-event'; -import type { JSX } from 'react'; +import { act, type JSX } from 'react'; import { render } from 'test/test-utils'; import { @@ -237,7 +237,9 @@ describe('ProvisioningWizard', () => { path: '/', }); - await user.click(screen.getByRole('button', { name: /Choose what to synchronize/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => fireEvent.click(screen.getByRole('button', { name: /Choose what to synchronize/i }))); await waitFor(() => { expect(screen.getByRole('heading', { name: /2\. Choose what to synchronize/i })).toBeInTheDocument(); @@ -245,7 +247,9 @@ describe('ProvisioningWizard', () => { expect(mockUseCreateOrUpdateRepository).toHaveBeenCalled(); - await user.click(screen.getByRole('button', { name: /Synchronize with external storage/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => fireEvent.click(screen.getByRole('button', { name: /Synchronize with external storage/i }))); await waitFor(() => { expect(screen.getByRole('heading', { name: /3\. Synchronize with external storage/i })).toBeInTheDocument(); @@ -281,7 +285,9 @@ describe('ProvisioningWizard', () => { path: '/', }); - await user.click(screen.getByRole('button', { name: /Choose what to synchronize/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => fireEvent.click(screen.getByRole('button', { name: /Choose what to synchronize/i }))); await waitFor(() => { expect(screen.getByRole('heading', { name: /2\. Choose what to synchronize/i })).toBeInTheDocument(); @@ -339,7 +345,9 @@ describe('ProvisioningWizard', () => { path: '/', }); - await user.click(screen.getByRole('button', { name: /Choose what to synchronize/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => fireEvent.click(screen.getByRole('button', { name: /Choose what to synchronize/i }))); await waitFor(() => { expect(screen.getByText('Branch "invalid-branch" not found')).toBeInTheDocument(); @@ -373,7 +381,9 @@ describe('ProvisioningWizard', () => { path: '/', }); - await user.click(screen.getByRole('button', { name: /Choose what to synchronize/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => fireEvent.click(screen.getByRole('button', { name: /Choose what to synchronize/i }))); await waitFor(() => { expect(screen.getByRole('alert')).toBeInTheDocument(); @@ -414,7 +424,9 @@ describe('ProvisioningWizard', () => { path: '/', }); - await user.click(screen.getByRole('button', { name: /Choose what to synchronize/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => fireEvent.click(screen.getByRole('button', { name: /Choose what to synchronize/i }))); await waitFor(() => { expect(screen.getByRole('alert')).toBeInTheDocument(); @@ -442,13 +454,17 @@ describe('ProvisioningWizard', () => { path: '/', }); - await user.click(screen.getByRole('button', { name: /Choose what to synchronize/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => fireEvent.click(screen.getByRole('button', { name: /Choose what to synchronize/i }))); await waitFor(() => { expect(screen.getByRole('heading', { name: /2\. Choose what to synchronize/i })).toBeInTheDocument(); }); - await user.click(screen.getByRole('button', { name: /Previous/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => fireEvent.click(screen.getByRole('button', { name: /Previous/i }))); await waitFor(() => { expect(screen.getByRole('heading', { name: /1\. Connect to external storage/i })).toBeInTheDocument(); @@ -485,7 +501,9 @@ describe('ProvisioningWizard', () => { path: '/', }); - await user.click(screen.getByRole('button', { name: /Choose what to synchronize/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => fireEvent.click(screen.getByRole('button', { name: /Choose what to synchronize/i }))); expect(screen.getByRole('button', { name: /Submitting.../i })).toBeDisabled(); }); @@ -522,7 +540,9 @@ describe('ProvisioningWizard', () => { path: '/', }); - await user.click(screen.getByRole('button', { name: /Choose what to synchronize/i })); + // TODO investigate why we need act/fireEvent + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(async () => fireEvent.click(screen.getByRole('button', { name: /Choose what to synchronize/i }))); await waitFor(() => { expect(screen.getByRole('button', { name: /Synchronize with external storage/i })).toBeInTheDocument();