

























@@ -200,24 +200,12 @@ private final class MockWatchMessagingService: @preconcurrency WatchMessagingSer
200200201201private final class MockBootstrapNotificationCenter: NotificationCentering, @unchecked Sendable {
202202var status: NotificationAuthorizationStatus = .notDetermined
203-var requestAuthorizationResult = false
204-var requestAuthorizationCalls = 0
205203var addCalls = 0
206204207205func authorizationStatus() async -> NotificationAuthorizationStatus {
208206self.status
209207}
210208211-func requestAuthorization(options _: UNAuthorizationOptions) async throws -> Bool {
212-self.requestAuthorizationCalls += 1
213-if self.requestAuthorizationResult {
214-self.status = .authorized
215-} else {
216-self.status = .denied
217-}
218-return self.requestAuthorizationResult
219-}
220-221209func add(_: UNNotificationRequest) async throws {
222210self.addCalls += 1
223211}
@@ -1233,15 +1221,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
12331221 hasStoredOperatorToken: false))
12341222}
123512231236-@Test @MainActor func successfulBootstrapOnboardingDoesNotRequestNotificationAuthorization() async {
1237-let center = MockBootstrapNotificationCenter()
1238-let appModel = NodeAppModel(notificationCenter: center)
1239-1240-await appModel._test_handleSuccessfulBootstrapGatewayOnboarding()
1241-1242- #expect(center.requestAuthorizationCalls == 0)
1243-}
1244-12451224@Test @MainActor func operatorGatewayRequestedEventShowsNotificationGuidanceWhenNotificationsOff() async throws {
12461225let center = MockBootstrapNotificationCenter()
12471226 center.status = .notDetermined
@@ -1258,7 +1237,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
1258123712591238let prompt = try #require(appModel._test_pendingNotificationPermissionGuidancePrompt())
12601239 #expect(prompt.approvalId == "approval-notifications-off")
1261- #expect(center.requestAuthorizationCalls == 0)
12621240}
1263124112641242@Test @MainActor func suppressedOperatorGatewayRequestedEventDoesNotShowNotificationGuidance() async {
@@ -1277,7 +1255,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
12771255 stateversion: nil))
1278125612791257 #expect(appModel._test_pendingNotificationPermissionGuidancePrompt() == nil)
1280- #expect(center.requestAuthorizationCalls == 0)
12811258}
1282125912831260@Test @MainActor func operatorGatewayResolvedEventClearsNotificationGuidancePrompt() async throws {
@@ -1364,7 +1341,7 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
13641341 #expect(res.error?.message.contains("CAMERA_DISABLED") == true)
13651342}
136613431367-@Test @MainActor func systemNotifyDoesNotRequestNotificationAuthorizationWhenOff() async throws {
1344+@Test @MainActor func systemNotifyReturnsUnavailableWhenNotificationsOff() async throws {
13681345let center = MockBootstrapNotificationCenter()
13691346 center.status = .notDetermined
13701347let appModel = NodeAppModel(notificationCenter: center)
@@ -1380,7 +1357,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
13801357 #expect(res.ok == false)
13811358 #expect(res.error?.code == .unavailable)
13821359 #expect(res.error?.message == "NOT_AUTHORIZED: notifications")
1383- #expect(center.requestAuthorizationCalls == 0)
13841360 #expect(center.addCalls == 0)
13851361}
13861362@@ -1398,11 +1374,10 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
13981374let res = await appModel._test_handleInvoke(req)
1399137514001376 #expect(res.ok)
1401- #expect(center.requestAuthorizationCalls == 0)
14021377 #expect(center.addCalls == 1)
14031378}
140413791405-@Test @MainActor func chatPushWithoutSpeechDoesNotRequestNotificationAuthorizationWhenOff() async throws {
1380+@Test @MainActor func chatPushWithoutSpeechReturnsUnavailableWhenNotificationsOff() async throws {
14061381let center = MockBootstrapNotificationCenter()
14071382 center.status = .notDetermined
14081383let appModel = NodeAppModel(notificationCenter: center)
@@ -1418,7 +1393,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
14181393 #expect(res.ok == false)
14191394 #expect(res.error?.code == .unavailable)
14201395 #expect(res.error?.message == "NOT_AUTHORIZED: notifications")
1421- #expect(center.requestAuthorizationCalls == 0)
14221396 #expect(center.addCalls == 0)
14231397}
14241398@@ -1436,7 +1410,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
14361410let res = await appModel._test_handleInvoke(req)
1437141114381412 #expect(res.ok)
1439- #expect(center.requestAuthorizationCalls == 0)
14401413 #expect(center.addCalls == 1)
14411414}
14421415此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。