]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13481 About page should not display issues statistics as long as issues indexat...
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Mon, 15 Jun 2020 13:45:17 +0000 (15:45 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 26 Jun 2020 20:04:58 +0000 (20:04 +0000)
server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx
server/sonar-web/src/main/js/apps/about/components/__tests__/AboutApp-test.tsx

index 64a1c738c071617720140706e955271e24c8095f..c8cac2354f35b0cef1d6daed0a97b38cd650cc94 100644 (file)
@@ -92,11 +92,15 @@ export class AboutApp extends React.PureComponent<Props, State> {
   }
 
   loadData() {
-    Promise.all([this.loadProjects(), this.loadIssues(), this.loadCustomText()]).then(
+    Promise.all([
+      this.loadProjects(),
+      this.loadIssues().catch(() => undefined),
+      this.loadCustomText()
+    ]).then(
       responses => {
         if (this.mounted) {
-          const [projectsCount, issues] = responses;
-          const issueTypes = keyBy(issues.facet, 'val');
+          const [projectsCount = 0, issues] = responses;
+          const issueTypes = issues && keyBy(issues.facet, 'val');
           this.setState({ projectsCount, issueTypes, loading: false });
         }
       },
@@ -141,12 +145,14 @@ export class AboutApp extends React.PureComponent<Props, State> {
 
             <div className="about-page-instance">
               <AboutProjects count={projectsCount} loading={loading} />
-              <EntryIssueTypes
-                bugs={bugs}
-                codeSmells={codeSmells}
-                loading={loading}
-                vulnerabilities={vulnerabilities}
-              />
+              {issueTypes && (
+                <EntryIssueTypes
+                  bugs={bugs}
+                  codeSmells={codeSmells}
+                  loading={loading}
+                  vulnerabilities={vulnerabilities}
+                />
+              )}
             </div>
           </div>
 
index 63a7f8d85fa7e95ed4523dd88df429be47e69781..a1393845948709a3499a4ff4a636b7cba7f26ca7 100644 (file)
@@ -25,6 +25,7 @@ import { searchProjects } from '../../../../api/components';
 import { getFacet } from '../../../../api/issues';
 import { mockAppState, mockCurrentUser, mockLocation } from '../../../../helpers/testMocks';
 import { AboutApp } from '../AboutApp';
+import EntryIssueTypes from '../EntryIssueTypes';
 
 jest.mock('sonar-ui-common/helpers/pages', () => ({
   addWhitePageClass: jest.fn(),
@@ -74,6 +75,16 @@ it('should load issues, projects, and custom text upon shallowing', () => {
   expect(getFacet).toBeCalled();
 });
 
+it('should not display issues if the WS return an http error', async () => {
+  (getFacet as jest.Mock).mockRejectedValueOnce(undefined);
+
+  const wrapper = shallowRender();
+
+  await waitAndUpdate(wrapper);
+
+  expect(wrapper.find(EntryIssueTypes).exists()).toBe(false);
+});
+
 function shallowRender(props: Partial<AboutApp['props']> = {}) {
   return shallow(
     <AboutApp