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

Add CITs for index management to show hidden and rollup indices and update existing tabs test to reflect all tabs #112010

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export type TestSubjects =
| 'aliasesTabContent'
| 'appTitle'
| 'cell'
| 'indexManagementHome div div:nth-child(2) div:nth-child(2)'
cuff-links marked this conversation as resolved.
Show resolved Hide resolved
| 'component_templatesTab'
| 'data_streamsTab'
| 'closeDetailsButton'
| 'createLegacyTemplateButton'
| 'createTemplateButton'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { ReactWrapper } from 'enzyme';

import { EuiDescriptionListDescription } from '@elastic/eui';
import { registerTestBed, TestBed, TestBedConfig, findTestSubject } from '@kbn/test/jest';
import { DataStream } from '../../../common';
import { IndexManagementHome } from '../../../public/application/sections/home';
import { indexManagementStore } from '../../../public/application/store';
import { WithAppDependencies, services, TestSubjects } from '../helpers';
import { DataStream } from '../../../../common';
import { IndexManagementHome } from '../../../../public/application/sections/home';
import { indexManagementStore } from '../../../../public/application/store';
import { WithAppDependencies, services, TestSubjects } from '../../helpers';

export interface DataStreamsTabTestBed extends TestBed<TestSubjects> {
actions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { act } from 'react-dom/test-utils';
import { createMemoryHistory } from 'history';

import { API_BASE_PATH } from '../../../common/constants';
import * as fixtures from '../../../test/fixtures';
import { setupEnvironment } from '../helpers';
import { API_BASE_PATH } from '../../../../common/constants';
import * as fixtures from '../../../../test/fixtures';
import { setupEnvironment } from '../../helpers';

import {
DataStreamsTabTestBed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const initTestBed = registerTestBed(WithAppDependencies(IndexManagementHome), te
export interface HomeTestBed extends TestBed<TestSubjects> {
actions: {
selectHomeTab: (tab: 'indicesTab' | 'templatesTab') => void;
showHiddenIndices: () => void;
};
}

Expand All @@ -38,10 +39,15 @@ export const setup = async (): Promise<HomeTestBed> => {
testBed.find(tab).simulate('click');
};

const showHiddenIndices = () => {
cuff-links marked this conversation as resolved.
Show resolved Hide resolved
testBed.find('indexTableIncludeHiddenIndicesToggle').simulate('click');
};

return {
...testBed,
actions: {
selectHomeTab,
showHiddenIndices,
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,22 @@ describe('<IndexManagementHome />', () => {
});

describe('tabs', () => {
test('should have 2 tabs', () => {
test('should have 4 tabs', () => {
const { find } = testBed;
const templatesTab = find('templatesTab');
const indicesTab = find('indicesTab');

expect(indicesTab.length).toBe(1);
expect(indicesTab.text()).toEqual('Indices');
expect(templatesTab.length).toBe(1);
expect(templatesTab.text()).toEqual('Index Templates');
const allTabs = [
{ label: 'Index Templates', element: find('templatesTab') },
{ label: 'Indices', element: find('indicesTab') },
{ label: 'Data Streams', element: find('data_streamsTab') },
{ label: 'Component Templates', element: find('component_templatesTab') },
];

expect(allTabs.length).toBe(4);

allTabs.forEach((tab) => {
expect(tab.element).toBeTruthy();
expect(tab.element.length).toBe(1);
expect(tab.element.text()).toEqual(tab.label);
cuff-links marked this conversation as resolved.
Show resolved Hide resolved
});
});

test('should navigate to Index Templates tab', async () => {
Expand All @@ -83,6 +90,14 @@ describe('<IndexManagementHome />', () => {
expect(exists('indicesList')).toBe(false);
expect(exists('templateList')).toBe(true);
});

describe('toggles', () => {
test('Should show system indices if hidden indices is toggled. ', () => {
const { find, actions } = testBed;

actions.showHiddenIndices();
cuff-links marked this conversation as resolved.
Show resolved Hide resolved
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { act } from 'react-dom/test-utils';

import { registerTestBed, TestBed, TestBedConfig, findTestSubject } from '@kbn/test/jest';
import { TemplateList } from '../../../public/application/sections/home/template_list';
import { TemplateDeserialized } from '../../../common';
import { WithAppDependencies, TestSubjects } from '../helpers';
import { TemplateList } from '../../../../public/application/sections/home/template_list';
import { TemplateDeserialized } from '../../../../common';
import { WithAppDependencies, TestSubjects } from '../../helpers';

const testBedConfig: TestBedConfig = {
memoryRouter: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import { act } from 'react-dom/test-utils';

import * as fixtures from '../../../test/fixtures';
import { API_BASE_PATH } from '../../../common/constants';
import { setupEnvironment, getRandomString } from '../helpers';
import * as fixtures from '../../../../test/fixtures';
import { API_BASE_PATH } from '../../../../common/constants';
import { setupEnvironment, getRandomString } from '../../helpers';

import { IndexTemplatesTabTestBed, setup } from './index_templates_tab.helpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { act } from 'react-dom/test-utils';
import { API_BASE_PATH } from '../../../common/constants';
import { setupEnvironment, nextTick } from '../helpers';
import { IndicesTestBed, setup } from './indices_tab.helpers';
import { createDataStreamPayload } from './data_streams_tab.helpers';
import { createDataStreamPayload } from './data_streams/data_streams_tab.helpers';

/**
* The below import is required to avoid a console error warn from the "brace" package
Expand Down