[Security Solution] [Cases] Fix flaky jest test (moment.js) (#87518)

This commit is contained in:
Steph Milovic 2021-01-06 15:31:27 -07:00 committed by GitHub
parent 5d135359d7
commit e5cb55d377
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,7 +21,7 @@ import {
import * as api from './api';
import { CaseServices } from './use_get_case_user_actions';
import { CaseConnector, ConnectorTypes, CommentType } from '../../../../case/common/api';
import moment from 'moment';
jest.mock('./api');
jest.mock('../../common/components/link_to', () => {
const originalModule = jest.requireActual('../../common/components/link_to');
@ -31,9 +31,7 @@ jest.mock('../../common/components/link_to', () => {
useFormatUrl: jest.fn().mockReturnValue({ formatUrl: jest.fn(), search: 'urlSearch' }),
};
});
// FLAKY: https://github.com/elastic/kibana/issues/87541
describe.skip('usePostPushToService', () => {
describe('usePostPushToService', () => {
const abortCtrl = new AbortController();
const updateCase = jest.fn();
const formatUrl = jest.fn();
@ -307,6 +305,8 @@ describe.skip('usePostPushToService', () => {
});
it('formatServiceRequestData - Alert comment content', () => {
const mockDuration = moment.duration(1);
jest.spyOn(moment, 'duration').mockReturnValue(mockDuration);
formatUrl.mockReturnValue('https://app.com/detections');
const caseServices = sampleCaseServices;
const result = formatServiceRequestData({
@ -328,7 +328,7 @@ describe.skip('usePostPushToService', () => {
});
expect(result.comments![0].comment).toEqual(
'[Alert](https://app.com/detections?filters=!((%27$state%27:(store:appState),meta:(alias:!n,disabled:!f,key:_id,negate:!f,params:(query:alert-id-1),type:phrase),query:(match:(_id:(query:alert-id-1,type:phrase)))))&sourcerer=(default:!())&timerange=(global:(linkTo:!(timeline),timerange:(from:%272020-11-20T15:29:28.373Z%27,kind:absolute,to:%272020-11-20T15:35:28.373Z%27)),timeline:(linkTo:!(global),timerange:(from:%272020-11-20T15:29:28.373Z%27,kind:absolute,to:%272020-11-20T15:35:28.373Z%27)))) added to case.'
'[Alert](https://app.com/detections?filters=!((%27$state%27:(store:appState),meta:(alias:!n,disabled:!f,key:_id,negate:!f,params:(query:alert-id-1),type:phrase),query:(match:(_id:(query:alert-id-1,type:phrase)))))&sourcerer=(default:!())&timerange=(global:(linkTo:!(timeline),timerange:(from:%272020-11-20T15:35:28.372Z%27,kind:absolute,to:%272020-11-20T15:35:28.373Z%27)),timeline:(linkTo:!(global),timerange:(from:%272020-11-20T15:35:28.372Z%27,kind:absolute,to:%272020-11-20T15:35:28.373Z%27)))) added to case.'
);
});