-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:yctercero/kibana into exceptions-…
…viewer-followup
- Loading branch information
Showing
71 changed files
with
3,437 additions
and
333 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
51 changes: 51 additions & 0 deletions
51
x-pack/plugins/index_management/__jest__/client_integration/helpers/test_subjects.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,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export type TestSubjects = | ||
| 'aliasesTab' | ||
| 'appTitle' | ||
| 'cell' | ||
| 'closeDetailsButton' | ||
| 'createLegacyTemplateButton' | ||
| 'createTemplateButton' | ||
| 'dataStreamsEmptyPromptTemplateLink' | ||
| 'dataStreamTable' | ||
| 'dataStreamTable' | ||
| 'deleteSystemTemplateCallOut' | ||
| 'deleteTemplateButton' | ||
| 'deleteTemplatesConfirmation' | ||
| 'documentationLink' | ||
| 'emptyPrompt' | ||
| 'filterList.filterItem' | ||
| 'indexTable' | ||
| 'indexTableIncludeHiddenIndicesToggle' | ||
| 'indexTableIndexNameLink' | ||
| 'indicesList' | ||
| 'indicesTab' | ||
| 'legacyTemplateTable' | ||
| 'manageTemplateButton' | ||
| 'mappingsTab' | ||
| 'noAliasesCallout' | ||
| 'noMappingsCallout' | ||
| 'noSettingsCallout' | ||
| 'reloadButton' | ||
| 'reloadIndicesButton' | ||
| 'row' | ||
| 'sectionError' | ||
| 'sectionLoading' | ||
| 'settingsTab' | ||
| 'summaryTab' | ||
| 'summaryTitle' | ||
| 'systemTemplatesSwitch' | ||
| 'templateDetails' | ||
| 'templateDetails.manageTemplateButton' | ||
| 'templateDetails.sectionLoading' | ||
| 'templateDetails.tab' | ||
| 'templateDetails.title' | ||
| 'templateList' | ||
| 'templatesTab' | ||
| 'templateTable' | ||
| 'viewButton'; |
101 changes: 101 additions & 0 deletions
101
x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.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,101 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { act } from 'react-dom/test-utils'; | ||
|
||
import { | ||
registerTestBed, | ||
TestBed, | ||
TestBedConfig, | ||
findTestSubject, | ||
} from '../../../../../test_utils'; | ||
import { DataStream } from '../../../common'; | ||
import { IndexManagementHome } from '../../../public/application/sections/home'; // eslint-disable-line @kbn/eslint/no-restricted-paths | ||
import { indexManagementStore } from '../../../public/application/store'; // eslint-disable-line @kbn/eslint/no-restricted-paths | ||
import { WithAppDependencies, services, TestSubjects } from '../helpers'; | ||
|
||
const testBedConfig: TestBedConfig = { | ||
store: () => indexManagementStore(services as any), | ||
memoryRouter: { | ||
initialEntries: [`/indices`], | ||
componentRoutePath: `/:section(indices|data_streams|templates)`, | ||
}, | ||
doMountAsync: true, | ||
}; | ||
|
||
const initTestBed = registerTestBed(WithAppDependencies(IndexManagementHome), testBedConfig); | ||
|
||
export interface DataStreamsTabTestBed extends TestBed<TestSubjects> { | ||
actions: { | ||
goToDataStreamsList: () => void; | ||
clickEmptyPromptIndexTemplateLink: () => void; | ||
clickReloadButton: () => void; | ||
clickIndicesAt: (index: number) => void; | ||
}; | ||
} | ||
|
||
export const setup = async (): Promise<DataStreamsTabTestBed> => { | ||
const testBed = await initTestBed(); | ||
|
||
/** | ||
* User Actions | ||
*/ | ||
|
||
const goToDataStreamsList = () => { | ||
testBed.find('data_streamsTab').simulate('click'); | ||
}; | ||
|
||
const clickEmptyPromptIndexTemplateLink = async () => { | ||
const { find, component, router } = testBed; | ||
|
||
const templateLink = find('dataStreamsEmptyPromptTemplateLink'); | ||
|
||
await act(async () => { | ||
router.navigateTo(templateLink.props().href!); | ||
}); | ||
|
||
component.update(); | ||
}; | ||
|
||
const clickReloadButton = () => { | ||
const { find } = testBed; | ||
find('reloadButton').simulate('click'); | ||
}; | ||
|
||
const clickIndicesAt = async (index: number) => { | ||
const { component, table, router } = testBed; | ||
const { rows } = table.getMetaData('dataStreamTable'); | ||
const indicesLink = findTestSubject(rows[index].reactWrapper, 'indicesLink'); | ||
|
||
await act(async () => { | ||
router.navigateTo(indicesLink.props().href!); | ||
}); | ||
|
||
component.update(); | ||
}; | ||
|
||
return { | ||
...testBed, | ||
actions: { | ||
goToDataStreamsList, | ||
clickEmptyPromptIndexTemplateLink, | ||
clickReloadButton, | ||
clickIndicesAt, | ||
}, | ||
}; | ||
}; | ||
|
||
export const createDataStreamPayload = (name: string): DataStream => ({ | ||
name, | ||
timeStampField: '@timestamp', | ||
indices: [ | ||
{ | ||
name: 'indexName', | ||
uuid: 'indexId', | ||
}, | ||
], | ||
generation: 1, | ||
}); |
137 changes: 137 additions & 0 deletions
137
x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.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,137 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { act } from 'react-dom/test-utils'; | ||
|
||
import { API_BASE_PATH } from '../../../common/constants'; | ||
import { setupEnvironment } from '../helpers'; | ||
|
||
import { DataStreamsTabTestBed, setup, createDataStreamPayload } from './data_streams_tab.helpers'; | ||
|
||
describe('Data Streams tab', () => { | ||
const { server, httpRequestsMockHelpers } = setupEnvironment(); | ||
let testBed: DataStreamsTabTestBed; | ||
|
||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setLoadIndicesResponse([ | ||
{ | ||
health: '', | ||
status: '', | ||
primary: '', | ||
replica: '', | ||
documents: '', | ||
documents_deleted: '', | ||
size: '', | ||
primary_size: '', | ||
name: 'data-stream-index', | ||
data_stream: 'dataStream1', | ||
}, | ||
{ | ||
health: 'green', | ||
status: 'open', | ||
primary: 1, | ||
replica: 1, | ||
documents: 10000, | ||
documents_deleted: 100, | ||
size: '156kb', | ||
primary_size: '156kb', | ||
name: 'non-data-stream-index', | ||
}, | ||
]); | ||
|
||
await act(async () => { | ||
testBed = await setup(); | ||
}); | ||
}); | ||
|
||
describe('when there are no data streams', () => { | ||
beforeEach(async () => { | ||
const { actions, component } = testBed; | ||
|
||
httpRequestsMockHelpers.setLoadDataStreamsResponse([]); | ||
httpRequestsMockHelpers.setLoadTemplatesResponse({ templates: [], legacyTemplates: [] }); | ||
|
||
await act(async () => { | ||
actions.goToDataStreamsList(); | ||
}); | ||
|
||
component.update(); | ||
}); | ||
|
||
test('displays an empty prompt', async () => { | ||
const { exists } = testBed; | ||
|
||
expect(exists('sectionLoading')).toBe(false); | ||
expect(exists('emptyPrompt')).toBe(true); | ||
}); | ||
|
||
test('goes to index templates tab when "Get started" link is clicked', async () => { | ||
const { actions, exists } = testBed; | ||
|
||
await act(async () => { | ||
actions.clickEmptyPromptIndexTemplateLink(); | ||
}); | ||
|
||
expect(exists('templateList')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('when there are data streams', () => { | ||
beforeEach(async () => { | ||
const { actions, component } = testBed; | ||
|
||
httpRequestsMockHelpers.setLoadDataStreamsResponse([ | ||
createDataStreamPayload('dataStream1'), | ||
createDataStreamPayload('dataStream2'), | ||
]); | ||
|
||
await act(async () => { | ||
actions.goToDataStreamsList(); | ||
}); | ||
|
||
component.update(); | ||
}); | ||
|
||
test('lists them in the table', async () => { | ||
const { table } = testBed; | ||
|
||
const { tableCellsValues } = table.getMetaData('dataStreamTable'); | ||
|
||
expect(tableCellsValues).toEqual([ | ||
['dataStream1', '1', '@timestamp', '1'], | ||
['dataStream2', '1', '@timestamp', '1'], | ||
]); | ||
}); | ||
|
||
test('has a button to reload the data streams', async () => { | ||
const { exists, actions } = testBed; | ||
const totalRequests = server.requests.length; | ||
|
||
expect(exists('reloadButton')).toBe(true); | ||
|
||
await act(async () => { | ||
actions.clickReloadButton(); | ||
}); | ||
|
||
expect(server.requests.length).toBe(totalRequests + 1); | ||
expect(server.requests[server.requests.length - 1].url).toBe(`${API_BASE_PATH}/data_streams`); | ||
}); | ||
|
||
test('clicking the indices count navigates to the backing indices', async () => { | ||
const { table, actions } = testBed; | ||
|
||
await actions.clickIndicesAt(0); | ||
|
||
expect(table.getMetaData('indexTable').tableCellsValues).toEqual([ | ||
['', '', '', '', '', '', '', 'dataStream1'], | ||
]); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.