@@ -92,6 +92,45 @@ class AbstractEventNotificationAgentSpec extends Specification {
9292 // notifications ON, stage is synthetic
9393 fakeStageEvent(" orca:stage:complete" , " stage.complete" , false , true ) || 0
9494 }
95+
96+ @Unroll
97+ def " prevents stage notifications for Manual Judgment stages with specialized notifications" () {
98+ given :
99+ subclassMock. sendNotifications(* _) >> { notification , application , event_local , config , status_param -> }
100+
101+ when :
102+ // Create a stage event with specialized Manual Judgment notification type
103+ def event = createManualJudgmentStageEvent(" orca:stage:" + status, notificationType)
104+ agent. processEvent(event)
105+
106+ then :
107+ // Verify no notifications are sent due to our fix
108+ 0 * subclassMock. sendNotifications(* _)
109+
110+ where :
111+ status | notificationType
112+ " starting" | " manualJudgment"
113+ " complete" | " manualJudgmentContinue"
114+ " failed" | " manualJudgmentStop"
115+ }
116+
117+ @Unroll
118+ def " still sends stage notifications for non-Manual Judgment stages" () {
119+ given :
120+ subclassMock. sendNotifications(* _) >> { notification , application , event_local , config , status_param -> }
121+
122+ when :
123+ // Create a stage event with regular stage notification type
124+ def event = createRegularStageEvent(" orca:stage:" + status, " stage." + status)
125+ agent. processEvent(event)
126+
127+ then :
128+ // Verify notifications are still sent for normal stages
129+ 1 * subclassMock. sendNotifications(* _)
130+
131+ where :
132+ status << [" starting" , " complete" , " failed" ]
133+ }
95134
96135 @Unroll
97136 def " sends notifications for ManualJudgment stage based on status and configuration" () {
@@ -106,9 +145,9 @@ class AbstractEventNotificationAgentSpec extends Specification {
106145
107146 where :
108147 event || expectedNotifications
109- fakeStageEvent(" orca:stage:complete" , " manualJudgmentContinue" ) || 1
110- fakeStageEvent(" orca:stage:starting" , " manualJudgment" ) || 1
111- fakeStageEvent(" orca:stage:failed" , " manualJudgmentStop" ) || 1
148+ fakeStageEvent(" orca:stage:complete" , " manualJudgmentContinue" ) || 0
149+ fakeStageEvent(" orca:stage:starting" , " manualJudgment" ) || 0
150+ fakeStageEvent(" orca:stage:failed" , " manualJudgmentStop" ) || 0
112151 }
113152
114153 private def fakePipelineEvent (String type , String status , String notifyWhen , Map extraExecutionProps = [:]) {
@@ -173,4 +212,46 @@ class AbstractEventNotificationAgentSpec extends Specification {
173212
174213 return new Event (eventProps)
175214 }
215+
216+ private Event createManualJudgmentStageEvent (String eventType , String notificationType ) {
217+ return new Event (
218+ details : [
219+ type : eventType,
220+ application : " testapp"
221+ ],
222+ content : [
223+ context : [
224+ type : " manualJudgment" ,
225+ sendNotifications : true ,
226+ notifications : [
227+ [
228+ type : " fake" ,
229+ when : [notificationType]
230+ ]
231+ ]
232+ ]
233+ ]
234+ )
235+ }
236+
237+ private Event createRegularStageEvent (String eventType , String notificationType ) {
238+ return new Event (
239+ details : [
240+ type : eventType,
241+ application : " testapp"
242+ ],
243+ content : [
244+ context : [
245+ type : " regularStage" ,
246+ sendNotifications : true ,
247+ notifications : [
248+ [
249+ type : " fake" ,
250+ when : [notificationType]
251+ ]
252+ ]
253+ ]
254+ ]
255+ )
256+ }
176257}
0 commit comments