@@ -481,7 +481,8 @@ class AlertManagerTests: XCTestCase {
481
481
alertManager. loopDidComplete ( lastLoopDate)
482
482
alertManager. alertMuter. configuration. startTime = Date ( )
483
483
alertManager. alertMuter. configuration. duration = . hours( 4 )
484
-
484
+ waitOnMain ( )
485
+
485
486
let testExpectation = expectation ( description: #function)
486
487
var loopNotRunningRequests : [ UNNotificationRequest ] = [ ]
487
488
UNUserNotificationCenter . current ( ) . getPendingNotificationRequests ( ) { notificationRequests in
@@ -492,8 +493,21 @@ class AlertManagerTests: XCTestCase {
492
493
}
493
494
494
495
wait ( for: [ testExpectation] , timeout: 1 )
495
- XCTAssertNil ( loopNotRunningRequests. first ( where: { $0. content. interruptionLevel == . timeSensitive } ) !. content. sound)
496
- XCTAssertEqual ( loopNotRunningRequests. first ( where: { $0. content. interruptionLevel == . critical } ) !. content. sound, . defaultCriticalSound( withAudioVolume: 0 ) )
496
+ if #available( iOS 15 . 0 , * ) {
497
+ XCTAssertNil ( loopNotRunningRequests. first ( where: { $0. content. interruptionLevel == . timeSensitive } ) ? . content. sound)
498
+ if let request = loopNotRunningRequests. first ( where: { $0. content. interruptionLevel == . critical } ) {
499
+ XCTAssertEqual ( request. content. sound, . defaultCriticalSound( withAudioVolume: 0 ) )
500
+ }
501
+ } else if FeatureFlags . criticalAlertsEnabled {
502
+ for request in loopNotRunningRequests {
503
+ let sound = request. content. sound
504
+ XCTAssertTrue ( sound == nil || sound == . defaultCriticalSound( withAudioVolume: 0.0 ) )
505
+ }
506
+ } else {
507
+ for request in loopNotRunningRequests {
508
+ XCTAssertNil ( request. content. sound)
509
+ }
510
+ }
497
511
}
498
512
}
499
513
0 commit comments