-
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.
Merge branch 'main' of github.com:elastic/kibana into api-alert-time-…
…range
- Loading branch information
Showing
30 changed files
with
513 additions
and
91 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
33 changes: 33 additions & 0 deletions
33
...analytics/api/check_analytics_events_index/check_analytics_events_index_api_logic.test.ts
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,33 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { mockHttpValues } from '../../../__mocks__/kea_logic'; | ||
|
||
import { nextTick } from '@kbn/test-jest-helpers'; | ||
|
||
import { checkAnalyticsEventsIndexExists } from './check_analytics_events_index_api_logic'; | ||
|
||
describe('FetchAnalyticsCollectionApiLogic', () => { | ||
const { http } = mockHttpValues; | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('FetchAnalyticsCollectionsApiLogic', () => { | ||
it('calls the analytics collections exists api', async () => { | ||
const promise = Promise.resolve({ exists: true }); | ||
const indexName = 'eventsIndex'; | ||
http.get.mockReturnValue(promise); | ||
const result = checkAnalyticsEventsIndexExists({ indexName }); | ||
await nextTick(); | ||
expect(http.get).toHaveBeenCalledWith( | ||
`/internal/enterprise_search/analytics/events/${indexName}/exists` | ||
); | ||
await expect(result).resolves.toEqual({ exists: true }); | ||
}); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
...ions/analytics/api/check_analytics_events_index/check_analytics_events_index_api_logic.ts
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,31 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { AnalyticsEventsIndexExists } from '../../../../../common/types/analytics'; | ||
import { createApiLogic } from '../../../shared/api_logic/create_api_logic'; | ||
import { HttpLogic } from '../../../shared/http'; | ||
|
||
export interface AnalyticsEventsIndexExistsApiLogicArgs { | ||
indexName: string; | ||
} | ||
|
||
export type AnalyticsEventsIndexExistsApiLogicResponse = AnalyticsEventsIndexExists; | ||
|
||
export const checkAnalyticsEventsIndexExists = async ({ | ||
indexName, | ||
}: AnalyticsEventsIndexExistsApiLogicArgs): Promise<AnalyticsEventsIndexExistsApiLogicResponse> => { | ||
const { http } = HttpLogic.values; | ||
const route = `/internal/enterprise_search/analytics/events/${indexName}/exists`; | ||
const response = await http.get<AnalyticsEventsIndexExists>(route); | ||
|
||
return response; | ||
}; | ||
|
||
export const AnalyticsEventsIndexExistsAPILogic = createApiLogic( | ||
['analytics', 'analytics_events_index_exists_api_logic'], | ||
checkAnalyticsEventsIndexExists | ||
); |
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
48 changes: 48 additions & 0 deletions
48
...nalytics/components/analytics_collection_view/analytics_events_index_exists_logic.test.ts
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,48 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { LogicMounter } from '../../../__mocks__/kea_logic'; | ||
|
||
import { Status } from '../../../../../common/types/api'; | ||
|
||
import { AnalyticsEventsIndexExistsLogic } from './analytics_events_index_exists_logic'; | ||
|
||
describe('analyticsEventsIndexExistsLogic', () => { | ||
const { mount } = new LogicMounter(AnalyticsEventsIndexExistsLogic); | ||
const indexName = true; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
jest.useRealTimers(); | ||
mount(); | ||
}); | ||
|
||
const DEFAULT_VALUES = { | ||
data: undefined, | ||
isLoading: true, | ||
isPresent: false, | ||
status: Status.IDLE, | ||
}; | ||
|
||
it('has expected default values', () => { | ||
expect(AnalyticsEventsIndexExistsLogic.values).toEqual(DEFAULT_VALUES); | ||
}); | ||
|
||
describe('selectors', () => { | ||
it('updates when apiSuccess listener triggered', () => { | ||
AnalyticsEventsIndexExistsLogic.actions.apiSuccess({ exists: indexName }); | ||
|
||
expect(AnalyticsEventsIndexExistsLogic.values).toEqual({ | ||
...DEFAULT_VALUES, | ||
isLoading: false, | ||
isPresent: true, | ||
status: Status.SUCCESS, | ||
data: { exists: indexName }, | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.