-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hasData
service fixes and improvements (#137824)
* fix has data * clean up remote cluster comment Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
241e469
commit e2b8525
Showing
11 changed files
with
242 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { hasUserDataView } from './has_user_data_view'; | ||
import { elasticsearchServiceMock, savedObjectsClientMock } from '@kbn/core/server/mocks'; | ||
|
||
describe('hasUserDataView', () => { | ||
const esClient = elasticsearchServiceMock.createScopedClusterClient().asCurrentUser; | ||
const soClient = savedObjectsClientMock.create(); | ||
|
||
beforeEach(() => jest.resetAllMocks()); | ||
|
||
it('returns false when there are no data views', async () => { | ||
soClient.find.mockResolvedValue({ | ||
page: 1, | ||
per_page: 100, | ||
total: 0, | ||
saved_objects: [], | ||
}); | ||
expect(await hasUserDataView({ esClient, soClient })).toEqual(false); | ||
}); | ||
|
||
it('returns true when there are data views', async () => { | ||
soClient.find.mockResolvedValue({ | ||
page: 1, | ||
per_page: 100, | ||
total: 1, | ||
saved_objects: [ | ||
{ | ||
id: '1', | ||
references: [], | ||
type: 'index-pattern', | ||
score: 99, | ||
attributes: { title: 'my-pattern-*' }, | ||
}, | ||
], | ||
}); | ||
expect(await hasUserDataView({ esClient, soClient })).toEqual(true); | ||
}); | ||
|
||
it('can shortcut using api internally', async () => { | ||
const dataViewsFindResponse = { | ||
page: 1, | ||
per_page: 100, | ||
total: 1, | ||
saved_objects: [ | ||
{ | ||
id: '1', | ||
references: [], | ||
type: 'index-pattern', | ||
score: 99, | ||
attributes: { title: 'my-pattern-*' }, | ||
}, | ||
], | ||
}; | ||
expect(await hasUserDataView({ esClient, soClient }, dataViewsFindResponse)).toEqual(true); | ||
expect(soClient.find).not.toBeCalled(); | ||
}); | ||
}); |
Oops, something went wrong.