Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Liza Katz 2020-04-28 15:03:04 +03:00 committed by GitHub
parent e7971fa08e
commit c2e464325e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -96,6 +96,34 @@ describe('Async search strategy', () => {
});
});
// For bug fixed in https://github.com/elastic/kibana/pull/64155
it('Continues polling if no records are returned on first async request', async () => {
mockSearch
.mockReturnValueOnce(of({ id: 1, total: 0, loaded: 0, is_running: true, is_partial: true }))
.mockReturnValueOnce(
of({ id: 1, total: 2, loaded: 2, is_running: false, is_partial: false })
);
const asyncSearch = asyncSearchStrategyProvider({
core: mockCoreStart,
getSearchStrategy: jest.fn().mockImplementation(() => {
return () => {
return {
search: mockSearch,
};
};
}),
});
expect(mockSearch).toBeCalledTimes(0);
await asyncSearch.search(mockRequest, mockOptions).toPromise();
expect(mockSearch).toBeCalledTimes(2);
expect(mockSearch.mock.calls[0][0]).toEqual(mockRequest);
expect(mockSearch.mock.calls[1][0]).toEqual({ id: 1, serverStrategy: 'foo' });
});
it('only sends the ID and server strategy after the first request', async () => {
mockSearch
.mockReturnValueOnce(of({ id: 1, total: 2, loaded: 1, is_running: true, is_partial: true }))