diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts index b75d1c507cc7a..f9da7464a900b 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts @@ -38,6 +38,7 @@ export interface DataStreamsTabTestBed extends TestBed { clickEditDataRetentionButton: () => void; clickDetailPanelIndexTemplateLink: () => void; clickManageDataStreamsButton: () => void; + clickBulkDeleteDataStreamsButton: () => void; clickBulkEditDataRetentionButton: () => void; }; findDeleteActionAt: (index: number) => ReactWrapper; @@ -216,7 +217,13 @@ export const setup = async ( testBed.find('dataStreamActionsPopoverButton').simulate('click'); }; + const clickBulkDeleteDataStreamsButton = () => { + testBed.find('dataStreamActionsPopoverButton').simulate('click'); + testBed.find('deleteDataStreamsButton').simulate('click'); + }; + const clickBulkEditDataRetentionButton = () => { + testBed.find('dataStreamActionsPopoverButton').simulate('click'); testBed.find('bulkEditDataRetentionButton').simulate('click'); }; @@ -269,6 +276,7 @@ export const setup = async ( clickEditDataRetentionButton, clickDetailPanelIndexTemplateLink, clickManageDataStreamsButton, + clickBulkDeleteDataStreamsButton, clickBulkEditDataRetentionButton, }, findDeleteActionAt, diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.test.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.test.ts index d3368371de336..6a0783179ce63 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.test.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.test.ts @@ -449,9 +449,64 @@ describe('Data Streams tab', () => { }); }); + describe('bulk delete of data streams', () => { + beforeAll(async () => { + const { setLoadDataStreamsResponse } = httpRequestsMockHelpers; + + const ds1 = createDataStreamPayload({ + name: 'dataStream1', + privileges: { delete_index: true, manage_data_stream_lifecycle: true }, + }); + const ds2 = createDataStreamPayload({ + name: 'dataStream2', + privileges: { delete_index: true, manage_data_stream_lifecycle: true }, + }); + + setLoadDataStreamsResponse([ds1, ds2]); + + testBed = await setup(httpSetup, { + history: createMemoryHistory(), + url: urlServiceMock, + }); + await act(async () => { + testBed.actions.goToDataStreamsList(); + }); + testBed.component.update(); + }); + + test('can delete multiple data streams at once', async () => { + const { + actions: { selectDataStream, clickBulkDeleteDataStreamsButton, clickConfirmDelete }, + } = testBed; + + selectDataStream('dataStream1', true); + selectDataStream('dataStream2', true); + + clickBulkDeleteDataStreamsButton(); + + httpRequestsMockHelpers.setDeleteDataStreamResponse({ + results: { + dataStreamsDeleted: ['dataStream1', 'dataStream2'], + errors: [], + }, + }); + + await clickConfirmDelete(); + + testBed.component.update(); + + expect(httpSetup.post).toHaveBeenLastCalledWith( + `${API_BASE_PATH}/delete_data_streams`, + expect.objectContaining({ + body: JSON.stringify({ dataStreams: ['dataStream1', 'dataStream2'] }), + }) + ); + }); + }); + describe('bulk update data retention', () => { beforeAll(async () => { - const { setLoadDataStreamsResponse, setLoadDataStreamResponse } = httpRequestsMockHelpers; + const { setLoadDataStreamsResponse } = httpRequestsMockHelpers; const ds1 = createDataStreamPayload({ name: 'dataStream1', @@ -467,7 +522,6 @@ describe('Data Streams tab', () => { }); setLoadDataStreamsResponse([ds1, ds2]); - setLoadDataStreamResponse(ds1.name, ds1); testBed = await setup(httpSetup, { history: createMemoryHistory(), @@ -481,16 +535,11 @@ describe('Data Streams tab', () => { test('can set data retention period for mutliple data streams', async () => { const { - actions: { - selectDataStream, - clickManageDataStreamsButton, - clickBulkEditDataRetentionButton, - }, + actions: { selectDataStream, clickBulkEditDataRetentionButton }, } = testBed; selectDataStream('dataStream1', true); selectDataStream('dataStream2', true); - clickManageDataStreamsButton(); clickBulkEditDataRetentionButton(); @@ -526,16 +575,11 @@ describe('Data Streams tab', () => { test('can disable lifecycle', async () => { const { - actions: { - selectDataStream, - clickManageDataStreamsButton, - clickBulkEditDataRetentionButton, - }, + actions: { selectDataStream, clickBulkEditDataRetentionButton }, } = testBed; selectDataStream('dataStream1', true); selectDataStream('dataStream2', true); - clickManageDataStreamsButton(); clickBulkEditDataRetentionButton(); @@ -564,16 +608,11 @@ describe('Data Streams tab', () => { test('allows to set infinite retention period', async () => { const { - actions: { - selectDataStream, - clickManageDataStreamsButton, - clickBulkEditDataRetentionButton, - }, + actions: { selectDataStream, clickBulkEditDataRetentionButton }, } = testBed; selectDataStream('dataStream1', true); selectDataStream('dataStream2', true); - clickManageDataStreamsButton(); clickBulkEditDataRetentionButton(); @@ -1250,4 +1289,4 @@ describe('Data Streams tab', () => { }); }); }); -}); +}); \ No newline at end of file