File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
x-pack/legacy/plugins/alerting/server Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -883,7 +883,6 @@ describe('enable()', () => {
883883 schedule : { interval : '10s' } ,
884884 alertTypeId : '2' ,
885885 enabled : true ,
886- scheduledTaskId : 'task-123' ,
887886 updatedBy : 'elastic' ,
888887 apiKey : null ,
889888 apiKeyOwner : null ,
@@ -892,6 +891,9 @@ describe('enable()', () => {
892891 version : '123' ,
893892 }
894893 ) ;
894+ expect ( savedObjectsClient . update ) . toHaveBeenCalledWith ( 'alert' , '1' , {
895+ scheduledTaskId : 'task-123' ,
896+ } ) ;
895897 expect ( taskManager . schedule ) . toHaveBeenCalledWith ( {
896898 taskType : `alerting:2` ,
897899 params : {
@@ -964,7 +966,6 @@ describe('enable()', () => {
964966 schedule : { interval : '10s' } ,
965967 alertTypeId : '2' ,
966968 enabled : true ,
967- scheduledTaskId : 'task-123' ,
968969 apiKey : Buffer . from ( '123:abc' ) . toString ( 'base64' ) ,
969970 apiKeyOwner : 'elastic' ,
970971 updatedBy : 'elastic' ,
@@ -973,6 +974,9 @@ describe('enable()', () => {
973974 version : '123' ,
974975 }
975976 ) ;
977+ expect ( savedObjectsClient . update ) . toHaveBeenCalledWith ( 'alert' , '1' , {
978+ scheduledTaskId : 'task-123' ,
979+ } ) ;
976980 expect ( taskManager . schedule ) . toHaveBeenCalledWith ( {
977981 taskType : `alerting:2` ,
978982 params : {
Original file line number Diff line number Diff line change @@ -362,7 +362,6 @@ export class AlertsClient {
362362 } ) ;
363363
364364 if ( attributes . enabled === false ) {
365- const scheduledTask = await this . scheduleAlert ( id , attributes . alertTypeId ) ;
366365 const username = await this . getUserName ( ) ;
367366 await this . savedObjectsClient . update (
368367 'alert' ,
@@ -372,11 +371,11 @@ export class AlertsClient {
372371 enabled : true ,
373372 ...this . apiKeyAsAlertAttributes ( await this . createAPIKey ( ) , username ) ,
374373 updatedBy : username ,
375-
376- scheduledTaskId : scheduledTask . id ,
377374 } ,
378375 { version }
379376 ) ;
377+ const scheduledTask = await this . scheduleAlert ( id , attributes . alertTypeId ) ;
378+ await this . savedObjectsClient . update ( 'alert' , id , { scheduledTaskId : scheduledTask . id } ) ;
380379 await this . invalidateApiKey ( { apiKey : attributes . apiKey } ) ;
381380 }
382381 }
You can’t perform that action at this time.
0 commit comments