mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Cases][Observability] Do not sync alerts status with case status (#114318)
* set sync status according to disable alerts * Adding test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
c8a0108269
commit
badc77828e
3 changed files with 34 additions and 1 deletions
|
@ -239,6 +239,29 @@ describe('Create case', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set sync alerts to false when the sync setting is passed in as false and alerts are disabled', async () => {
|
||||||
|
useConnectorsMock.mockReturnValue({
|
||||||
|
...sampleConnectorData,
|
||||||
|
connectors: connectorsMock,
|
||||||
|
});
|
||||||
|
|
||||||
|
const wrapper = mount(
|
||||||
|
<TestProviders>
|
||||||
|
<FormContext onSuccess={onFormSubmitSuccess} syncAlertsDefaultValue={false}>
|
||||||
|
<CreateCaseForm {...defaultCreateCaseForm} disableAlerts={true} />
|
||||||
|
<SubmitCaseButton />
|
||||||
|
</FormContext>
|
||||||
|
</TestProviders>
|
||||||
|
);
|
||||||
|
|
||||||
|
fillForm(wrapper);
|
||||||
|
wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
|
||||||
|
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(postCase).toBeCalledWith({ ...sampleData, settings: { syncAlerts: false } })
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('it should select the default connector set in the configuration', async () => {
|
it('it should select the default connector set in the configuration', async () => {
|
||||||
useCaseConfigureMock.mockImplementation(() => ({
|
useCaseConfigureMock.mockImplementation(() => ({
|
||||||
...useCaseConfigureResponse,
|
...useCaseConfigureResponse,
|
||||||
|
|
|
@ -34,6 +34,7 @@ interface Props {
|
||||||
children?: JSX.Element | JSX.Element[];
|
children?: JSX.Element | JSX.Element[];
|
||||||
hideConnectorServiceNowSir?: boolean;
|
hideConnectorServiceNowSir?: boolean;
|
||||||
onSuccess?: (theCase: Case) => Promise<void>;
|
onSuccess?: (theCase: Case) => Promise<void>;
|
||||||
|
syncAlertsDefaultValue?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FormContext: React.FC<Props> = ({
|
export const FormContext: React.FC<Props> = ({
|
||||||
|
@ -42,6 +43,7 @@ export const FormContext: React.FC<Props> = ({
|
||||||
children,
|
children,
|
||||||
hideConnectorServiceNowSir,
|
hideConnectorServiceNowSir,
|
||||||
onSuccess,
|
onSuccess,
|
||||||
|
syncAlertsDefaultValue = true,
|
||||||
}) => {
|
}) => {
|
||||||
const { connectors, loading: isLoadingConnectors } = useConnectors();
|
const { connectors, loading: isLoadingConnectors } = useConnectors();
|
||||||
const owner = useOwnerContext();
|
const owner = useOwnerContext();
|
||||||
|
@ -51,7 +53,12 @@ export const FormContext: React.FC<Props> = ({
|
||||||
|
|
||||||
const submitCase = useCallback(
|
const submitCase = useCallback(
|
||||||
async (
|
async (
|
||||||
{ connectorId: dataConnectorId, fields, syncAlerts = true, ...dataWithoutConnectorId },
|
{
|
||||||
|
connectorId: dataConnectorId,
|
||||||
|
fields,
|
||||||
|
syncAlerts = syncAlertsDefaultValue,
|
||||||
|
...dataWithoutConnectorId
|
||||||
|
},
|
||||||
isValid
|
isValid
|
||||||
) => {
|
) => {
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
|
@ -94,6 +101,7 @@ export const FormContext: React.FC<Props> = ({
|
||||||
onSuccess,
|
onSuccess,
|
||||||
postComment,
|
postComment,
|
||||||
pushCaseToExternalService,
|
pushCaseToExternalService,
|
||||||
|
syncAlertsDefaultValue,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,8 @@ const CreateCaseComponent = ({
|
||||||
caseType={caseType}
|
caseType={caseType}
|
||||||
hideConnectorServiceNowSir={hideConnectorServiceNowSir}
|
hideConnectorServiceNowSir={hideConnectorServiceNowSir}
|
||||||
onSuccess={onSuccess}
|
onSuccess={onSuccess}
|
||||||
|
// if we are disabling alerts, then we should not sync alerts
|
||||||
|
syncAlertsDefaultValue={!disableAlerts}
|
||||||
>
|
>
|
||||||
<CreateCaseForm
|
<CreateCaseForm
|
||||||
hideConnectorServiceNowSir={hideConnectorServiceNowSir}
|
hideConnectorServiceNowSir={hideConnectorServiceNowSir}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue