}
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 });
}
},
<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>
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(),
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