Added Component Integration Test for Flush Action in Index Management (#114401)

* Aded some data test subjects for the test.

* Added flush indices test.

* Fixed linting issue.

* Merged test subject PR in and updated tests.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
John Dorlus 2021-10-15 14:22:45 -04:00 committed by GitHub
parent 47ce4a80a6
commit 98acb5d8a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 0 deletions

View file

@ -25,6 +25,8 @@ export type TestSubjects =
| 'ilmPolicyLink'
| 'includeStatsSwitch'
| 'includeManagedSwitch'
| 'indexActionsContextMenuButton'
| 'indexContextMenu'
| 'indexManagementHeaderContent'
| 'indexTable'
| 'indexTableIncludeHiddenIndicesToggle'

View file

@ -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;
@ -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();
@ -95,6 +108,8 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
getIncludeHiddenIndicesToggleStatus,
clickIncludeHiddenIndicesToggle,
clickDataStreamAt,
clickManageContextMenuButton,
clickContextMenuOption,
},
findDataStreamDetailPanel,
findDataStreamDetailPanelTitle,

View file

@ -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`);
});
});
});