@@ -140,6 +140,15 @@ const notificationsDisabledPreferences = JSON.stringify({
140140 notifyOnFailure : true ,
141141} ) ;
142142
143+ const liveActivityWithoutPushPreferences = JSON . stringify ( {
144+ liveActivitiesEnabled : true ,
145+ notificationsEnabled : false ,
146+ notifyOnApproval : true ,
147+ notifyOnInput : true ,
148+ notifyOnCompletion : true ,
149+ notifyOnFailure : true ,
150+ } ) ;
151+
143152const target : LiveActivities . TargetRow = {
144153 user_id : "dev:julius" ,
145154 device_id : "device-1" ,
@@ -523,6 +532,53 @@ describe("ApnsDeliveries", () => {
523532 } ,
524533 ) ;
525534
535+ it . effect ( "keeps the Live Activity alert when push notifications are preferred off" , ( ) => {
536+ const attempts : Array < DeliveryAttempts . DeliveryAttemptInput > = [ ] ;
537+ const queuedJobs : Array < SignedApnsDeliveryJob > = [ ] ;
538+ const previousAggregate : RelayAgentActivityAggregateState = {
539+ ...aggregate ,
540+ activities : [
541+ {
542+ ...aggregate . activities [ 0 ] ! ,
543+ phase : "running" ,
544+ status : "Working" ,
545+ } ,
546+ ] ,
547+ } ;
548+ const inputAggregate : RelayAgentActivityAggregateState = {
549+ ...aggregate ,
550+ activities : [
551+ {
552+ ...aggregate . activities [ 0 ] ! ,
553+ phase : "waiting_for_approval" ,
554+ status : "Approval" ,
555+ } ,
556+ ] ,
557+ } ;
558+
559+ return Effect . gen ( function * ( ) {
560+ const deliveries = yield * ApnsDeliveries . ApnsDeliveries ;
561+ const result = yield * deliveries . sendForTarget ( {
562+ target : {
563+ ...target ,
564+ push_token : "apns-device-token" ,
565+ preferences_json : liveActivityWithoutPushPreferences ,
566+ last_aggregate_json : JSON . stringify ( previousAggregate ) ,
567+ } ,
568+ aggregate : inputAggregate ,
569+ nowMs : 5_000 ,
570+ } ) ;
571+
572+ expect ( result ?. kind ) . toBe ( "live_activity_update" ) ;
573+ expect ( queuedJobs ) . toHaveLength ( 1 ) ;
574+ expect ( queuedJobs [ 0 ] ?. payload ) . toMatchObject ( {
575+ kind : "live_activity_update" ,
576+ alert : { title : "Needs your reply" } ,
577+ } ) ;
578+ expect ( attempts ) . toEqual ( [ ] ) ;
579+ } ) . pipe ( Effect . provide ( layerFor ( { attempts, queuedJobs } ) ) ) ;
580+ } ) ;
581+
526582 it . effect (
527583 "queues a companion push with Live Activity updates so stale activity tokens cannot swallow alerts" ,
528584 ( ) => {
0 commit comments