Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.15] Added Component Integration Test for Flush Action in Index Management (#114401) #115249

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`);
});
});
});