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

Added Component Integration Test For Force Merging an Index #122176

Merged
merged 5 commits into from
Jan 1, 2022
Merged
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 @@ -21,6 +21,7 @@ export type TestSubjects =
| 'deleteTemplatesConfirmation'
| 'documentationLink'
| 'emptyPrompt'
| 'forcemergeIndexMenuButton'
| 'filterList.filterItem'
| 'ilmPolicyLink'
| 'includeStatsSwitch'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IndicesTestBed extends TestBed<TestSubjects> {
clickDataStreamAt: (index: number) => void;
clickManageContextMenuButton: () => void;
clickContextMenuOption: (optionDataTestSubject: string) => void;
clickModalConfirm: () => void;
};
findDataStreamDetailPanel: () => ReactWrapper;
findDataStreamDetailPanelTitle: () => string;
Expand Down Expand Up @@ -97,6 +98,15 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
component.update();
};

const clickModalConfirm = async () => {
const { find, component } = testBed;

await act(async () => {
find('confirmModalConfirmButton').simulate('click');
});
component.update();
};

const findDataStreamDetailPanel = () => {
const { find } = testBed;
return find('dataStreamDetailPanel');
Expand All @@ -116,6 +126,7 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
clickDataStreamAt,
clickManageContextMenuButton,
clickContextMenuOption,
clickModalConfirm,
},
findDataStreamDetailPanel,
findDataStreamDetailPanelTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('<IndexManagementHome />', () => {

test("should be able to clear an index's cache", async () => {
const { actions } = testBed;
actions.clickManageContextMenuButton();
await actions.clickManageContextMenuButton();

await actions.clickManageContextMenuButton();
await actions.clickContextMenuOption('clearCacheIndexMenuButton');
Expand Down Expand Up @@ -291,6 +291,26 @@ describe('<IndexManagementHome />', () => {
// The unfreeze action should not be present anymore
expect(exists('unfreezeIndexMenuButton')).toBe(false);
});

test('should be able to force merge an index', async () => {
const { actions, exists } = testBed;

httpRequestsMockHelpers.setReloadIndicesResponse([{ ...indexMockA, isFrozen: false }]);

// Open context menu
await actions.clickManageContextMenuButton();
// Check that the force merge action exists for the current index and merge it
expect(exists('forcemergeIndexMenuButton')).toBe(true);
await actions.clickContextMenuOption('forcemergeIndexMenuButton');

await actions.clickModalConfirm();

const requestsCount = server.requests.length;
expect(server.requests[requestsCount - 2].url).toBe(`${API_BASE_PATH}/indices/forcemerge`);
// After the index is force merged, we immediately do a reload. So we need to expect to see
// a reload server call also.
expect(server.requests[requestsCount - 1].url).toBe(`${API_BASE_PATH}/indices/reload`);
});
});

describe('Edit index settings', () => {
Expand Down