"fix" provisioningwizard tests

This commit is contained in:
Ashley Harrison
2025-12-12 11:16:05 +00:00
parent 3808ddf948
commit 68a83b73c9
@@ -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();