feat(notification): Turn off action and tap-to-open on background notification (#1408)

This commit is contained in:
m57 authored and GitHub committed 2026-09-30 13:30:55 +03:00
1 parent 48de25985a
commit 05519ba1ff
9 files changed
+139 -9

No files matched your search

@@ -407,4 +407,55 @@ class BackgroundConnectionControllerTest {
unmockkObject(NetworkMonitor)
}
}
@Test
fun testOnKeepConnectedDisabled_whenBackgrounded_releasesLeaseAndStopsService() {
var leaseReleased = false
var serviceStopped = false
val snapshot =
BackgroundConnectionSnapshot(
appInForeground = false,
keepConnectedOptIn = false,
pendingReply = false,
isEligibleForConnection = true,
status = ConnectionStatus.CONNECTED,
)
val controller =
BackgroundConnectionController(
snapshotProvider = { snapshot },
releaseLease = { leaseReleased = true },
requestServiceStop = { serviceStopped = true },
)
controller.onKeepConnectedDisabled()
assertTrue(leaseReleased)
assertTrue(serviceStopped)
}
@Test
fun testOnKeepConnectedDisabled_whenReplyPending_keepsServiceAndRefreshesNotification() {
var serviceStopped = false
var refreshed: BackgroundNotificationState? = null
val snapshot =
BackgroundConnectionSnapshot(
appInForeground = false,
keepConnectedOptIn = false,
pendingReply = true,
isEligibleForConnection = true,
status = ConnectionStatus.CONNECTED,
)
val controller =
BackgroundConnectionController(
snapshotProvider = { snapshot },
releaseLease = {},
requestServiceStop = { serviceStopped = true },
onNotificationStateChanged = { refreshed = it },
)
controller.onKeepConnectedDisabled()
assertFalse(serviceStopped)
assertEquals(BackgroundNotificationState.WaitingForReplies, refreshed)
}
}