]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21692 Fix jest warnings related to ProjectDumpApp and IssuesApp
authorIsmail Cherri <ismail.cherri@sonarsource.com>
Thu, 22 Feb 2024 08:45:11 +0000 (09:45 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 22 Feb 2024 20:02:53 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx
server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx
server/sonar-web/src/main/js/components/rules/MoreInfoRuleDescription.tsx

index a4ad9efe448668e819117994f4bb914b9a316b3e..c29f06ff08810c47d9f7b16712409c1448b1551c 100644 (file)
@@ -170,7 +170,7 @@ export class ProjectDumpApp extends React.Component<Props, State> {
           <header className="sw-mb-5">
             <Helmet defer={false} title={translate('project_dump.page')} />
             <Title className="sw-mb-4">{translate('project_dump.page')}</Title>
-            <p>
+            <div>
               {projectImportFeatureEnabled ? (
                 <>
                   <p>{translate('project_dump.page.description1')}</p>
@@ -182,7 +182,7 @@ export class ProjectDumpApp extends React.Component<Props, State> {
                   <p>{translate('project_dump.page.description_without_import2')}</p>
                 </>
               )}
-            </p>
+            </div>
           </header>
 
           <Spinner loading={status === undefined}>
index d1e37fad5d4b18c71a6fe0c008667bee94cb19d1..ed0305a8f2e404df853434fc4e622a294ab38cc0 100644 (file)
@@ -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();
 });
index 6a1957ed89a7f3754a331a02c796be2de313d3e9..7fa2d76ab28ac0dfecca68d065f6ab9428d6f7c7 100644 (file)
@@ -41,7 +41,7 @@ const EDUCATION_PRINCIPLES_MAP: Dict<React.ComponentType<React.PropsWithChildren
   never_trust_user_input: NeverTrustUserInput,
 };
 
-export default class MoreInfoRuleDescription extends React.PureComponent<Props, {}> {
+export default class MoreInfoRuleDescription extends React.PureComponent<Props> {
   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;
   }
 `;