diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/test_subjects.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/test_subjects.ts index b24defcdcd79c..8ee05bfa5d322 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/helpers/test_subjects.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/test_subjects.ts @@ -25,6 +25,8 @@ export type TestSubjects = | 'ilmPolicyLink' | 'includeStatsSwitch' | 'includeManagedSwitch' + | 'indexActionsContextMenuButton' + | 'indexContextMenu' | 'indexManagementHeaderContent' | 'indexTable' | 'indexTableIncludeHiddenIndicesToggle' diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts index 01593200a6cd5..900f7ddbf084b 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts @@ -28,6 +28,8 @@ export interface IndicesTestBed extends TestBed { getIncludeHiddenIndicesToggleStatus: () => boolean; clickIncludeHiddenIndicesToggle: () => void; clickDataStreamAt: (index: number) => void; + clickManageContextMenuButton: () => void; + clickContextMenuOption: (optionDataTestSubject: string) => void; }; findDataStreamDetailPanel: () => ReactWrapper; findDataStreamDetailPanelTitle: () => string; @@ -44,11 +46,22 @@ export const setup = async (overridingDependencies: any = {}): Promise { + const { find } = testBed; + const contextMenu = find('indexContextMenu'); + contextMenu.find(`button[data-test-subj="${optionDataTestSubject}"]`).simulate('click'); + }; + const clickIncludeHiddenIndicesToggle = () => { const { find } = testBed; find('indexTableIncludeHiddenIndicesToggle').simulate('click'); }; + const clickManageContextMenuButton = () => { + const { find } = testBed; + find('indexActionsContextMenuButton').simulate('click'); + }; + const getIncludeHiddenIndicesToggleStatus = () => { const { find } = testBed; const props = find('indexTableIncludeHiddenIndicesToggle').props(); @@ -95,6 +108,8 @@ export const setup = async (overridingDependencies: any = {}): Promise', () => { expect(latestRequest.url).toBe(`${API_BASE_PATH}/settings/${encodeURIComponent(indexName)}`); }); }); + + describe('index actions', () => { + const indexName = 'testIndex'; + beforeEach(async () => { + const index = { + health: 'green', + status: 'open', + primary: 1, + replica: 1, + documents: 10000, + documents_deleted: 100, + size: '156kb', + primary_size: '156kb', + name: indexName, + }; + + httpRequestsMockHelpers.setLoadIndicesResponse([index]); + testBed = await setup(); + const { find, component } = testBed; + component.update(); + + find('indexTableIndexNameLink').at(0).simulate('click'); + }); + + test('should be able to flush index', async () => { + const { actions } = testBed; + await actions.clickManageContextMenuButton(); + await actions.clickContextMenuOption('flushIndexMenuButton'); + + const latestRequest = server.requests[server.requests.length - 1]; + expect(latestRequest.url).toBe(`${API_BASE_PATH}/indices/flush`); + }); + }); });