From 5d0acc25ee67fd9e8a41299bb602c95acf94fad1 Mon Sep 17 00:00:00 2001 From: Ismail Cherri Date: Thu, 22 Feb 2024 09:45:11 +0100 Subject: SONAR-21692 Fix jest warnings related to ProjectDumpApp and IssuesApp --- .../src/main/js/apps/projectDump/ProjectDumpApp.tsx | 4 ++-- .../apps/projectDump/__tests__/ProjectDumpApp-it.tsx | 19 ++++++++++++++----- .../js/components/rules/MoreInfoRuleDescription.tsx | 6 +++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx b/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx index a4ad9efe448..c29f06ff088 100644 --- a/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx @@ -170,7 +170,7 @@ export class ProjectDumpApp extends React.Component {
{translate('project_dump.page')} -

+

{projectImportFeatureEnabled ? ( <>

{translate('project_dump.page.description1')}

@@ -182,7 +182,7 @@ export class ProjectDumpApp extends React.Component {

{translate('project_dump.page.description_without_import2')}

)} -

+
diff --git a/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx b/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx index d1e37fad5d4..ed0305a8f2e 100644 --- a/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx @@ -17,7 +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 { screen } from '@testing-library/react'; +import { act, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import ComputeEngineServiceMock from '../../../api/mocks/ComputeEngineServiceMock'; import { ProjectDumpServiceMock } from '../../../api/mocks/ProjectDumpServiceMock'; @@ -103,6 +103,7 @@ it('should show pending->in progress->failed export', async () => { status: TaskStatuses.Pending, submittedAt: '2023-06-08T11:55:00Z', }); + await userEvent.click(await ui.exportBtn.find()); expect(await ui.pendingExport.find()).toBeInTheDocument(); expect(ui.exportBtn.query()).not.toBeInTheDocument(); @@ -113,7 +114,9 @@ it('should show pending->in progress->failed export', async () => { status: TaskStatuses.InProgress, startedAt: '2023-06-08T12:00:00Z', }); - jest.runOnlyPendingTimers(); + act(() => { + jest.runOnlyPendingTimers(); + }); expect(await ui.inProgressExport.find()).toBeInTheDocument(); expect(ui.exportBtn.query()).not.toBeInTheDocument(); @@ -123,7 +126,9 @@ it('should show pending->in progress->failed export', async () => { status: TaskStatuses.Failed, executedAt: '2023-06-08T12:05:00Z', }); - jest.runOnlyPendingTimers(); + act(() => { + jest.runOnlyPendingTimers(); + }); expect(await ui.failedExport.find()).toBeInTheDocument(); expect(ui.exportBtn.get()).toBeInTheDocument(); }); @@ -159,7 +164,9 @@ it('should show pending->in progress->failed import', async () => { status: TaskStatuses.InProgress, startedAt: '2023-06-08T12:00:00Z', }); - jest.runOnlyPendingTimers(); + act(() => { + jest.runOnlyPendingTimers(); + }); expect(await ui.inProgressImport.find()).toBeInTheDocument(); expect(ui.importBtn.query()).not.toBeInTheDocument(); @@ -169,7 +176,9 @@ it('should show pending->in progress->failed import', async () => { status: TaskStatuses.Failed, executedAt: '2023-06-08T12:05:00Z', }); - jest.runOnlyPendingTimers(); + act(() => { + jest.runOnlyPendingTimers(); + }); expect(await ui.failedImport.find()).toBeInTheDocument(); expect(ui.importBtn.get()).toBeInTheDocument(); }); diff --git a/server/sonar-web/src/main/js/components/rules/MoreInfoRuleDescription.tsx b/server/sonar-web/src/main/js/components/rules/MoreInfoRuleDescription.tsx index 6a1957ed89a..7fa2d76ab28 100644 --- a/server/sonar-web/src/main/js/components/rules/MoreInfoRuleDescription.tsx +++ b/server/sonar-web/src/main/js/components/rules/MoreInfoRuleDescription.tsx @@ -41,7 +41,7 @@ const EDUCATION_PRINCIPLES_MAP: Dict { +export default class MoreInfoRuleDescription extends React.PureComponent { handleNotificationScroll = () => { const element = this.props.educationPrinciplesRef?.current; @@ -114,7 +114,7 @@ const StyledEducationPrinciples = styled.div` background-color: ${themeColor('educationPrincipleBackground')}; border: ${themeBorder('default', 'educationPrincipleBorder')}; - & h3:first-child { - margin-top: 0px; + & h3:first-of-type { + margin-top: 0; } `; -- cgit v1.2.3