Skip to content

Commit

Permalink
[7.x] [Visualizations] Fix to usage collection when no results (#77478)…
Browse files Browse the repository at this point in the history
… (#77511)
  • Loading branch information
afharo authored Sep 15, 2020
1 parent f8f5d09 commit 4353979
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ describe('Visualizations usage collector', () => {
expect(usageCollector.fetch).toEqual(expect.any(Function));
});

test('Returns undefined when no results found (undefined)', async () => {
const result = await usageCollector.fetch(getMockCallCluster(undefined as any));
expect(result).toBe(undefined);
});

test('Returns undefined when no results found (0 results)', async () => {
const result = await usageCollector.fetch(getMockCallCluster([]));
expect(result).toBe(undefined);
});

test('Summarizes visualizations response data', async () => {
const result = await usageCollector.fetch(getMockCallCluster(defaultMockSavedObjects));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function getStats(callCluster: LegacyAPICaller, index: string) {
},
};
const esResponse: ESResponse = await callCluster('search', searchParams);
const size = get(esResponse, 'hits.hits.length');
const size = get(esResponse, 'hits.hits.length', 0);
if (size < 1) {
return;
}
Expand Down

0 comments on commit 4353979

Please sign in to comment.