mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Added Component Integration Test for Opening A closed Index. * Fixed open index test and changed the structure of the tests to consolidate boilerplate. * Fixed PR based on feedback. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.test.ts
This commit is contained in:
parent
e23739e7d7
commit
7dca9c0eab
2 changed files with 29 additions and 10 deletions
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue