Skip to content

Commit 3f61937

Browse files
committed
Fixed due to comments
1 parent 2c1145e commit 3f61937

10 files changed

Lines changed: 132 additions & 177 deletions

File tree

x-pack/plugins/triggers_actions_ui/public/application/context/actions_connectors_context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { TypeRegistry } from '../type_registry';
1212
export interface ActionsConnectorsContextValue {
1313
http: HttpSetup;
1414
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
15-
toastNotifications?: Pick<
15+
toastNotifications: Pick<
1616
ToastsApi,
1717
'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError'
1818
>;

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,21 @@ import { coreMock } from '../../../../../../../src/core/public/mocks';
99
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
1010
import { ValidationResult, ActionConnector } from '../../../types';
1111
import { ActionConnectorForm } from './action_connector_form';
12+
import { ActionsConnectorsContextValue } from '../../context/actions_connectors_context';
1213
const actionTypeRegistry = actionTypeRegistryMock.create();
1314

1415
describe('action_connector_form', () => {
15-
let deps: any;
16+
let deps: ActionsConnectorsContextValue;
1617
beforeAll(async () => {
1718
const mocks = coreMock.createSetup();
1819
const [
1920
{
20-
chrome,
21-
docLinks,
2221
application: { capabilities },
2322
},
2423
] = await mocks.getStartServices();
2524
deps = {
26-
chrome,
27-
docLinks,
2825
toastNotifications: mocks.notifications.toasts,
29-
injectedMetadata: mocks.injectedMetadata,
3026
http: mocks.http,
31-
uiSettings: mocks.uiSettings,
3227
capabilities: {
3328
...capabilities,
3429
actions: {
@@ -37,11 +32,7 @@ describe('action_connector_form', () => {
3732
show: true,
3833
},
3934
},
40-
legacy: {
41-
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
42-
},
4335
actionTypeRegistry: actionTypeRegistry as any,
44-
alertTypeRegistry: {} as any,
4536
};
4637
});
4738

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
import * as React from 'react';
77
import { mountWithIntl } from 'test_utils/enzyme_helpers';
88
import { coreMock } from '../../../../../../../src/core/public/mocks';
9-
import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context';
9+
import {
10+
ActionsConnectorsContextProvider,
11+
ActionsConnectorsContextValue,
12+
} from '../../context/actions_connectors_context';
1013
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
1114
import { ActionTypeMenu } from './action_type_menu';
1215
import { ValidationResult } from '../../../types';
1316
const actionTypeRegistry = actionTypeRegistryMock.create();
1417

1518
describe('connector_add_flyout', () => {
16-
let deps: any;
19+
let deps: ActionsConnectorsContextValue;
1720

1821
beforeAll(async () => {
1922
const mockes = coreMock.createSetup();
@@ -24,6 +27,7 @@ describe('connector_add_flyout', () => {
2427
] = await mockes.getStartServices();
2528
deps = {
2629
http: mockes.http,
30+
toastNotifications: mockes.notifications.toasts,
2731
capabilities: {
2832
...capabilities,
2933
actions: {
@@ -60,6 +64,7 @@ describe('connector_add_flyout', () => {
6064
http: deps!.http,
6165
actionTypeRegistry: deps!.actionTypeRegistry,
6266
capabilities: deps!.capabilities,
67+
toastNotifications: deps!.toastNotifications,
6368
reloadConnectors: () => {
6469
return new Promise<void>(() => {});
6570
},

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ import * as React from 'react';
77
import { mountWithIntl } from 'test_utils/enzyme_helpers';
88
import { coreMock } from '../../../../../../../src/core/public/mocks';
99
import { ConnectorAddFlyout } from './connector_add_flyout';
10-
import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context';
10+
import {
11+
ActionsConnectorsContextProvider,
12+
ActionsConnectorsContextValue,
13+
} from '../../context/actions_connectors_context';
1114
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
1215
import { ValidationResult } from '../../../types';
13-
import { AppContextProvider } from '../../app_context';
1416

1517
const actionTypeRegistry = actionTypeRegistryMock.create();
1618

1719
describe('connector_add_flyout', () => {
18-
let deps: any;
20+
let deps: ActionsConnectorsContextValue;
1921

2022
beforeAll(async () => {
2123
const mocks = coreMock.createSetup();
@@ -36,7 +38,6 @@ describe('connector_add_flyout', () => {
3638
},
3739
},
3840
actionTypeRegistry: actionTypeRegistry as any,
39-
alertTypeRegistry: {} as any,
4041
};
4142
});
4243

@@ -59,30 +60,29 @@ describe('connector_add_flyout', () => {
5960
actionTypeRegistry.has.mockReturnValue(true);
6061

6162
const wrapper = mountWithIntl(
62-
<AppContextProvider appDeps={deps}>
63-
<ActionsConnectorsContextProvider
64-
value={{
65-
http: deps!.http,
66-
actionTypeRegistry: deps!.actionTypeRegistry,
67-
capabilities: deps!.capabilities,
68-
reloadConnectors: () => {
69-
return new Promise<void>(() => {});
63+
<ActionsConnectorsContextProvider
64+
value={{
65+
http: deps!.http,
66+
toastNotifications: deps!.toastNotifications,
67+
actionTypeRegistry: deps!.actionTypeRegistry,
68+
capabilities: deps!.capabilities,
69+
reloadConnectors: () => {
70+
return new Promise<void>(() => {});
71+
},
72+
}}
73+
>
74+
<ConnectorAddFlyout
75+
addFlyoutVisible={true}
76+
setAddFlyoutVisibility={() => {}}
77+
actionTypes={[
78+
{
79+
id: actionType.id,
80+
enabled: true,
81+
name: 'Test',
7082
},
71-
}}
72-
>
73-
<ConnectorAddFlyout
74-
addFlyoutVisible={true}
75-
setAddFlyoutVisibility={state => {}}
76-
actionTypes={[
77-
{
78-
id: actionType.id,
79-
enabled: true,
80-
name: 'Test',
81-
},
82-
]}
83-
/>
84-
</ActionsConnectorsContextProvider>
85-
</AppContextProvider>
83+
]}
84+
/>
85+
</ActionsConnectorsContextProvider>
8686
);
8787
expect(wrapper.find('ActionTypeMenu')).toHaveLength(1);
8888
expect(wrapper.find('[data-test-subj="my-action-type-card"]').exists()).toBeTruthy();

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.test.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,22 @@ import { coreMock } from '../../../../../../../src/core/public/mocks';
99
import { ConnectorAddModal } from './connector_add_modal';
1010
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
1111
import { ValidationResult } from '../../../types';
12-
import { AppDeps } from '../../app';
13-
import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks';
14-
import { chartPluginMock } from '../../../../../../../src/plugins/charts/public/mocks';
12+
import { ActionsConnectorsContextValue } from '../../context/actions_connectors_context';
1513
const actionTypeRegistry = actionTypeRegistryMock.create();
1614

1715
describe('connector_add_modal', () => {
18-
let deps: AppDeps | null;
16+
let deps: ActionsConnectorsContextValue;
1917

2018
beforeAll(async () => {
2119
const mocks = coreMock.createSetup();
2220
const [
2321
{
24-
chrome,
25-
docLinks,
2622
application: { capabilities },
2723
},
2824
] = await mocks.getStartServices();
2925
deps = {
30-
chrome,
31-
docLinks,
32-
dataPlugin: dataPluginMock.createStartContract(),
33-
charts: chartPluginMock.createStartContract(),
3426
toastNotifications: mocks.notifications.toasts,
35-
injectedMetadata: mocks.injectedMetadata,
3627
http: mocks.http,
37-
uiSettings: mocks.uiSettings,
3828
capabilities: {
3929
...capabilities,
4030
actions: {
@@ -43,9 +33,7 @@ describe('connector_add_modal', () => {
4333
show: true,
4434
},
4535
},
46-
setBreadcrumbs: jest.fn(),
4736
actionTypeRegistry: actionTypeRegistry as any,
48-
alertTypeRegistry: {} as any,
4937
};
5038
});
5139
it('renders connector modal form if addModalVisible is true', () => {
@@ -80,7 +68,7 @@ describe('connector_add_modal', () => {
8068
actionType={actionType}
8169
http={deps.http}
8270
actionTypeRegistry={deps.actionTypeRegistry}
83-
alertTypeRegistry={deps.alertTypeRegistry}
71+
alertTypeRegistry={{} as any}
8472
toastNotifications={deps.toastNotifications}
8573
/>
8674
)

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { actionTypeRegistryMock } from '../../action_type_registry.mock';
1111
import { ValidationResult } from '../../../types';
1212
import { ConnectorEditFlyout } from './connector_edit_flyout';
1313
import { AppContextProvider } from '../../app_context';
14-
import { chartPluginMock } from '../../../../../../../src/plugins/charts/public/mocks';
15-
import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks';
1614

1715
const actionTypeRegistry = actionTypeRegistryMock.create();
1816
let deps: any;
@@ -22,18 +20,11 @@ describe('connector_edit_flyout', () => {
2220
const mockes = coreMock.createSetup();
2321
const [
2422
{
25-
chrome,
26-
docLinks,
2723
application: { capabilities },
2824
},
2925
] = await mockes.getStartServices();
3026
deps = {
31-
chrome,
32-
docLinks,
33-
dataPlugin: dataPluginMock.createStartContract(),
34-
charts: chartPluginMock.createStartContract(),
3527
toastNotifications: mockes.notifications.toasts,
36-
injectedMetadata: mockes.injectedMetadata,
3728
http: mockes.http,
3829
uiSettings: mockes.uiSettings,
3930
capabilities: {
@@ -44,7 +35,6 @@ describe('connector_edit_flyout', () => {
4435
show: true,
4536
},
4637
},
47-
setBreadcrumbs: jest.fn(),
4838
actionTypeRegistry: actionTypeRegistry as any,
4939
alertTypeRegistry: {} as any,
5040
};
@@ -83,6 +73,7 @@ describe('connector_edit_flyout', () => {
8373
<ActionsConnectorsContextProvider
8474
value={{
8575
http: deps.http,
76+
toastNotifications: deps.toastNotifications,
8677
capabilities: deps.capabilities,
8778
actionTypeRegistry: deps.actionTypeRegistry,
8879
reloadConnectors: () => {

x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.test.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('alert_edit', () => {
2020
let deps: any;
2121
let wrapper: ReactWrapper<any>;
2222

23-
beforeAll(async () => {
23+
async function setup() {
2424
const mockes = coreMock.createSetup();
2525
deps = {
2626
toastNotifications: mockes.notifications.toasts,
@@ -122,9 +122,10 @@ describe('alert_edit', () => {
122122
await nextTick();
123123
wrapper.update();
124124
});
125-
});
125+
}
126126

127-
it('renders alert add flyout', () => {
127+
it('renders alert add flyout', async () => {
128+
await setup();
128129
expect(wrapper.find('[data-test-subj="editAlertFlyoutTitle"]').exists()).toBeTruthy();
129130
expect(wrapper.find('[data-test-subj="saveEditedAlertButton"]').exists()).toBeTruthy();
130131
});

0 commit comments

Comments
 (0)