From f3bf247138d7c5ebe41b8b414aa46af77a8a395e Mon Sep 17 00:00:00 2001 From: John Dorlus Date: Fri, 10 Dec 2021 16:51:12 -0500 Subject: [PATCH] Added Close Index Component Integration Test For Index Management (#114020) * Added close index test. * Fixed linting issues. * Fixed linting issues. * Abstracted out the index action option selection method and cleaned up test. * Merged Yulia's changes into this PR and updated the test to consume the new data test subjects. * Adjusted assertion to check for second to last request since there is a refresh done after the close index call. * Fixed linting issue. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../client_integration/helpers/test_subjects.ts | 1 - .../client_integration/home/indices_tab.helpers.ts | 1 - .../client_integration/home/indices_tab.test.ts | 13 ++++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) 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 96775484e0733..2373d967512b9 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,7 +25,6 @@ export type TestSubjects = | 'ilmPolicyLink' | 'includeStatsSwitch' | 'includeManagedSwitch' - | 'indexActionsContextMenuButton' | 'indexContextMenu' | 'indexManagementHeaderContent' | 'indexTable' 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 0e4564163c553..c1b8dfcc0034f 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 @@ -45,7 +45,6 @@ export const setup = async (overridingDependencies: any = {}): Promise { const { find, component } = testBed; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.test.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.test.ts index 79fe885820fae..da5bc2fc39cca 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.test.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.test.ts @@ -171,11 +171,22 @@ describe('', () => { httpRequestsMockHelpers.setReloadIndicesResponse({ indexNames: [indexName] }); testBed = await setup(); - const { find, component } = testBed; + const { component, find } = testBed; + component.update(); find('indexTableIndexNameLink').at(0).simulate('click'); }); + test('should be able to close an open index', async () => { + const { actions } = testBed; + + await actions.clickManageContextMenuButton(); + await actions.clickContextMenuOption('closeIndexMenuButton'); + + // A refresh call was added after closing an index so we need to check the second to last request. + const latestRequest = server.requests[server.requests.length - 2]; + expect(latestRequest.url).toBe(`${API_BASE_PATH}/indices/close`); + }); test('should be able to flush index', async () => { const { actions } = testBed;