From: Philippe Perrin Date: Mon, 15 Jun 2020 13:45:17 +0000 (+0200) Subject: SONAR-13481 About page should not display issues statistics as long as issues indexat... X-Git-Tag: 8.4.0.35506~44 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f37bcda548c9ddf5f137d89ed9685516da5a27cf;p=sonarqube.git SONAR-13481 About page should not display issues statistics as long as issues indexation is in progress --- diff --git a/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx b/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx index 64a1c738c07..c8cac2354f3 100644 --- a/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx +++ b/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx @@ -92,11 +92,15 @@ export class AboutApp extends React.PureComponent { } 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 {
- + {issueTypes && ( + + )}
diff --git a/server/sonar-web/src/main/js/apps/about/components/__tests__/AboutApp-test.tsx b/server/sonar-web/src/main/js/apps/about/components/__tests__/AboutApp-test.tsx index 63a7f8d85fa..a1393845948 100644 --- a/server/sonar-web/src/main/js/apps/about/components/__tests__/AboutApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/about/components/__tests__/AboutApp-test.tsx @@ -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 = {}) { return shallow(