Attempt to improve unit test reliability:

- synchronize mock properties on the main queue
- sleep for longer when processing routes
- finish encoding before deallocating the keyed archiver
- wait for NotificationCenter notifications to be delivered
- change were we process remote notification permissions
This commit is contained in:
Stefan Ceriu
2024-04-10 16:29:30 +03:00
committed by Stefan Ceriu
parent da598302df
commit 7645971812
6 changed files with 8825 additions and 378 deletions
@@ -23,17 +23,7 @@ final class NotificationManager: NSObject, NotificationManagerProtocol {
private let notificationCenter: UserNotificationCenterProtocol
private let appSettings: AppSettings
private var userSession: UserSessionProtocol? {
didSet {
// If notification permissions were given previously then attempt re-registering
// for remote notifications on startup. Otherwise let the onboarding flow handle it
Task { @MainActor in
if await self.notificationCenter.authorizationStatus() == .authorized {
self.delegate?.registerForRemoteNotifications()
}
}
}
}
private var userSession: UserSessionProtocol?
private var cancellables = Set<AnyCancellable>()
private var notificationsEnabled = false
@@ -103,6 +93,18 @@ final class NotificationManager: NSObject, NotificationManagerProtocol {
func setUserSession(_ userSession: UserSessionProtocol?) {
self.userSession = userSession
// If notification permissions were given previously then attempt re-registering
// for remote notifications on startup. Otherwise let the onboarding flow handle it
Task { [weak self] in
guard let self else { return }
if await notificationCenter.authorizationStatus() == .authorized {
await MainActor.run {
delegate?.registerForRemoteNotifications()
}
}
}
}
func registrationFailed(with error: Error) {