Disable sync toggle in flyout (#110714)
This commit is contained in:
parent
b77ca9392b
commit
31d335868e
|
@ -7,7 +7,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { act, waitFor } from '@testing-library/react';
|
||||
import { act, render, waitFor } from '@testing-library/react';
|
||||
|
||||
import { useForm, Form, FormHook } from '../../common/shared_imports';
|
||||
import { useGetTags } from '../../containers/use_get_tags';
|
||||
|
@ -119,4 +119,14 @@ describe('CreateCaseForm', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('hides the sync alerts toggle', () => {
|
||||
const { queryByText } = render(
|
||||
<MockHookWrapperComponent>
|
||||
<CreateCaseForm disableAlerts />
|
||||
</MockHookWrapperComponent>
|
||||
);
|
||||
|
||||
expect(queryByText('Sync alert')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -53,7 +53,6 @@ export const CreateCaseForm: React.FC<Props> = React.memo(
|
|||
withSteps = true,
|
||||
}) => {
|
||||
const { isSubmitting } = useFormContext();
|
||||
|
||||
const firstStep = useMemo(
|
||||
() => ({
|
||||
title: i18n.STEP_ONE_TITLE,
|
||||
|
|
|
@ -10,16 +10,13 @@ import { mount } from 'enzyme';
|
|||
import { EuiThemeProvider } from '../../../../../../../../src/plugins/kibana_react/common';
|
||||
|
||||
import { CreateCaseFlyout } from './flyout';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import { useKibana } from '../../../../utils/kibana_react';
|
||||
import { CASES_OWNER } from '../constants';
|
||||
|
||||
jest.mock('../../../../utils/kibana_react');
|
||||
|
||||
jest.mock('../../../../utils/kibana_react', () => ({
|
||||
useKibana: () => ({
|
||||
services: {
|
||||
cases: {
|
||||
getCreateCase: jest.fn(),
|
||||
},
|
||||
},
|
||||
}),
|
||||
}));
|
||||
const onCloseFlyout = jest.fn();
|
||||
const onSuccess = jest.fn();
|
||||
const defaultProps = {
|
||||
|
@ -28,8 +25,17 @@ const defaultProps = {
|
|||
};
|
||||
|
||||
describe('CreateCaseFlyout', () => {
|
||||
const mockCreateCase = jest.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
(useKibana as jest.Mock).mockReturnValue({
|
||||
services: {
|
||||
cases: {
|
||||
getCreateCase: mockCreateCase,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('renders', () => {
|
||||
|
@ -52,4 +58,22 @@ describe('CreateCaseFlyout', () => {
|
|||
wrapper.find(`[data-test-subj='euiFlyoutCloseButton']`).first().simulate('click');
|
||||
expect(onCloseFlyout).toBeCalled();
|
||||
});
|
||||
|
||||
it('does not show the sync alerts toggle', () => {
|
||||
render(
|
||||
<EuiThemeProvider>
|
||||
<CreateCaseFlyout {...defaultProps} />
|
||||
</EuiThemeProvider>
|
||||
);
|
||||
|
||||
expect(mockCreateCase).toBeCalledTimes(1);
|
||||
expect(mockCreateCase).toBeCalledWith({
|
||||
onCancel: onCloseFlyout,
|
||||
onSuccess,
|
||||
afterCaseCreated: undefined,
|
||||
withSteps: false,
|
||||
owner: [CASES_OWNER],
|
||||
disableAlerts: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -68,6 +68,7 @@ function CreateCaseFlyoutComponent({
|
|||
onSuccess,
|
||||
withSteps: false,
|
||||
owner: [CASES_OWNER],
|
||||
disableAlerts: true,
|
||||
})}
|
||||
</FormWrapper>
|
||||
</StyledEuiFlyoutBody>
|
||||
|
|
|
@ -26,6 +26,7 @@ export interface AddToCaseActionProps {
|
|||
} | null;
|
||||
appId: string;
|
||||
onClose?: Function;
|
||||
disableAlerts?: boolean;
|
||||
}
|
||||
|
||||
const AddToCaseActionComponent: React.FC<AddToCaseActionProps> = ({
|
||||
|
@ -35,6 +36,7 @@ const AddToCaseActionComponent: React.FC<AddToCaseActionProps> = ({
|
|||
casePermissions,
|
||||
appId,
|
||||
onClose,
|
||||
disableAlerts,
|
||||
}) => {
|
||||
const eventId = event?.ecs._id ?? '';
|
||||
const eventIndex = event?.ecs._index ?? '';
|
||||
|
@ -104,6 +106,7 @@ const AddToCaseActionComponent: React.FC<AddToCaseActionProps> = ({
|
|||
onSuccess={onCaseSuccess}
|
||||
useInsertTimeline={useInsertTimeline}
|
||||
appId={appId}
|
||||
disableAlerts={disableAlerts}
|
||||
/>
|
||||
)}
|
||||
{isAllCaseModalOpen && cases.getAllCasesSelectorModal(getAllCasesSelectorModalProps)}
|
||||
|
|
|
@ -20,6 +20,7 @@ export interface CreateCaseModalProps {
|
|||
onSuccess: (theCase: Case) => Promise<void>;
|
||||
useInsertTimeline?: Function;
|
||||
appId: string;
|
||||
disableAlerts?: boolean;
|
||||
}
|
||||
|
||||
const StyledFlyout = styled(EuiFlyout)`
|
||||
|
@ -53,6 +54,7 @@ const CreateCaseFlyoutComponent: React.FC<CreateCaseModalProps> = ({
|
|||
onCloseFlyout,
|
||||
onSuccess,
|
||||
appId,
|
||||
disableAlerts,
|
||||
}) => {
|
||||
const { cases } = useKibana<TimelinesStartServices>().services;
|
||||
const createCaseProps = useMemo(() => {
|
||||
|
@ -62,8 +64,9 @@ const CreateCaseFlyoutComponent: React.FC<CreateCaseModalProps> = ({
|
|||
onSuccess,
|
||||
withSteps: false,
|
||||
owner: [appId],
|
||||
disableAlerts,
|
||||
};
|
||||
}, [afterCaseCreated, onCloseFlyout, onSuccess, appId]);
|
||||
}, [afterCaseCreated, onCloseFlyout, onSuccess, appId, disableAlerts]);
|
||||
return (
|
||||
<StyledFlyout onClose={onCloseFlyout} data-test-subj="create-case-flyout">
|
||||
<EuiFlyoutHeader hasBorder>
|
||||
|
|
|
@ -411,7 +411,7 @@ const TGridStandaloneComponent: React.FC<TGridStandaloneProps> = ({
|
|||
</EventsContainerLoading>
|
||||
</>
|
||||
) : null}
|
||||
<AddToCaseAction {...addToCaseActionProps} />
|
||||
<AddToCaseAction {...addToCaseActionProps} disableAlerts />
|
||||
</AlertsTableWrapper>
|
||||
</InspectButtonContainer>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue