From: stanislavh Date: Tue, 20 Feb 2024 13:34:21 +0000 (+0100) Subject: SONAR-21692 Remove RTL warning from IssueHeader X-Git-Tag: 10.5.0.89998~193 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e1d1a4ec9ea16c679c8997c861df4979f479454c;p=sonarqube.git SONAR-21692 Remove RTL warning from IssueHeader --- diff --git a/server/sonar-web/config/jest/SetupReactTestingLibrary.ts b/server/sonar-web/config/jest/SetupReactTestingLibrary.ts index 1907cd07dc4..35347ca7ead 100644 --- a/server/sonar-web/config/jest/SetupReactTestingLibrary.ts +++ b/server/sonar-web/config/jest/SetupReactTestingLibrary.ts @@ -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; }, }); diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/IssueHeader-it.tsx b/server/sonar-web/src/main/js/apps/issues/__tests__/IssueHeader-it.tsx index 40e755bb385..ab1c1e628cf 100644 --- a/server/sonar-web/src/main/js/apps/issues/__tests__/IssueHeader-it.tsx +++ b/server/sonar-web/src/main/js/apps/issues/__tests__/IssueHeader-it.tsx @@ -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(); diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/PermissionTemplatesApp-it.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/PermissionTemplatesApp-it.tsx index fabf117fba8..cc3a6b172ee 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/PermissionTemplatesApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/PermissionTemplatesApp-it.tsx @@ -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', );