Skip to content

Commit

Permalink
Fixed due to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Mar 5, 2020
1 parent 2c1145e commit 3f61937
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { TypeRegistry } from '../type_registry';
export interface ActionsConnectorsContextValue {
http: HttpSetup;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
toastNotifications?: Pick<
toastNotifications: Pick<
ToastsApi,
'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError'
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,21 @@ import { coreMock } from '../../../../../../../src/core/public/mocks';
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
import { ValidationResult, ActionConnector } from '../../../types';
import { ActionConnectorForm } from './action_connector_form';
import { ActionsConnectorsContextValue } from '../../context/actions_connectors_context';
const actionTypeRegistry = actionTypeRegistryMock.create();

describe('action_connector_form', () => {
let deps: any;
let deps: ActionsConnectorsContextValue;
beforeAll(async () => {
const mocks = coreMock.createSetup();
const [
{
chrome,
docLinks,
application: { capabilities },
},
] = await mocks.getStartServices();
deps = {
chrome,
docLinks,
toastNotifications: mocks.notifications.toasts,
injectedMetadata: mocks.injectedMetadata,
http: mocks.http,
uiSettings: mocks.uiSettings,
capabilities: {
...capabilities,
actions: {
Expand All @@ -37,11 +32,7 @@ describe('action_connector_form', () => {
show: true,
},
},
legacy: {
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
},
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: {} as any,
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
import * as React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { coreMock } from '../../../../../../../src/core/public/mocks';
import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context';
import {
ActionsConnectorsContextProvider,
ActionsConnectorsContextValue,
} from '../../context/actions_connectors_context';
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
import { ActionTypeMenu } from './action_type_menu';
import { ValidationResult } from '../../../types';
const actionTypeRegistry = actionTypeRegistryMock.create();

describe('connector_add_flyout', () => {
let deps: any;
let deps: ActionsConnectorsContextValue;

beforeAll(async () => {
const mockes = coreMock.createSetup();
Expand All @@ -24,6 +27,7 @@ describe('connector_add_flyout', () => {
] = await mockes.getStartServices();
deps = {
http: mockes.http,
toastNotifications: mockes.notifications.toasts,
capabilities: {
...capabilities,
actions: {
Expand Down Expand Up @@ -60,6 +64,7 @@ describe('connector_add_flyout', () => {
http: deps!.http,
actionTypeRegistry: deps!.actionTypeRegistry,
capabilities: deps!.capabilities,
toastNotifications: deps!.toastNotifications,
reloadConnectors: () => {
return new Promise<void>(() => {});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import * as React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { coreMock } from '../../../../../../../src/core/public/mocks';
import { ConnectorAddFlyout } from './connector_add_flyout';
import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context';
import {
ActionsConnectorsContextProvider,
ActionsConnectorsContextValue,
} from '../../context/actions_connectors_context';
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
import { ValidationResult } from '../../../types';
import { AppContextProvider } from '../../app_context';

const actionTypeRegistry = actionTypeRegistryMock.create();

describe('connector_add_flyout', () => {
let deps: any;
let deps: ActionsConnectorsContextValue;

beforeAll(async () => {
const mocks = coreMock.createSetup();
Expand All @@ -36,7 +38,6 @@ describe('connector_add_flyout', () => {
},
},
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: {} as any,
};
});

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

const wrapper = mountWithIntl(
<AppContextProvider appDeps={deps}>
<ActionsConnectorsContextProvider
value={{
http: deps!.http,
actionTypeRegistry: deps!.actionTypeRegistry,
capabilities: deps!.capabilities,
reloadConnectors: () => {
return new Promise<void>(() => {});
<ActionsConnectorsContextProvider
value={{
http: deps!.http,
toastNotifications: deps!.toastNotifications,
actionTypeRegistry: deps!.actionTypeRegistry,
capabilities: deps!.capabilities,
reloadConnectors: () => {
return new Promise<void>(() => {});
},
}}
>
<ConnectorAddFlyout
addFlyoutVisible={true}
setAddFlyoutVisibility={() => {}}
actionTypes={[
{
id: actionType.id,
enabled: true,
name: 'Test',
},
}}
>
<ConnectorAddFlyout
addFlyoutVisible={true}
setAddFlyoutVisibility={state => {}}
actionTypes={[
{
id: actionType.id,
enabled: true,
name: 'Test',
},
]}
/>
</ActionsConnectorsContextProvider>
</AppContextProvider>
]}
/>
</ActionsConnectorsContextProvider>
);
expect(wrapper.find('ActionTypeMenu')).toHaveLength(1);
expect(wrapper.find('[data-test-subj="my-action-type-card"]').exists()).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,22 @@ import { coreMock } from '../../../../../../../src/core/public/mocks';
import { ConnectorAddModal } from './connector_add_modal';
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
import { ValidationResult } from '../../../types';
import { AppDeps } from '../../app';
import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks';
import { chartPluginMock } from '../../../../../../../src/plugins/charts/public/mocks';
import { ActionsConnectorsContextValue } from '../../context/actions_connectors_context';
const actionTypeRegistry = actionTypeRegistryMock.create();

describe('connector_add_modal', () => {
let deps: AppDeps | null;
let deps: ActionsConnectorsContextValue;

beforeAll(async () => {
const mocks = coreMock.createSetup();
const [
{
chrome,
docLinks,
application: { capabilities },
},
] = await mocks.getStartServices();
deps = {
chrome,
docLinks,
dataPlugin: dataPluginMock.createStartContract(),
charts: chartPluginMock.createStartContract(),
toastNotifications: mocks.notifications.toasts,
injectedMetadata: mocks.injectedMetadata,
http: mocks.http,
uiSettings: mocks.uiSettings,
capabilities: {
...capabilities,
actions: {
Expand All @@ -43,9 +33,7 @@ describe('connector_add_modal', () => {
show: true,
},
},
setBreadcrumbs: jest.fn(),
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: {} as any,
};
});
it('renders connector modal form if addModalVisible is true', () => {
Expand Down Expand Up @@ -80,7 +68,7 @@ describe('connector_add_modal', () => {
actionType={actionType}
http={deps.http}
actionTypeRegistry={deps.actionTypeRegistry}
alertTypeRegistry={deps.alertTypeRegistry}
alertTypeRegistry={{} as any}
toastNotifications={deps.toastNotifications}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { actionTypeRegistryMock } from '../../action_type_registry.mock';
import { ValidationResult } from '../../../types';
import { ConnectorEditFlyout } from './connector_edit_flyout';
import { AppContextProvider } from '../../app_context';
import { chartPluginMock } from '../../../../../../../src/plugins/charts/public/mocks';
import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks';

const actionTypeRegistry = actionTypeRegistryMock.create();
let deps: any;
Expand All @@ -22,18 +20,11 @@ describe('connector_edit_flyout', () => {
const mockes = coreMock.createSetup();
const [
{
chrome,
docLinks,
application: { capabilities },
},
] = await mockes.getStartServices();
deps = {
chrome,
docLinks,
dataPlugin: dataPluginMock.createStartContract(),
charts: chartPluginMock.createStartContract(),
toastNotifications: mockes.notifications.toasts,
injectedMetadata: mockes.injectedMetadata,
http: mockes.http,
uiSettings: mockes.uiSettings,
capabilities: {
Expand All @@ -44,7 +35,6 @@ describe('connector_edit_flyout', () => {
show: true,
},
},
setBreadcrumbs: jest.fn(),
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: {} as any,
};
Expand Down Expand Up @@ -83,6 +73,7 @@ describe('connector_edit_flyout', () => {
<ActionsConnectorsContextProvider
value={{
http: deps.http,
toastNotifications: deps.toastNotifications,
capabilities: deps.capabilities,
actionTypeRegistry: deps.actionTypeRegistry,
reloadConnectors: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('alert_edit', () => {
let deps: any;
let wrapper: ReactWrapper<any>;

beforeAll(async () => {
async function setup() {
const mockes = coreMock.createSetup();
deps = {
toastNotifications: mockes.notifications.toasts,
Expand Down Expand Up @@ -122,9 +122,10 @@ describe('alert_edit', () => {
await nextTick();
wrapper.update();
});
});
}

it('renders alert add flyout', () => {
it('renders alert add flyout', async () => {
await setup();
expect(wrapper.find('[data-test-subj="editAlertFlyoutTitle"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="saveEditedAlertButton"]').exists()).toBeTruthy();
});
Expand Down
Loading

0 comments on commit 3f61937

Please sign in to comment.