Skip to content

Commit fa49d3a

Browse files
authored
[LOOP-4349] corrected loop not looping rescheduling (#532)
* corrected identifier for loop not looping notifications * updated test to run for both DIY and Tidepool
1 parent 635ade6 commit fa49d3a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Loop/Managers/Alerts/AlertManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public final class AlertManager {
203203
)
204204

205205
let request = UNNotificationRequest(
206-
identifier: "\(LoopNotificationCategory.loopNotRunning.rawValue)\(failureInterval)",
206+
identifier: "\(LoopNotificationCategory.loopNotRunning.rawValue)\(minutes)",
207207
content: notificationContent,
208208
trigger: trigger
209209
)

LoopTests/Managers/Alerts/AlertManagerTests.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ class AlertManagerTests: XCTestCase {
481481
alertManager.loopDidComplete(lastLoopDate)
482482
alertManager.alertMuter.configuration.startTime = Date()
483483
alertManager.alertMuter.configuration.duration = .hours(4)
484-
484+
waitOnMain()
485+
485486
let testExpectation = expectation(description: #function)
486487
var loopNotRunningRequests: [UNNotificationRequest] = []
487488
UNUserNotificationCenter.current().getPendingNotificationRequests() { notificationRequests in
@@ -492,8 +493,21 @@ class AlertManagerTests: XCTestCase {
492493
}
493494

494495
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+
}
497511
}
498512
}
499513

0 commit comments

Comments
 (0)