From 4f212b34c0979216e5bebcb14dd5a06fe2b2c50b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 19 Jun 2024 11:44:08 +0200 Subject: [PATCH] Update test and add test for incoming call when notifications are disabled. --- .../push/impl/push/DefaultPushHandlerTest.kt | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt index 9e37aae29d..4953e4d7b4 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt @@ -118,7 +118,7 @@ class DefaultPushHandlerTest { incrementPushCounterResult.assertions() .isCalledOnce() notifiableEventResult.assertions() - .isNeverCalled() + .isCalledOnce() onNotifiableEventReceived.assertions() .isNeverCalled() } @@ -277,6 +277,34 @@ class DefaultPushHandlerTest { onNotifiableEventReceived.assertions().isCalledOnce() } + @Test + fun `when notify call PushData is received, the incoming call will be treated as a normal notification even if notification are disabled`() = runTest { + val aPushData = PushData( + eventId = AN_EVENT_ID, + roomId = A_ROOM_ID, + unread = 0, + clientSecret = A_SECRET, + ) + val onNotifiableEventReceived = lambdaRecorder {} + val handleIncomingCallLambda = lambdaRecorder { _, _, _, _, _, _, _ -> } + val elementCallEntryPoint = FakeElementCallEntryPoint(handleIncomingCallResult = handleIncomingCallLambda) + val defaultPushHandler = createDefaultPushHandler( + elementCallEntryPoint = elementCallEntryPoint, + onNotifiableEventReceived = onNotifiableEventReceived, + notifiableEventResult = { _, _, _ -> aNotifiableCallEvent() }, + incrementPushCounterResult = {}, + userPushStore = FakeUserPushStore().apply { + setNotificationEnabledForDevice(false) + }, + pushClientSecret = FakePushClientSecret( + getUserIdFromSecretResult = { A_USER_ID } + ), + ) + defaultPushHandler.handle(aPushData) + handleIncomingCallLambda.assertions().isCalledOnce() + onNotifiableEventReceived.assertions().isNeverCalled() + } + @Test fun `when diagnostic PushData is received, the diagnostic push handler is informed `() = runTest {