Skip to content

Commit

Permalink
Gracefully handle malformed index patterns on role management pages (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego authored May 13, 2021
1 parent c4529fa commit 5487657
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ function getProps({
rolesAPIClient.getRole.mockResolvedValue(role);

const indexPatterns = dataPluginMock.createStartContract().indexPatterns;
indexPatterns.getTitles = jest.fn().mockResolvedValue(['foo*', 'bar*']);
// `undefined` titles can technically happen via import/export or other manual manipulation
indexPatterns.getTitles = jest.fn().mockResolvedValue(['foo*', 'bar*', undefined]);

const indicesAPIClient = indicesAPIClientMock.create();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function useIndexPatternsTitles(
fatalErrors.add(err);
throw err;
})
.then(setIndexPatternsTitles);
.then((titles) => setIndexPatternsTitles(titles.filter(Boolean)));
}, [fatalErrors, indexPatterns, notifications]);

return indexPatternsTitles;
Expand Down

0 comments on commit 5487657

Please sign in to comment.