Add missing test
This commit is contained in:
parent
843e1a28b2
commit
9fbb21fb39
4 changed files with 40 additions and 26 deletions
|
|
@ -20,6 +20,7 @@ import io.element.android.libraries.push.impl.notifications.fake.FakeActiveNotif
|
||||||
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationCreator
|
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationCreator
|
||||||
import io.element.android.libraries.push.impl.notifications.fake.FakeRoomGroupMessageCreator
|
import io.element.android.libraries.push.impl.notifications.fake.FakeRoomGroupMessageCreator
|
||||||
import io.element.android.libraries.push.impl.notifications.fake.FakeSummaryGroupMessageCreator
|
import io.element.android.libraries.push.impl.notifications.fake.FakeSummaryGroupMessageCreator
|
||||||
|
import io.element.android.libraries.push.impl.notifications.fixtures.aFallbackNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.fixtures.aSimpleNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.fixtures.aSimpleNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.fixtures.anInviteNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.fixtures.anInviteNotifiableEvent
|
||||||
|
|
@ -33,6 +34,7 @@ private val MY_AVATAR_URL: String? = null
|
||||||
private val AN_INVITATION_EVENT = anInviteNotifiableEvent(roomId = A_ROOM_ID)
|
private val AN_INVITATION_EVENT = anInviteNotifiableEvent(roomId = A_ROOM_ID)
|
||||||
private val A_SIMPLE_EVENT = aSimpleNotifiableEvent(eventId = AN_EVENT_ID)
|
private val A_SIMPLE_EVENT = aSimpleNotifiableEvent(eventId = AN_EVENT_ID)
|
||||||
private val A_MESSAGE_EVENT = aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID)
|
private val A_MESSAGE_EVENT = aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID)
|
||||||
|
private val A_FALLBACK_EVENT = aFallbackNotifiableEvent()
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
class NotificationDataFactoryTest {
|
class NotificationDataFactoryTest {
|
||||||
|
|
@ -69,6 +71,25 @@ class NotificationDataFactoryTest {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `given a fallback invitation when mapping to notification then it's added`() = testWith(notificationDataFactory) {
|
||||||
|
val fallbackEvents = listOf(A_FALLBACK_EVENT)
|
||||||
|
val expectedNotification = notificationCreator.createFallbackNotificationResult(
|
||||||
|
null,
|
||||||
|
aNotificationAccountParams(),
|
||||||
|
fallbackEvents,
|
||||||
|
)
|
||||||
|
val result = toNotification(fallbackEvents, aNotificationAccountParams())
|
||||||
|
assertThat(result).isEqualTo(
|
||||||
|
OneShotNotification(
|
||||||
|
notification = expectedNotification,
|
||||||
|
tag = "FALLBACK",
|
||||||
|
isNoisy = false,
|
||||||
|
timestamp = A_FALLBACK_EVENT.timestamp
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a simple event when mapping to notification then it's added`() = testWith(notificationDataFactory) {
|
fun `given a simple event when mapping to notification then it's added`() = testWith(notificationDataFactory) {
|
||||||
val expectedNotification = notificationCreator.createRoomInvitationNotificationResult(
|
val expectedNotification = notificationCreator.createRoomInvitationNotificationResult(
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ import io.element.android.libraries.push.impl.notifications.factories.action.Acc
|
||||||
import io.element.android.libraries.push.impl.notifications.factories.action.MarkAsReadActionFactory
|
import io.element.android.libraries.push.impl.notifications.factories.action.MarkAsReadActionFactory
|
||||||
import io.element.android.libraries.push.impl.notifications.factories.action.QuickReplyActionFactory
|
import io.element.android.libraries.push.impl.notifications.factories.action.QuickReplyActionFactory
|
||||||
import io.element.android.libraries.push.impl.notifications.factories.action.RejectInvitationActionFactory
|
import io.element.android.libraries.push.impl.notifications.factories.action.RejectInvitationActionFactory
|
||||||
|
import io.element.android.libraries.push.impl.notifications.fixtures.aFallbackNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
|
|
||||||
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent
|
||||||
import io.element.android.services.toolbox.test.sdk.FakeBuildVersionSdkIntProvider
|
import io.element.android.services.toolbox.test.sdk.FakeBuildVersionSdkIntProvider
|
||||||
|
|
@ -85,18 +85,7 @@ class DefaultNotificationCreatorTest {
|
||||||
existingNotification = null,
|
existingNotification = null,
|
||||||
notificationAccountParams = aNotificationAccountParams(),
|
notificationAccountParams = aNotificationAccountParams(),
|
||||||
fallbackNotifiableEvents = listOf(
|
fallbackNotifiableEvents = listOf(
|
||||||
FallbackNotifiableEvent(
|
aFallbackNotifiableEvent(),
|
||||||
sessionId = A_SESSION_ID,
|
|
||||||
roomId = A_ROOM_ID,
|
|
||||||
eventId = AN_EVENT_ID,
|
|
||||||
editedEventId = null,
|
|
||||||
description = "description",
|
|
||||||
canBeReplaced = false,
|
|
||||||
isRedacted = false,
|
|
||||||
isUpdated = false,
|
|
||||||
timestamp = A_FAKE_TIMESTAMP,
|
|
||||||
cause = null,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
result.commonAssertions(
|
result.commonAssertions(
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,12 @@ import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||||
import io.element.android.libraries.matrix.test.A_TIMESTAMP
|
import io.element.android.libraries.matrix.test.A_TIMESTAMP
|
||||||
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
||||||
import io.element.android.libraries.matrix.test.A_USER_NAME_2
|
import io.element.android.libraries.matrix.test.A_USER_NAME_2
|
||||||
|
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableRingingCallEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableRingingCallEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent
|
||||||
|
import io.element.android.services.toolbox.test.systemclock.A_FAKE_TIMESTAMP
|
||||||
|
|
||||||
fun aSimpleNotifiableEvent(
|
fun aSimpleNotifiableEvent(
|
||||||
sessionId: SessionId = A_SESSION_ID,
|
sessionId: SessionId = A_SESSION_ID,
|
||||||
|
|
@ -141,3 +143,16 @@ fun aNotifiableCallEvent(
|
||||||
senderAvatarUrl = senderAvatarUrl,
|
senderAvatarUrl = senderAvatarUrl,
|
||||||
rtcNotificationType = rtcNotificationType,
|
rtcNotificationType = rtcNotificationType,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun aFallbackNotifiableEvent() = FallbackNotifiableEvent(
|
||||||
|
sessionId = A_SESSION_ID,
|
||||||
|
roomId = A_ROOM_ID,
|
||||||
|
eventId = AN_EVENT_ID,
|
||||||
|
editedEventId = null,
|
||||||
|
description = "A fallback notification",
|
||||||
|
canBeReplaced = false,
|
||||||
|
isRedacted = false,
|
||||||
|
isUpdated = false,
|
||||||
|
timestamp = A_FAKE_TIMESTAMP,
|
||||||
|
cause = "Unable to decrypt event",
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ import io.element.android.libraries.push.impl.notifications.DefaultNotificationR
|
||||||
import io.element.android.libraries.push.impl.notifications.FakeNotifiableEventResolver
|
import io.element.android.libraries.push.impl.notifications.FakeNotifiableEventResolver
|
||||||
import io.element.android.libraries.push.impl.notifications.FallbackNotificationFactory
|
import io.element.android.libraries.push.impl.notifications.FallbackNotificationFactory
|
||||||
import io.element.android.libraries.push.impl.notifications.channels.FakeNotificationChannels
|
import io.element.android.libraries.push.impl.notifications.channels.FakeNotificationChannels
|
||||||
|
import io.element.android.libraries.push.impl.notifications.fixtures.aFallbackNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableCallEvent
|
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableCallEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
|
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.ResolvedPushEvent
|
import io.element.android.libraries.push.impl.notifications.model.ResolvedPushEvent
|
||||||
import io.element.android.libraries.push.impl.test.DefaultTestPush
|
import io.element.android.libraries.push.impl.test.DefaultTestPush
|
||||||
|
|
@ -626,18 +626,7 @@ class DefaultPushHandlerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `when receiving a fallback event, we notify the push history service about it not being resolved`() = runTest {
|
fun `when receiving a fallback event, we notify the push history service about it not being resolved`() = runTest {
|
||||||
val aNotifiableFallbackEvent = FallbackNotifiableEvent(
|
val aNotifiableFallbackEvent = aFallbackNotifiableEvent()
|
||||||
sessionId = A_SESSION_ID,
|
|
||||||
roomId = A_ROOM_ID,
|
|
||||||
eventId = AN_EVENT_ID,
|
|
||||||
editedEventId = null,
|
|
||||||
description = "A fallback notification",
|
|
||||||
canBeReplaced = false,
|
|
||||||
isRedacted = false,
|
|
||||||
isUpdated = false,
|
|
||||||
timestamp = 0L,
|
|
||||||
cause = "Unable to decrypt event",
|
|
||||||
)
|
|
||||||
val notifiableEventResult =
|
val notifiableEventResult =
|
||||||
lambdaRecorder<SessionId, List<NotificationEventRequest>, Result<Map<NotificationEventRequest, Result<ResolvedPushEvent>>>> { _, _ ->
|
lambdaRecorder<SessionId, List<NotificationEventRequest>, Result<Map<NotificationEventRequest, Result<ResolvedPushEvent>>>> { _, _ ->
|
||||||
val request = NotificationEventRequest(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID, A_PUSHER_INFO)
|
val request = NotificationEventRequest(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID, A_PUSHER_INFO)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue