Skip to content

Commit

Permalink
fix when issues are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
billyvg committed Jun 11, 2019
1 parent f31fd75 commit 6eb599d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const RelatedIssues = styled(
<div className={className}>
<IssuesFetcher api={api} issueIds={incident && incident.groups}>
{({issues, loading, error}) => {
// If loading is finished, and there are no issues, do not display anythig
if (!loading && issues && issues.length === 0) {
return null;
}

return (
<React.Fragment>
<SideHeader loading={loading}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ class IssuesFetcher extends React.PureComponent {

fetchData = async () => {
const {api, issueIds} = this.props;
this.setState({loading: true});

if (!issueIds) {
return;
}

this.setState({loading: true});

try {
const issues = await Promise.all(
issueIds.map(issueId => findIssueById(api, issueId))
Expand Down
20 changes: 20 additions & 0 deletions tests/js/spec/views/organizationIncidents/details/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,24 @@ describe('IncidentDetails', function() {
.text()
).toBe('JAVASCRIPT-6QS');
});

it('renders incident without issues', async function() {
MockApiClient.addMockResponse({
url: '/organizations/org-slug/incidents/123/',
body: {
...mockIncident,
groups: [],
},
});

const wrapper = createWrapper();

expect(wrapper.find('RelatedIssues Placeholder')).toHaveLength(1);

await tick();
wrapper.update();

expect(wrapper.find('RelatedItem')).toHaveLength(0);
expect(wrapper.find('RelatedIssues Placeholder')).toHaveLength(0);
});
});

0 comments on commit 6eb599d

Please sign in to comment.