Skip to content

Commit c64651f

Browse files
committed
Fix Index Management Jest tests.
1 parent ef3a963 commit c64651f

File tree

7 files changed

+34
-13
lines changed

7 files changed

+34
-13
lines changed

x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { ReactWrapper } from 'enzyme';
1010

1111
import { EuiDescriptionListDescription } from '@elastic/eui';
1212
import { registerTestBed, TestBed, TestBedConfig, findTestSubject } from '@kbn/test/jest';
13+
14+
import { KibanaPageTemplate } from '../../../../../../src/plugins/kibana_react/public';
1315
import { DataStream } from '../../../common';
1416
import { IndexManagementHome } from '../../../public/application/sections/home';
1517
import { indexManagementStore } from '../../../public/application/store';
@@ -51,11 +53,13 @@ export const setup = async (overridingDependencies: any = {}): Promise<DataStrea
5153
doMountAsync: true,
5254
};
5355

54-
const initTestBed = registerTestBed(
56+
const setupTestbed = registerTestBed(
5557
WithAppDependencies(IndexManagementHome, overridingDependencies),
5658
testBedConfig
5759
);
58-
const testBed = await initTestBed();
60+
const testBed = await setupTestbed({
61+
managementPageLayout: KibanaPageTemplate,
62+
});
5963

6064
/**
6165
* User Actions

x-pack/plugins/index_management/__jest__/client_integration/home/home.helpers.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77

88
import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest';
9+
10+
import { KibanaPageTemplate } from '../../../../../../src/plugins/kibana_react/public';
911
import { IndexManagementHome } from '../../../public/application/sections/home';
1012
import { indexManagementStore } from '../../../public/application/store';
1113
import { WithAppDependencies, services, TestSubjects } from '../helpers';
@@ -19,7 +21,7 @@ const testBedConfig: TestBedConfig = {
1921
doMountAsync: true,
2022
};
2123

22-
const initTestBed = registerTestBed(WithAppDependencies(IndexManagementHome), testBedConfig);
24+
const setupTestbed = registerTestBed(WithAppDependencies(IndexManagementHome), testBedConfig);
2325

2426
export interface HomeTestBed extends TestBed<TestSubjects> {
2527
actions: {
@@ -28,7 +30,9 @@ export interface HomeTestBed extends TestBed<TestSubjects> {
2830
}
2931

3032
export const setup = async (): Promise<HomeTestBed> => {
31-
const testBed = await initTestBed();
33+
const testBed = await setupTestbed({
34+
managementPageLayout: KibanaPageTemplate,
35+
});
3236

3337
/**
3438
* User Actions

x-pack/plugins/index_management/__jest__/client_integration/home/index_templates_tab.helpers.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import { act } from 'react-dom/test-utils';
99

1010
import { registerTestBed, TestBed, TestBedConfig, findTestSubject } from '@kbn/test/jest';
11+
12+
import { KibanaPageTemplate } from '../../../../../../src/plugins/kibana_react/public';
1113
import { TemplateList } from '../../../public/application/sections/home/template_list';
1214
import { TemplateDeserialized } from '../../../common';
1315
import { WithAppDependencies, TestSubjects } from '../helpers';
@@ -20,7 +22,10 @@ const testBedConfig: TestBedConfig = {
2022
doMountAsync: true,
2123
};
2224

23-
const initTestBed = registerTestBed<TestSubjects>(WithAppDependencies(TemplateList), testBedConfig);
25+
const setupTestbed = registerTestBed<TestSubjects>(
26+
WithAppDependencies(TemplateList),
27+
testBedConfig
28+
);
2429

2530
const createActions = (testBed: TestBed<TestSubjects>) => {
2631
/**
@@ -128,7 +133,9 @@ const createActions = (testBed: TestBed<TestSubjects>) => {
128133
};
129134

130135
export const setup = async (): Promise<IndexTemplatesTabTestBed> => {
131-
const testBed = await initTestBed();
136+
const testBed = await setupTestbed({
137+
managementPageLayout: KibanaPageTemplate,
138+
});
132139

133140
return {
134141
...testBed,

x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { act } from 'react-dom/test-utils';
99
import { ReactWrapper } from 'enzyme';
1010

1111
import { registerTestBed, TestBed, TestBedConfig, findTestSubject } from '@kbn/test/jest';
12+
13+
import { KibanaPageTemplate } from '../../../../../../src/plugins/kibana_react/public';
1214
import { IndexManagementHome } from '../../../public/application/sections/home';
1315
import { indexManagementStore } from '../../../public/application/store';
1416
import { WithAppDependencies, services, TestSubjects } from '../helpers';
@@ -34,11 +36,13 @@ export interface IndicesTestBed extends TestBed<TestSubjects> {
3436
}
3537

3638
export const setup = async (overridingDependencies: any = {}): Promise<IndicesTestBed> => {
37-
const initTestBed = registerTestBed(
39+
const setupTestbed = registerTestBed(
3840
WithAppDependencies(IndexManagementHome, overridingDependencies),
3941
testBedConfig
4042
);
41-
const testBed = await initTestBed();
43+
const testBed = await setupTestbed({
44+
managementPageLayout: KibanaPageTemplate,
45+
});
4246

4347
/**
4448
* User Actions

x-pack/plugins/index_management/__jest__/components/index_table.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { MemoryRouter } from 'react-router-dom';
1818
*/
1919
import { mountWithIntl, stubWebWorker } from '@kbn/test/jest'; // eslint-disable-line no-unused-vars
2020

21+
import { KibanaPageTemplate } from '../../../../../src/plugins/kibana_react/public';
2122
import { AppWithoutRouter } from '../../public/application/app';
2223
import { AppContextProvider } from '../../public/application/app_context';
2324
import { Provider } from 'react-redux';
@@ -137,7 +138,7 @@ describe('index table', () => {
137138
<Provider store={store}>
138139
<MemoryRouter initialEntries={[`${BASE_PATH}indices`]}>
139140
<AppContextProvider value={appDependencies}>
140-
<AppWithoutRouter />
141+
<AppWithoutRouter managementPageLayout={KibanaPageTemplate} />
141142
</AppContextProvider>
142143
</MemoryRouter>
143144
</Provider>

x-pack/plugins/index_management/public/application/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const AppWithoutRouter = ({
6363
render={(props) => (
6464
<IndexManagementHome
6565
section={props.match.params.section}
66-
historyPush={props.history.push}
66+
history={props.history}
6767
managementPageLayout={managementPageLayout}
6868
/>
6969
)}

x-pack/plugins/index_management/public/application/sections/home/home.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import React, { useEffect } from 'react';
99
import { Route, Switch } from 'react-router-dom';
10+
import { History } from 'history';
1011
import { FormattedMessage } from '@kbn/i18n/react';
1112
import { EuiButtonEmpty } from '@elastic/eui';
1213
import { documentationService } from '../../services/documentation';
@@ -33,13 +34,13 @@ export const homeSections = [
3334

3435
interface MatchParams {
3536
section: Section;
36-
historyPush: (newRoute: string) => void;
37+
history: History;
3738
managementPageLayout: ManagementAppMountParams['managementPageLayout'];
3839
}
3940

4041
export const IndexManagementHome = ({
4142
section,
42-
historyPush,
43+
history,
4344
managementPageLayout: ManagementPageLayout,
4445
}: MatchParams) => {
4546
const tabs = [
@@ -77,7 +78,7 @@ export const IndexManagementHome = ({
7778
];
7879

7980
const onSectionChange = (newSection: Section) => {
80-
historyPush(`/${newSection}`);
81+
history.push(`/${newSection}`);
8182
};
8283

8384
useEffect(() => {

0 commit comments

Comments
 (0)