Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export type TestSubjects =
| 'ilmPolicyLink'
| 'includeStatsSwitch'
| 'includeManagedSwitch'
| 'indexActionsContextMenuButton'
| 'indexContextMenu'
| 'indexManagementHeaderContent'
| 'indexTable'
| 'indexTableIncludeHiddenIndicesToggle'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface IndicesTestBed extends TestBed<TestSubjects> {
getIncludeHiddenIndicesToggleStatus: () => boolean;
clickIncludeHiddenIndicesToggle: () => void;
clickDataStreamAt: (index: number) => void;
clickManageContextMenuButton: () => void;
clickContextMenuOption: (optionDataTestSubject: string) => void;
};
findDataStreamDetailPanel: () => ReactWrapper;
findDataStreamDetailPanelTitle: () => string;
Expand All @@ -44,11 +46,22 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
* User Actions
*/

const clickContextMenuOption = async (optionDataTestSubject: string) => {
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();
Expand Down Expand Up @@ -95,6 +108,8 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
getIncludeHiddenIndicesToggleStatus,
clickIncludeHiddenIndicesToggle,
clickDataStreamAt,
clickManageContextMenuButton,
clickContextMenuOption,
},
findDataStreamDetailPanel,
findDataStreamDetailPanelTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,37 @@ describe('<IndexManagementHome />', () => {
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`);
});
});
});