@@ -17,6 +17,8 @@ import {
1717 basicParams ,
1818 userActions ,
1919 commentAlert ,
20+ commentAlertMultipleIds ,
21+ commentGeneratedAlert ,
2022} from './mock' ;
2123
2224import {
@@ -48,7 +50,7 @@ describe('utils', () => {
4850 {
4951 actionType : 'overwrite' ,
5052 key : 'short_description' ,
51- pipes : [ 'informationCreated' ] ,
53+ pipes : [ ] ,
5254 value : 'a title' ,
5355 } ,
5456 {
@@ -71,7 +73,7 @@ describe('utils', () => {
7173 {
7274 actionType : 'overwrite' ,
7375 key : 'short_description' ,
74- pipes : [ 'myTestPipe' ] ,
76+ pipes : [ ] ,
7577 value : 'a title' ,
7678 } ,
7779 {
@@ -98,7 +100,7 @@ describe('utils', () => {
98100 } ) ;
99101
100102 expect ( res ) . toEqual ( {
101- short_description : 'a title (created at 2020-03-13T08:34:53.450Z by Elastic User) ' ,
103+ short_description : 'a title' ,
102104 description : 'a description (created at 2020-03-13T08:34:53.450Z by Elastic User)' ,
103105 } ) ;
104106 } ) ;
@@ -122,13 +124,13 @@ describe('utils', () => {
122124 } ,
123125 fields,
124126 currentIncident : {
125- short_description : 'first title (created at 2020-03-13T08:34:53.450Z by Elastic User) ' ,
127+ short_description : 'first title' ,
126128 description : 'first description (created at 2020-03-13T08:34:53.450Z by Elastic User)' ,
127129 } ,
128130 } ) ;
129131
130132 expect ( res ) . toEqual ( {
131- short_description : 'a title (updated at 2020-03-15T08:34:53.450Z by Another User) ' ,
133+ short_description : 'a title' ,
132134 description :
133135 'first description (created at 2020-03-13T08:34:53.450Z by Elastic User) \r\na description (updated at 2020-03-15T08:34:53.450Z by Another User)' ,
134136 } ) ;
@@ -168,7 +170,7 @@ describe('utils', () => {
168170 } ) ;
169171
170172 expect ( res ) . toEqual ( {
171- short_description : 'a title (created at 2020-03-13T08:34:53.450Z by elastic) ' ,
173+ short_description : 'a title' ,
172174 description : 'a description (created at 2020-03-13T08:34:53.450Z by elastic)' ,
173175 } ) ;
174176 } ) ;
@@ -190,7 +192,7 @@ describe('utils', () => {
190192 } ) ;
191193
192194 expect ( res ) . toEqual ( {
193- short_description : 'a title (updated at 2020-03-15T08:34:53.450Z by anotherUser) ' ,
195+ short_description : 'a title' ,
194196 description : 'a description (updated at 2020-03-15T08:34:53.450Z by anotherUser)' ,
195197 } ) ;
196198 } ) ;
@@ -448,8 +450,7 @@ describe('utils', () => {
448450 labels : [ 'defacement' ] ,
449451 issueType : null ,
450452 parent : null ,
451- short_description :
452- 'Super Bad Security Issue (created at 2019-11-25T21:54:48.952Z by elastic)' ,
453+ short_description : 'Super Bad Security Issue' ,
453454 description :
454455 'This is a brand new case of a bad meanie defacing data (created at 2019-11-25T21:54:48.952Z by elastic)' ,
455456 externalId : null ,
@@ -504,15 +505,17 @@ describe('utils', () => {
504505 expect ( res . comments ) . toEqual ( [ ] ) ;
505506 } ) ;
506507
507- it ( 'it creates comments of type alert correctly' , async ( ) => {
508+ it ( 'it adds the total alert comments correctly' , async ( ) => {
508509 const res = await createIncident ( {
509510 actionsClient : actionsMock ,
510511 theCase : {
511512 ...theCase ,
512513 comments : [
513514 { ...commentObj , id : 'comment-user-1' } ,
514515 { ...commentAlert , id : 'comment-alert-1' } ,
515- { ...commentAlert , id : 'comment-alert-2' } ,
516+ {
517+ ...commentAlertMultipleIds ,
518+ } ,
516519 ] ,
517520 } ,
518521 // Remove second push
@@ -536,14 +539,36 @@ describe('utils', () => {
536539 commentId : 'comment-user-1' ,
537540 } ,
538541 {
539- comment :
540- 'Alert with ids alert-id-1 added to case (added at 2019-11-25T21:55:00.177Z by elastic)' ,
541- commentId : 'comment-alert-1' ,
542+ comment : 'Elastic Security Alerts attached to the case: 3' ,
542543 } ,
544+ ] ) ;
545+ } ) ;
546+
547+ it ( 'it removes alerts correctly' , async ( ) => {
548+ const res = await createIncident ( {
549+ actionsClient : actionsMock ,
550+ theCase : {
551+ ...theCase ,
552+ comments : [
553+ { ...commentObj , id : 'comment-user-1' } ,
554+ commentAlertMultipleIds ,
555+ commentGeneratedAlert ,
556+ ] ,
557+ } ,
558+ userActions,
559+ connector,
560+ mappings,
561+ alerts : [ ] ,
562+ } ) ;
563+
564+ expect ( res . comments ) . toEqual ( [
543565 {
544566 comment :
545- 'Alert with ids alert-id-1 added to case (added at 2019-11-25T21:55:00.177Z by elastic)' ,
546- commentId : 'comment-alert-2' ,
567+ 'Wow, good luck catching that bad meanie! (added at 2019-11-25T21:55:00.177Z by elastic)' ,
568+ commentId : 'comment-user-1' ,
569+ } ,
570+ {
571+ comment : 'Elastic Security Alerts attached to the case: 4' ,
547572 } ,
548573 ] ) ;
549574 } ) ;
@@ -578,8 +603,7 @@ describe('utils', () => {
578603 description :
579604 'fun description \r\nThis is a brand new case of a bad meanie defacing data (updated at 2019-11-25T21:54:48.952Z by elastic)' ,
580605 externalId : 'external-id' ,
581- short_description :
582- 'Super Bad Security Issue (updated at 2019-11-25T21:54:48.952Z by elastic)' ,
606+ short_description : 'Super Bad Security Issue' ,
583607 } ,
584608 comments : [ ] ,
585609 } ) ;
0 commit comments