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

[Cases] Adding deprecated icon to additional actions dropdown selectors #115287

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2c387e9
adding deprecated icon to the other actions list
jonathan-buttner Oct 15, 2021
b7ea813
Merge branch 'master' of github.com:elastic/kibana into connectors-de…
jonathan-buttner Oct 19, 2021
6c93aa5
Adding deprecated text to list view
jonathan-buttner Oct 20, 2021
9026520
Merge branch 'master' of github.com:elastic/kibana into connectors-de…
jonathan-buttner Oct 20, 2021
31ea456
Each action type can render the dropdown row
jonathan-buttner Oct 21, 2021
2acc4c6
Merge branch 'master' of github.com:elastic/kibana into connectors-de…
jonathan-buttner Oct 25, 2021
aa7b647
Refactoring and fixing todos
jonathan-buttner Oct 25, 2021
0403c15
Fixing jest tests
jonathan-buttner Oct 25, 2021
2cbbace
Adding and fixing other tests
jonathan-buttner Oct 25, 2021
6c71628
Fixing functional test
jonathan-buttner Oct 25, 2021
02a48f4
Merge branch 'master' of github.com:elastic/kibana into connectors-de…
jonathan-buttner Oct 26, 2021
1444fda
Merge branch 'master' into connectors-deprecated-icon
kibanamachine Oct 26, 2021
2d60ec6
Fixing tests
jonathan-buttner Oct 26, 2021
4e18f13
Merge branch 'connectors-deprecated-icon' of github.com:jonathan-butt…
jonathan-buttner Oct 26, 2021
58778e9
Merge branch 'master' into connectors-deprecated-icon
kibanamachine Oct 26, 2021
4186801
Merge branch 'master' into connectors-deprecated-icon
kibanamachine Oct 27, 2021
6abb14f
Merge branch 'master' into connectors-deprecated-icon
kibanamachine Oct 27, 2021
0e462f6
Adjusting text to match cases
jonathan-buttner Oct 27, 2021
bb4de03
Merge branch 'master' into connectors-deprecated-icon
kibanamachine Oct 28, 2021
6df58da
Merge branch 'main' of github.com:elastic/kibana into connectors-depr…
jonathan-buttner Nov 15, 2021
45079ef
Fixing tests
jonathan-buttner Nov 15, 2021
ae9a377
Merge branch 'main' of github.com:elastic/kibana into connectors-depr…
jonathan-buttner Nov 19, 2021
5ba6fa1
Addressing pr feedback
jonathan-buttner Nov 22, 2021
c8d88b3
Merge branch 'main' of github.com:elastic/kibana into connectors-depr…
jonathan-buttner Nov 22, 2021
1c706b8
Renaming connector dropdown to selection
jonathan-buttner Nov 22, 2021
fa0f045
Fixing type errors
jonathan-buttner Nov 22, 2021
3f02f8e
Fixing type error
jonathan-buttner Nov 22, 2021
fc8bb6d
Fixing translation error
jonathan-buttner Nov 22, 2021
b308867
Fixing test
jonathan-buttner Nov 23, 2021
4981da4
Merge branch 'main' into connectors-deprecated-icon
kibanamachine Nov 24, 2021
02bf882
Merge branch 'main' into connectors-deprecated-icon
kibanamachine Nov 29, 2021
09a028f
Merge branch 'main' of github.com:elastic/kibana into connectors-depr…
jonathan-buttner Dec 1, 2021
13536d4
Merge branch 'connectors-deprecated-icon' of github.com:jonathan-butt…
jonathan-buttner Dec 1, 2021
0ed891f
Addressing ux feedback and using ComboBox
jonathan-buttner Dec 2, 2021
10772b9
Merge branch 'main' of github.com:elastic/kibana into connectors-depr…
jonathan-buttner Dec 3, 2021
383d05c
Merge branch 'main' into connectors-deprecated-icon
kibanamachine Dec 6, 2021
09145c9
Extracting customConnectorSelectItem to an interface
jonathan-buttner Dec 7, 2021
115e917
Merge branch 'connectors-deprecated-icon' of github.com:jonathan-butt…
jonathan-buttner Dec 7, 2021
d96a447
Merge branch 'main' of github.com:elastic/kibana into connectors-depr…
jonathan-buttner Dec 7, 2021
51cb6dc
Merge branch 'main' into connectors-deprecated-icon
kibanamachine Dec 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
import * as React from 'react';
import { mountWithIntl, nextTick } from '@kbn/test/jest';

import { ActionTypeForm } from './action_type_form';
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
import {
Expand All @@ -17,6 +18,7 @@ import {
} from '../../../types';
import { act } from 'react-dom/test-utils';
import { EuiFieldText } from '@elastic/eui';
import { EuiThemeProvider } from '../../../../../../../src/plugins/kibana_react/common';
import { DefaultActionParams } from '../../lib/get_defaults_for_action_params';

jest.mock('../../../common/lib/kibana');
Expand All @@ -38,7 +40,7 @@ describe('action_type_form', () => {
},
}));

it('calls "setActionParamsProperty" to set the default value for the empty dedupKey', async () => {
beforeEach(() => {
jonathan-buttner marked this conversation as resolved.
Show resolved Hide resolved
const actionType = actionTypeRegistryMock.createMockActionTypeModel({
id: '.pagerduty',
iconClass: 'test',
Expand All @@ -54,22 +56,101 @@ describe('action_type_form', () => {
actionParamsFields: mockedActionParamsFields,
});
actionTypeRegistry.get.mockReturnValue(actionType);
});

describe('deprecated icon', () => {
const notDeprecatedConnector = {
actionTypeId: '.pagerduty',
config: {
apiUrl: 'http:\\test',
},
id: 'test',
isPreconfigured: false,
name: 'test name',
secrets: {},
};

const actionItem = {
id: 'test',
actionTypeId: '.pagerduty',
group: 'recovered',
params: {
eventAction: 'recovered',
dedupKey: undefined,
summary: '2323',
source: 'source',
severity: '1',
timestamp: new Date().toISOString(),
component: 'test',
group: 'group',
class: 'test class',
},
};

it('renders the deprecated warning icon for deprecated connectors', async () => {
const deprecatedConnector = {
...notDeprecatedConnector,
config: { ...notDeprecatedConnector.config, isLegacy: true },
};

const wrapper = mountWithIntl(
getActionTypeForm({
actionConnector: deprecatedConnector,
connectors: [deprecatedConnector],
actionItem,
})
);

// Wait for active space to resolve before requesting the component to update
await act(async () => {
await nextTick();
wrapper.update();
});

expect(
wrapper.find('[data-test-subj="deprecated-connector-icon-test"]').exists()
).toBeTruthy();
});

it('does not render the deprecated warning icon for non-deprecated connectors', async () => {
const wrapper = mountWithIntl(
getActionTypeForm({
actionConnector: notDeprecatedConnector,
connectors: [notDeprecatedConnector],
actionItem,
})
);

// Wait for active space to resolve before requesting the component to update
await act(async () => {
await nextTick();
wrapper.update();
});

expect(
wrapper.find('[data-test-subj="deprecated-connector-icon-test"]').exists()
).toBeFalsy();
});
});

it('calls "setActionParamsProperty" to set the default value for the empty dedupKey', async () => {
const wrapper = mountWithIntl(
getActionTypeForm(1, undefined, {
id: '123',
actionTypeId: '.pagerduty',
group: 'recovered',
params: {
eventAction: 'recovered',
dedupKey: undefined,
summary: '2323',
source: 'source',
severity: '1',
timestamp: new Date().toISOString(),
component: 'test',
group: 'group',
class: 'test class',
getActionTypeForm({
jonathan-buttner marked this conversation as resolved.
Show resolved Hide resolved
actionItem: {
id: '123',
actionTypeId: '.pagerduty',
group: 'recovered',
params: {
eventAction: 'recovered',
dedupKey: undefined,
summary: '2323',
source: 'source',
severity: '1',
timestamp: new Date().toISOString(),
component: 'test',
group: 'group',
class: 'test class',
},
},
})
);
Expand All @@ -88,37 +169,24 @@ describe('action_type_form', () => {
});

it('does not call "setActionParamsProperty" because dedupKey is not empty', async () => {
const actionType = actionTypeRegistryMock.createMockActionTypeModel({
id: '.pagerduty',
iconClass: 'test',
selectMessage: 'test',
validateConnector: (): Promise<ConnectorValidationResult<unknown, unknown>> => {
return Promise.resolve({});
},
validateParams: (): Promise<GenericValidationResult<unknown>> => {
const validationResult = { errors: {} };
return Promise.resolve(validationResult);
},
actionConnectorFields: null,
actionParamsFields: mockedActionParamsFields,
});
actionTypeRegistry.get.mockReturnValue(actionType);

const wrapper = mountWithIntl(
getActionTypeForm(1, undefined, {
id: '123',
actionTypeId: '.pagerduty',
group: 'recovered',
params: {
eventAction: 'recovered',
dedupKey: '232323',
summary: '2323',
source: 'source',
severity: '1',
timestamp: new Date().toISOString(),
component: 'test',
group: 'group',
class: 'test class',
getActionTypeForm({
jonathan-buttner marked this conversation as resolved.
Show resolved Hide resolved
index: 1,
actionItem: {
id: '123',
actionTypeId: '.pagerduty',
group: 'recovered',
params: {
eventAction: 'recovered',
dedupKey: '232323',
summary: '2323',
source: 'source',
severity: '1',
timestamp: new Date().toISOString(),
component: 'test',
group: 'group',
class: 'test class',
},
},
})
);
Expand All @@ -135,18 +203,29 @@ describe('action_type_form', () => {
});
});

function getActionTypeForm(
index?: number,
actionConnector?: ActionConnector<Record<string, unknown>, Record<string, unknown>>,
actionItem?: AlertAction,
defaultActionGroupId?: string,
connectors?: Array<ActionConnector<Record<string, unknown>, Record<string, unknown>>>,
actionTypeIndex?: Record<string, ActionType>,
defaultParams?: DefaultActionParams,
onAddConnector?: () => void,
onDeleteAction?: () => void,
onConnectorSelected?: (id: string) => void
) {
function getActionTypeForm({
jonathan-buttner marked this conversation as resolved.
Show resolved Hide resolved
index,
actionConnector,
actionItem,
defaultActionGroupId,
connectors,
actionTypeIndex,
defaultParams,
onAddConnector,
onDeleteAction,
onConnectorSelected,
}: {
index?: number;
actionConnector?: ActionConnector<Record<string, unknown>, Record<string, unknown>>;
actionItem?: AlertAction;
defaultActionGroupId?: string;
connectors?: Array<ActionConnector<Record<string, unknown>, Record<string, unknown>>>;
actionTypeIndex?: Record<string, ActionType>;
defaultParams?: DefaultActionParams;
onAddConnector?: () => void;
onDeleteAction?: () => void;
onConnectorSelected?: (id: string) => void;
}) {
const actionConnectorDefault = {
actionTypeId: '.pagerduty',
config: {
Expand Down Expand Up @@ -213,19 +292,21 @@ function getActionTypeForm(
eventAction: 'resolve',
};
return (
<ActionTypeForm
actionConnector={actionConnector ?? actionConnectorDefault}
actionItem={actionItem ?? actionItemDefault}
connectors={connectors ?? connectorsDefault}
onAddConnector={onAddConnector ?? jest.fn()}
onDeleteAction={onDeleteAction ?? jest.fn()}
onConnectorSelected={onConnectorSelected ?? jest.fn()}
defaultActionGroupId={defaultActionGroupId ?? 'default'}
setActionParamsProperty={jest.fn()}
index={index ?? 1}
actionTypesIndex={actionTypeIndex ?? actionTypeIndexDefault}
defaultParams={defaultParams ?? defaultParamsDefault}
actionTypeRegistry={actionTypeRegistry}
/>
<EuiThemeProvider>
jonathan-buttner marked this conversation as resolved.
Show resolved Hide resolved
<ActionTypeForm
actionConnector={actionConnector ?? actionConnectorDefault}
actionItem={actionItem ?? actionItemDefault}
connectors={connectors ?? connectorsDefault}
onAddConnector={onAddConnector ?? jest.fn()}
onDeleteAction={onDeleteAction ?? jest.fn()}
onConnectorSelected={onConnectorSelected ?? jest.fn()}
defaultActionGroupId={defaultActionGroupId ?? 'default'}
setActionParamsProperty={jest.fn()}
index={index ?? 1}
actionTypesIndex={actionTypeIndex ?? actionTypeIndexDefault}
defaultParams={defaultParams ?? defaultParamsDefault}
actionTypeRegistry={actionTypeRegistry}
/>
</EuiThemeProvider>
);
}
Loading