]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21692 Remove warnings from indexation components
authorstanislavh <stanislav.honcharov@sonarsource.com>
Thu, 22 Feb 2024 11:03:03 +0000 (12:03 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 23 Feb 2024 20:02:36 +0000 (20:02 +0000)
server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationContextProvider-test.tsx
server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotification-test.tsx

index 704d0d4375b7ca2056ed317d7fef735b132aab0e..c78d6ffddc1e4827bbbb905078f570515aa75f9f 100644 (file)
@@ -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) {
index d387a7e35546e990f6437c341e233b504d897d4a..ce3683330c1b5ee3a9e3009f91df62eadd11ea77 100644 (file)
@@ -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();