mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -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 () => {
|
||||
useCaseConfigureMock.mockImplementation(() => ({
|
||||
...useCaseConfigureResponse,
|
||||
|
|
|
@ -34,6 +34,7 @@ interface Props {
|
|||
children?: JSX.Element | JSX.Element[];
|
||||
hideConnectorServiceNowSir?: boolean;
|
||||
onSuccess?: (theCase: Case) => Promise<void>;
|
||||
syncAlertsDefaultValue?: boolean;
|
||||
}
|
||||
|
||||
export const FormContext: React.FC<Props> = ({
|
||||
|
@ -42,6 +43,7 @@ export const FormContext: React.FC<Props> = ({
|
|||
children,
|
||||
hideConnectorServiceNowSir,
|
||||
onSuccess,
|
||||
syncAlertsDefaultValue = true,
|
||||
}) => {
|
||||
const { connectors, loading: isLoadingConnectors } = useConnectors();
|
||||
const owner = useOwnerContext();
|
||||
|
@ -51,7 +53,12 @@ export const FormContext: React.FC<Props> = ({
|
|||
|
||||
const submitCase = useCallback(
|
||||
async (
|
||||
{ connectorId: dataConnectorId, fields, syncAlerts = true, ...dataWithoutConnectorId },
|
||||
{
|
||||
connectorId: dataConnectorId,
|
||||
fields,
|
||||
syncAlerts = syncAlertsDefaultValue,
|
||||
...dataWithoutConnectorId
|
||||
},
|
||||
isValid
|
||||
) => {
|
||||
if (isValid) {
|
||||
|
@ -94,6 +101,7 @@ export const FormContext: React.FC<Props> = ({
|
|||
onSuccess,
|
||||
postComment,
|
||||
pushCaseToExternalService,
|
||||
syncAlertsDefaultValue,
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -58,6 +58,8 @@ const CreateCaseComponent = ({
|
|||
caseType={caseType}
|
||||
hideConnectorServiceNowSir={hideConnectorServiceNowSir}
|
||||
onSuccess={onSuccess}
|
||||
// if we are disabling alerts, then we should not sync alerts
|
||||
syncAlertsDefaultValue={!disableAlerts}
|
||||
>
|
||||
<CreateCaseForm
|
||||
hideConnectorServiceNowSir={hideConnectorServiceNowSir}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue