@@ -146,6 +146,28 @@ describe('NotificationService grouped-email interception', () => {
146146 expect ( mockEnqueueFlush ) . not . toHaveBeenCalled ( )
147147 } )
148148
149+ it ( 'sends email overrides immediately so their task CTA is not grouped away' , async ( ) => {
150+ const task = makeTask ( )
151+
152+ await buildService ( ) . create ( NotificationTaskActions . Assigned , task , {
153+ disableEmail : false ,
154+ emailOverride : {
155+ subject : 'Action Required: Evaluation Ready' ,
156+ title : 'Review evaluation' ,
157+ } ,
158+ } )
159+
160+ expect ( mockGroupedCreateMany ) . not . toHaveBeenCalled ( )
161+ expect ( mockEnqueueFlush ) . not . toHaveBeenCalled ( )
162+ expect ( mockCreateNotification ) . toHaveBeenCalledTimes ( 1 )
163+ expect ( deliveryTargetsOf ( 0 ) . inProduct ) . toBeDefined ( )
164+ expect ( deliveryTargetsOf ( 0 ) . email ) . toMatchObject ( {
165+ subject : 'Action Required: Evaluation Ready' ,
166+ title : 'Review evaluation' ,
167+ ctaParams : { taskId : task . id } ,
168+ } )
169+ } )
170+
149171 it ( 'keys the window on (clientId, companyId) so a multi-company client does not get merged' , async ( ) => {
150172 const companyB = '99999999-9999-9999-9999-999999999999'
151173 await buildService ( ) . create ( NotificationTaskActions . Assigned , makeTask ( { companyId : companyB } ) )
@@ -251,6 +273,30 @@ describe('NotificationService grouped-email interception', () => {
251273 expect ( recipients ) . toEqual ( [ 'cu_a' , 'cu_b' , 'cu_c' ] )
252274 } )
253275
276+ it ( 'sends bulk email overrides immediately for every recipient' , async ( ) => {
277+ const task = makeTask ( )
278+ const recipients = [ '33333333-3333-3333-3333-333333333333' , '44444444-4444-4444-4444-444444444444' ]
279+
280+ await buildService ( ) . createBulkNotification ( NotificationTaskActions . AssignedToCompany , task , recipients , {
281+ email : true ,
282+ emailOverride : {
283+ subject : 'Action Required: Evaluation Ready' ,
284+ title : 'Review evaluation' ,
285+ } ,
286+ } )
287+
288+ expect ( mockGroupedCreateMany ) . not . toHaveBeenCalled ( )
289+ expect ( mockEnqueueFlush ) . not . toHaveBeenCalled ( )
290+ expect ( mockCreateNotification ) . toHaveBeenCalledTimes ( 2 )
291+ for ( const call of mockCreateNotification . mock . calls ) {
292+ expect ( call [ 0 ] . deliveryTargets . email ) . toMatchObject ( {
293+ subject : 'Action Required: Evaluation Ready' ,
294+ title : 'Review evaluation' ,
295+ ctaParams : { taskId : task . id } ,
296+ } )
297+ }
298+ } )
299+
254300 it ( 'falls back to the association company when the shared task has no companyId' , async ( ) => {
255301 const assocCompany = '88888888-8888-8888-8888-888888888888'
256302 const task = makeTask ( {
0 commit comments