Skip to content
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 @@ -183,17 +183,23 @@ describe('<IndexManagementHome />', () => {
});

describe('index actions', () => {
const indexName = 'testIndex';
const indexMock = createNonDataStreamIndex(indexName);
const indexNameA = 'testIndexA';
const indexNameB = 'testIndexB';
const indexMockA = createNonDataStreamIndex(indexNameA);
const indexMockB = createNonDataStreamIndex(indexNameB);

beforeEach(async () => {
httpRequestsMockHelpers.setLoadIndicesResponse([
{
...indexMock,
...indexMockA,
isFrozen: true,
},
{
...indexMockB,
status: 'closed',
},
]);
httpRequestsMockHelpers.setReloadIndicesResponse({ indexNames: [indexName] });
httpRequestsMockHelpers.setReloadIndicesResponse({ indexNames: [indexNameA, indexNameB] });

testBed = await setup();
const { component, find } = testBed;
Expand All @@ -202,6 +208,7 @@ describe('<IndexManagementHome />', () => {

find('indexTableIndexNameLink').at(0).simulate('click');
});

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

Expand All @@ -213,6 +220,22 @@ describe('<IndexManagementHome />', () => {
expect(latestRequest.url).toBe(`${API_BASE_PATH}/indices/close`);
});

test('should be able to open a closed index', async () => {
testBed = await setup();
const { component, find, actions } = testBed;

component.update();

find('indexTableIndexNameLink').at(1).simulate('click');

await actions.clickManageContextMenuButton();
await actions.clickContextMenuOption('openIndexMenuButton');

// A refresh call was added after closing an index so we need to check the second to last request.
const latestRequest = server.requests[server.requests.length - 2];
expect(latestRequest.url).toBe(`${API_BASE_PATH}/indices/open`);
});

test('should be able to flush index', async () => {
const { actions } = testBed;

Expand Down Expand Up @@ -240,7 +263,7 @@ describe('<IndexManagementHome />', () => {
test('should be able to unfreeze a frozen index', async () => {
const { actions, exists } = testBed;

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

// Open context menu
await actions.clickManageContextMenuButton();
Expand All @@ -253,10 +276,6 @@ describe('<IndexManagementHome />', () => {
// After the index is unfrozen, we imediately 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`);
// Open context menu once again, since clicking an action will close it.
await actions.clickManageContextMenuButton();
// The unfreeze action should not be present anymore
expect(exists('unfreezeIndexMenuButton')).toBe(false);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,9 @@ export class IndexActionsContextMenu extends Component {
repositionOnScroll
>
<EuiContextMenu
data-test-subj="indexContextMenu"
initialPanelId={0}
panels={panels}
data-test-subj="indexContextMenu"
/>
</EuiPopover>
</div>
Expand Down