@@ -706,20 +706,31 @@ describe('CIPE Notifications', () => {
706
706
) ;
707
707
} ) ;
708
708
709
- it ( 'should show regular error notification if an existing run fails and there is no AI fix after 5 minutes' , ( ) => {
709
+ it ( 'should show regular error notification when transitioning to no AI fix after 5 minutes' , ( ) => {
710
710
const sixMinutesAgo = Date . now ( ) - 1000 * 60 * 6 ;
711
+
712
+ // CIPE that was waiting for AI fix (within 5 minutes)
713
+ const waitingCipe : CIPEInfo [ ] = [
714
+ {
715
+ ...pipelineExamples . failWithAiFixesEnabled [ 0 ] ,
716
+ createdAt : tenMinutesAgo ,
717
+ completedAt : oneMinuteAgo , // Within 5 minutes
718
+ } ,
719
+ ] ;
720
+
721
+ // Same CIPE but now past 5 minutes
711
722
const failedCipe : CIPEInfo [ ] = [
712
723
{
713
724
...pipelineExamples . failWithAiFixesEnabled [ 0 ] ,
714
725
createdAt : tenMinutesAgo ,
715
- completedAt : sixMinutesAgo ,
726
+ completedAt : sixMinutesAgo , // Past 5 minutes
716
727
} ,
717
728
] ;
718
729
719
730
jest . clearAllMocks ( ) ;
720
731
721
- // should also fail if same CIPE is re-checked again but timeout has passed
722
- compareCIPEDataAndSendNotification ( failedCipe , failedCipe ) ;
732
+ // Transition from waiting to timeout - should show delayed notification
733
+ compareCIPEDataAndSendNotification ( waitingCipe , failedCipe ) ;
723
734
expect ( window . showInformationMessage ) . not . toHaveBeenCalled ( ) ;
724
735
expect ( window . showErrorMessage ) . toHaveBeenCalledTimes ( 1 ) ;
725
736
expect ( window . showErrorMessage ) . toHaveBeenCalledWith (
@@ -729,6 +740,55 @@ describe('CIPE Notifications', () => {
729
740
'View Results' ,
730
741
) ;
731
742
} ) ;
743
+
744
+ it ( 'should not show delayed notification repeatedly - only once when transitioning from waiting to no AI fix' , ( ) => {
745
+ const sixMinutesAgo = Date . now ( ) - 1000 * 60 * 6 ;
746
+
747
+ // CIPE that previously could have had AI fix (within 5 minutes)
748
+ const cipeWaitingForAiFix : CIPEInfo [ ] = [
749
+ {
750
+ ...pipelineExamples . failWithAiFixesEnabled [ 0 ] ,
751
+ createdAt : tenMinutesAgo ,
752
+ completedAt : oneMinuteAgo , // Within 5 minutes, so still waiting
753
+ } ,
754
+ ] ;
755
+
756
+ // Same CIPE but now past 5 minutes
757
+ const cipeAfterTimeout : CIPEInfo [ ] = [
758
+ {
759
+ ...pipelineExamples . failWithAiFixesEnabled [ 0 ] ,
760
+ createdAt : tenMinutesAgo ,
761
+ completedAt : sixMinutesAgo , // Past 5 minutes, no AI fix coming
762
+ } ,
763
+ ] ;
764
+
765
+ // First transition: from waiting to timeout - should show delayed notification
766
+ compareCIPEDataAndSendNotification (
767
+ cipeWaitingForAiFix ,
768
+ cipeAfterTimeout ,
769
+ ) ;
770
+ expect ( window . showErrorMessage ) . toHaveBeenCalledTimes ( 1 ) ;
771
+ expect ( window . showErrorMessage ) . toHaveBeenCalledWith (
772
+ 'CI failed for #feature.' ,
773
+ 'Help me fix this error' ,
774
+ 'View Commit' ,
775
+ 'View Results' ,
776
+ ) ;
777
+
778
+ jest . clearAllMocks ( ) ;
779
+
780
+ // Subsequent checks with same state - should NOT show notification again
781
+ compareCIPEDataAndSendNotification ( cipeAfterTimeout , cipeAfterTimeout ) ;
782
+ expect ( window . showErrorMessage ) . not . toHaveBeenCalled ( ) ;
783
+ expect ( window . showInformationMessage ) . not . toHaveBeenCalled ( ) ;
784
+
785
+ jest . clearAllMocks ( ) ;
786
+
787
+ // Another check - should still NOT show notification
788
+ compareCIPEDataAndSendNotification ( cipeAfterTimeout , cipeAfterTimeout ) ;
789
+ expect ( window . showErrorMessage ) . not . toHaveBeenCalled ( ) ;
790
+ expect ( window . showInformationMessage ) . not . toHaveBeenCalled ( ) ;
791
+ } ) ;
732
792
} ) ;
733
793
734
794
it ( 'should not show regular notifications twice even if run has been failed for more than 5 minutes and ai fixes are not enabled' , ( ) => {
0 commit comments