[SIEM][CASE] Fix callout messages appearance (#67303)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
d9ac0489a3
commit
0712741bb3
4 changed files with 81 additions and 3 deletions
|
@ -60,6 +60,43 @@ describe('CaseCallOut ', () => {
|
|||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('it applies the correct color to button', () => {
|
||||
const props = {
|
||||
...defaultProps,
|
||||
messages: [
|
||||
{
|
||||
...defaultProps,
|
||||
description: <p>{'one'}</p>,
|
||||
errorType: 'danger' as 'primary' | 'success' | 'warning' | 'danger',
|
||||
},
|
||||
{
|
||||
...defaultProps,
|
||||
description: <p>{'two'}</p>,
|
||||
errorType: 'success' as 'primary' | 'success' | 'warning' | 'danger',
|
||||
},
|
||||
{
|
||||
...defaultProps,
|
||||
description: <p>{'three'}</p>,
|
||||
errorType: 'primary' as 'primary' | 'success' | 'warning' | 'danger',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const wrapper = mount(<CaseCallOut {...props} />);
|
||||
|
||||
expect(wrapper.find(`[data-test-subj="callout-dismiss-danger"]`).first().prop('color')).toBe(
|
||||
'danger'
|
||||
);
|
||||
|
||||
expect(wrapper.find(`[data-test-subj="callout-dismiss-success"]`).first().prop('color')).toBe(
|
||||
'secondary'
|
||||
);
|
||||
|
||||
expect(wrapper.find(`[data-test-subj="callout-dismiss-primary"]`).first().prop('color')).toBe(
|
||||
'primary'
|
||||
);
|
||||
});
|
||||
|
||||
it('Dismisses callout', () => {
|
||||
const props = {
|
||||
...defaultProps,
|
||||
|
|
|
@ -66,7 +66,7 @@ const CaseCallOutComponent = ({ title, message, messages }: CaseCallOutProps) =>
|
|||
)}
|
||||
<EuiButton
|
||||
data-test-subj={`callout-dismiss-${key}`}
|
||||
color="primary"
|
||||
color={key === 'success' ? 'secondary' : key}
|
||||
onClick={handleCallOut}
|
||||
>
|
||||
{i18n.DISMISS_CALLOUT}
|
||||
|
|
|
@ -123,7 +123,27 @@ describe('usePushToService', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('Displays message when user does not have a connector configured', async () => {
|
||||
it('Displays message when user does not have any connector configured', async () => {
|
||||
await act(async () => {
|
||||
const { result, waitForNextUpdate } = renderHook<UsePushToService, ReturnUsePushToService>(
|
||||
() =>
|
||||
usePushToService({
|
||||
...defaultArgs,
|
||||
connectors: [],
|
||||
caseConnectorId: 'none',
|
||||
}),
|
||||
{
|
||||
wrapper: ({ children }) => <TestProviders> {children}</TestProviders>,
|
||||
}
|
||||
);
|
||||
await waitForNextUpdate();
|
||||
const errorsMsg = result.current.pushCallouts?.props.messages;
|
||||
expect(errorsMsg).toHaveLength(1);
|
||||
expect(errorsMsg[0].title).toEqual(i18n.PUSH_DISABLE_BY_NO_CONFIG_TITLE);
|
||||
});
|
||||
});
|
||||
|
||||
it('Displays message when user does have a connector but is configured to none', async () => {
|
||||
await act(async () => {
|
||||
const { result, waitForNextUpdate } = renderHook<UsePushToService, ReturnUsePushToService>(
|
||||
() =>
|
||||
|
@ -162,6 +182,27 @@ describe('usePushToService', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('Displays message when connector is deleted with empty connectors', async () => {
|
||||
await act(async () => {
|
||||
const { result, waitForNextUpdate } = renderHook<UsePushToService, ReturnUsePushToService>(
|
||||
() =>
|
||||
usePushToService({
|
||||
...defaultArgs,
|
||||
connectors: [],
|
||||
caseConnectorId: 'not-exist',
|
||||
isValidConnector: false,
|
||||
}),
|
||||
{
|
||||
wrapper: ({ children }) => <TestProviders> {children}</TestProviders>,
|
||||
}
|
||||
);
|
||||
await waitForNextUpdate();
|
||||
const errorsMsg = result.current.pushCallouts?.props.messages;
|
||||
expect(errorsMsg).toHaveLength(1);
|
||||
expect(errorsMsg[0].title).toEqual(i18n.PUSH_DISABLE_BY_NO_CASE_CONFIG_TITLE);
|
||||
});
|
||||
});
|
||||
|
||||
it('Displays message when case is closed', async () => {
|
||||
await act(async () => {
|
||||
const { result, waitForNextUpdate } = renderHook<UsePushToService, ReturnUsePushToService>(
|
||||
|
|
|
@ -75,7 +75,7 @@ export const usePushToService = ({
|
|||
if (actionLicense != null && !actionLicense.enabledInLicense) {
|
||||
errors = [...errors, getLicenseError()];
|
||||
}
|
||||
if (connectors.length === 0 && !loadingLicense) {
|
||||
if (connectors.length === 0 && caseConnectorId === 'none' && !loadingLicense) {
|
||||
errors = [
|
||||
...errors,
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue