From bf71383a30f8c44e3b2e703c08f76431b1eace1e Mon Sep 17 00:00:00 2001 From: stanislavh Date: Thu, 22 Feb 2024 12:03:03 +0100 Subject: [PATCH] SONAR-21692 Remove warnings from indexation components --- .../__tests__/IndexationContextProvider-test.tsx | 10 +++++----- .../__tests__/IndexationNotification-test.tsx | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationContextProvider-test.tsx b/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationContextProvider-test.tsx index 704d0d4375b..c78d6ffddc1 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationContextProvider-test.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationContextProvider-test.tsx @@ -17,6 +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 { waitFor } from '@testing-library/react'; import * as React from 'react'; import { useContext } from 'react'; import { mockAppState } from '../../../../helpers/testMocks'; @@ -60,11 +61,10 @@ it('should update the state on new status', async () => { expect(byText('null').get()).toBeInTheDocument(); - triggerNewStatus(newStatus); - - expect( - await byText('{"status":{"hasFailures":false,"isCompleted":true}}').find(), - ).toBeInTheDocument(); + await waitFor(() => { + triggerNewStatus(newStatus); + }); + expect(byText('{"status":{"hasFailures":false,"isCompleted":true}}').get()).toBeInTheDocument(); }); function renderIndexationContextProvider(props?: IndexationContextProviderProps) { diff --git a/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotification-test.tsx b/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotification-test.tsx index d387a7e3554..ce3683330c1 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotification-test.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotification-test.tsx @@ -17,6 +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 } from '@testing-library/react'; import * as React from 'react'; import { mockCurrentUser, mockLoggedInUser } from '../../../../helpers/testMocks'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; @@ -78,7 +79,7 @@ describe('Completed banner', () => { expect(IndexationNotificationHelper.markCompletedNotificationAsDisplayed).toHaveBeenCalled(); - jest.runAllTimers(); + act(() => jest.runOnlyPendingTimers()); expect(IndexationNotificationHelper.markCompletedNotificationAsDisplayed).toHaveBeenCalled(); -- 2.39.5