@@ -426,4 +426,72 @@ describe('AgentActivityFlyout', () => {
426426 . textContent ?. replace ( / \s / g, '' )
427427 ) . toContain ( 'Completed Sep 15, 2022 12:00 PM' . replace ( / \s / g, '' ) ) ;
428428 } ) ;
429+
430+ it ( 'should render agent activity for policy change no agents' , ( ) => {
431+ const mockActionStatuses = [
432+ {
433+ actionId : 'action8' ,
434+ nbAgentsActionCreated : 0 ,
435+ nbAgentsAck : 0 ,
436+ type : 'POLICY_CHANGE' ,
437+ nbAgentsActioned : 0 ,
438+ status : 'COMPLETE' ,
439+ expiration : '2099-09-16T10:00:00.000Z' ,
440+ policyId : 'policy1' ,
441+ revision : 2 ,
442+ creationTime : '2022-09-15T10:00:00.000Z' ,
443+ nbAgentsFailed : 0 ,
444+ completionTime : '2022-09-15T11:00:00.000Z' ,
445+ } ,
446+ ] ;
447+ mockUseActionStatus . mockReturnValue ( {
448+ currentActions : mockActionStatuses ,
449+ abortUpgrade : mockAbortUpgrade ,
450+ isFirstLoading : true ,
451+ } ) ;
452+ const result = renderComponent ( ) ;
453+
454+ expect ( result . container . querySelector ( '[data-test-subj="statusTitle"]' ) ! . textContent ) . toEqual (
455+ 'Policy changed'
456+ ) ;
457+ expect (
458+ result . container
459+ . querySelector ( '[data-test-subj="statusDescription"]' ) !
460+ . textContent ?. replace ( / \s / g, '' )
461+ ) . toContain ( 'Policy1 changed to revision 2 at Sep 15, 2022 10:00 AM.' . replace ( / \s / g, '' ) ) ;
462+ } ) ;
463+
464+ it ( 'should render agent activity for policy change with agents' , ( ) => {
465+ const mockActionStatuses = [
466+ {
467+ actionId : 'action8' ,
468+ nbAgentsActionCreated : 3 ,
469+ nbAgentsAck : 3 ,
470+ type : 'POLICY_CHANGE' ,
471+ nbAgentsActioned : 3 ,
472+ status : 'COMPLETE' ,
473+ expiration : '2099-09-16T10:00:00.000Z' ,
474+ policyId : 'policy1' ,
475+ revision : 2 ,
476+ creationTime : '2022-09-15T10:00:00.000Z' ,
477+ nbAgentsFailed : 0 ,
478+ completionTime : '2022-09-15T11:00:00.000Z' ,
479+ } ,
480+ ] ;
481+ mockUseActionStatus . mockReturnValue ( {
482+ currentActions : mockActionStatuses ,
483+ abortUpgrade : mockAbortUpgrade ,
484+ isFirstLoading : true ,
485+ } ) ;
486+ const result = renderComponent ( ) ;
487+
488+ expect ( result . container . querySelector ( '[data-test-subj="statusTitle"]' ) ! . textContent ) . toEqual (
489+ '3 agents applied policy change'
490+ ) ;
491+ expect (
492+ result . container
493+ . querySelector ( '[data-test-subj="statusDescription"]' ) !
494+ . textContent ?. replace ( / \s / g, '' )
495+ ) . toContain ( 'Policy1 changed to revision 2 at Sep 15, 2022 10:00 AM.' . replace ( / \s / g, '' ) ) ;
496+ } ) ;
429497} ) ;
0 commit comments