]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21692 Remove RTL warning from IssueHeader
authorstanislavh <stanislav.honcharov@sonarsource.com>
Tue, 20 Feb 2024 13:34:21 +0000 (14:34 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 20 Feb 2024 20:02:38 +0000 (20:02 +0000)
server/sonar-web/config/jest/SetupReactTestingLibrary.ts
server/sonar-web/src/main/js/apps/issues/__tests__/IssueHeader-it.tsx
server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/PermissionTemplatesApp-it.tsx

index 1907cd07dc4da9762ae34af82fab116287ca070c..35347ca7ead57b2502a926958908b94b28533630 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import '@testing-library/jest-dom';
-import { configure, fireEvent, screen } from '@testing-library/react';
+import { configure, fireEvent, screen, waitFor } from '@testing-library/react';
 
 configure({
   asyncUtilTimeout: 3000,
@@ -49,6 +49,10 @@ expect.extend({
 
     fireEvent.pointerLeave(received);
 
+    await waitFor(() => {
+      expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
+    });
+
     return result;
   },
 });
index 40e755bb3856aad7af693a3825237dd3520f33bc..ab1c1e628cf695b0fb1f82a0e3669deb985b4187 100644 (file)
@@ -25,8 +25,6 @@ import { byRole, byText } from '../../../helpers/testSelector';
 import { Dict } from '../../../types/types';
 import IssueHeader from '../components/IssueHeader';
 
-jest.useFakeTimers();
-
 it('renders correctly', async () => {
   const issue = mockIssue();
   renderIssueHeader(
@@ -57,19 +55,16 @@ it('renders correctly', async () => {
   await expect(cctBadge).toHaveATooltipWithContent(
     `issue.clean_code_attribute.${issue.cleanCodeAttribute}`,
   );
-  jest.runOnlyPendingTimers();
 
   // Software Qualities
   const qualityBadge = byText(`software_quality.${issue.impacts[0].softwareQuality}`).get();
   expect(qualityBadge).toBeInTheDocument();
   await expect(qualityBadge).toHaveATooltipWithContent('software_quality');
-  jest.runOnlyPendingTimers();
 
   // Deprecated type
   const type = byText(`issue.type.${issue.type}`).get();
   expect(type).toBeInTheDocument();
   await expect(type).toHaveATooltipWithContent('issue.clean_code_attribute');
-  jest.runOnlyPendingTimers();
 
   // Deprecated severity
   const severity = byText(`severity.${issue.severity}`).get();
index fabf117fba810c0519b257b21d67c76b4a54be77..cc3a6b172ee569cedfcd2169d0bb6e192e3d5043 100644 (file)
@@ -54,10 +54,10 @@ describe('rendering', () => {
     expect(ui.templateLink('Permission Template 2').get()).toBeInTheDocument();
 
     // Shows warning for browse and code viewer permissions.
-    await expect(ui.getHeaderTooltipIconByIndex(1)).toHaveATooltipWithContent(
+    await expect(ui.getHeaderTooltipIconByIndex(0)).toHaveATooltipWithContent(
       'projects_role.public_projects_warning',
     );
-    await expect(ui.getHeaderTooltipIconByIndex(2)).toHaveATooltipWithContent(
+    await expect(ui.getHeaderTooltipIconByIndex(1)).toHaveATooltipWithContent(
       'projects_role.public_projects_warning',
     );