Skip to content

Commit

Permalink
feat: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina committed Oct 1, 2024
1 parent 59e04e5 commit 3277f62
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class WireNotificationManagerTest {
fun givenNotAuthenticatedUser_whenObserveCalled_thenNothingHappenAndCallNotificationHides() =
runTestWithCancellation(dispatcherProvider.main()) {
val (arrangement, manager) = Arrangement()
.withCurrentScreen(CurrentScreen.SomeOther)
.withCurrentScreen(CurrentScreen.SomeOther())
.arrange()

manager.observeNotificationsAndCallsWhileRunning(listOf(), this)
Expand All @@ -152,7 +152,7 @@ class WireNotificationManagerTest {
val (arrangement, manager) = Arrangement()
.withSpecificUserSession(userId = userId, incomingCalls = incomingCalls)
.withMessageNotifications(listOf())
.withCurrentScreen(CurrentScreen.SomeOther)
.withCurrentScreen(CurrentScreen.SomeOther())
.withCurrentUserSession(CurrentSessionResult.Success(AccountInfo.Valid(userId)))
.arrange()

Expand All @@ -174,7 +174,7 @@ class WireNotificationManagerTest {
.withSpecificUserSession(userId = user1, incomingCalls = listOf())
.withSpecificUserSession(userId = user2, incomingCalls = incomingCalls)
.withMessageNotifications(listOf())
.withCurrentScreen(CurrentScreen.SomeOther)
.withCurrentScreen(CurrentScreen.SomeOther())
.withCurrentUserSession(CurrentSessionResult.Success(provideAccountInfo(user1.value)))
.arrange()

Expand All @@ -198,7 +198,7 @@ class WireNotificationManagerTest {
)
)
)
.withCurrentScreen(CurrentScreen.SomeOther).arrange()
.withCurrentScreen(CurrentScreen.SomeOther()).arrange()

manager.observeNotificationsAndCallsWhileRunning(listOf(), this)
runCurrent()
Expand Down Expand Up @@ -249,7 +249,7 @@ class WireNotificationManagerTest {
.withMessageNotifications(messageNotifications)
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withCurrentScreen(CurrentScreen.SomeOther)
.withCurrentScreen(CurrentScreen.SomeOther())
.arrange()

manager.observeNotificationsAndCallsWhileRunning(listOf(provideUserId(TestUser.SELF_USER.id.value)), this)
Expand Down Expand Up @@ -277,7 +277,7 @@ class WireNotificationManagerTest {
)
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withCurrentScreen(CurrentScreen.Conversation(conversationId))
.withCurrentScreen(CurrentScreen.Conversation(conversationId, "route"))
.arrange()

manager.observeNotificationsAndCallsWhileRunning(listOf(provideUserId(TestUser.SELF_USER.id.value)), this)
Expand Down Expand Up @@ -335,7 +335,7 @@ class WireNotificationManagerTest {
.withMessageNotifications(listOf())
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withCurrentScreen(CurrentScreen.Conversation(conversationId))
.withCurrentScreen(CurrentScreen.Conversation(conversationId, "route"))
.arrange()

manager.observeNotificationsAndCallsWhileRunning(listOf(provideUserId()), this)
Expand Down Expand Up @@ -428,7 +428,7 @@ class WireNotificationManagerTest {
)
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withCurrentScreen(CurrentScreen.Conversation(id = conversationId))
.withCurrentScreen(CurrentScreen.Conversation(id = conversationId, "route"))
.arrange()

manager.observeNotificationsAndCallsWhileRunning(listOf(provideUserId()), this)
Expand Down Expand Up @@ -688,7 +688,7 @@ class WireNotificationManagerTest {
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withMessageNotifications(listOf())
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withEstablishedCall(listOf(call))
.withCurrentUserSession(CurrentSessionResult.Success(provideAccountInfo(userId.value)))
.arrange()
Expand All @@ -709,7 +709,7 @@ class WireNotificationManagerTest {
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf(call))
.withMessageNotifications(listOf())
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withEstablishedCall(listOf())
.withCurrentUserSession(CurrentSessionResult.Success(provideAccountInfo(userId.value)))
.arrange()
Expand All @@ -729,7 +729,7 @@ class WireNotificationManagerTest {
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withMessageNotifications(listOf())
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withEstablishedCall(listOf())
.withCurrentUserSession(CurrentSessionResult.Success(provideAccountInfo(userId.value)))
.arrange()
Expand All @@ -750,7 +750,7 @@ class WireNotificationManagerTest {
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withMessageNotifications(listOf())
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withEstablishedCall(listOf(call))
.withCurrentUserSession(CurrentSessionResult.Success(provideInvalidAccountInfo(userId.value)))
.arrange()
Expand All @@ -770,7 +770,7 @@ class WireNotificationManagerTest {
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withMessageNotifications(listOf())
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withEstablishedCall(listOf())
.withCurrentUserSession(CurrentSessionResult.Success(provideInvalidAccountInfo(userId.value)))
.arrange()
Expand All @@ -789,7 +789,7 @@ class WireNotificationManagerTest {
val userId2 = UserId("value2", "domain")
val call = provideCall().copy(status = CallStatus.ESTABLISHED)
val (arrangement, manager) = Arrangement()
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withSpecificUserSession(userId = userId1, establishedCalls = listOf())
.withSpecificUserSession(userId = userId2, establishedCalls = listOf(call))
.withCurrentUserSession(CurrentSessionResult.Success(provideAccountInfo(userId1.value)))
Expand All @@ -808,7 +808,7 @@ class WireNotificationManagerTest {
val userId2 = UserId("value2", "domain")
val call = provideCall().copy(status = CallStatus.ESTABLISHED)
val (arrangement, manager) = Arrangement()
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withSpecificUserSession(userId = userId1, establishedCalls = listOf())
.withSpecificUserSession(userId = userId2, establishedCalls = listOf(call))
.withCurrentUserSession(CurrentSessionResult.Success(provideAccountInfo(userId1.value)))
Expand All @@ -830,7 +830,7 @@ class WireNotificationManagerTest {
val userId2 = UserId("value2", "domain")
val call = provideCall().copy(status = CallStatus.ESTABLISHED)
val (arrangement, manager) = Arrangement()
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withSpecificUserSession(userId = userId1, establishedCalls = listOf(call))
.withSpecificUserSession(userId = userId2, establishedCalls = listOf())
.withCurrentUserSession(CurrentSessionResult.Success(provideAccountInfo(userId1.value)))
Expand All @@ -854,7 +854,7 @@ class WireNotificationManagerTest {
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withMessageNotifications(listOf())
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withEstablishedCall(listOf(call))
.withCurrentUserSession(CurrentSessionResult.Success(provideAccountInfo(userId.value)))
.arrange()
Expand All @@ -878,7 +878,7 @@ class WireNotificationManagerTest {
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withMessageNotifications(listOf())
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withEstablishedCallFlow(callFlow)
.withCurrentUserSession(CurrentSessionResult.Success(provideAccountInfo(userId.value)))
.arrange()
Expand All @@ -900,7 +900,7 @@ class WireNotificationManagerTest {
runTestWithCancellation(dispatcherProvider.main()) {
val userId = provideUserId()
val call = provideCall().copy(status = CallStatus.ESTABLISHED)
val currentScreenFlow = MutableStateFlow<CurrentScreen>(CurrentScreen.Home)
val currentScreenFlow = MutableStateFlow<CurrentScreen>(CurrentScreen.Home("home"))
val (arrangement, manager) = Arrangement()
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
Expand Down Expand Up @@ -939,7 +939,7 @@ class WireNotificationManagerTest {
manager.observeNotificationsAndCallsWhileRunning(listOf(userId), this)
advanceUntilIdle()

currentScreenFlow.value = CurrentScreen.Home
currentScreenFlow.value = CurrentScreen.Home("home")
advanceUntilIdle()

verify(exactly = 0) { arrangement.servicesManager.stopCallService() }
Expand All @@ -960,7 +960,7 @@ class WireNotificationManagerTest {
)
.withIncomingCalls(listOf())
.withOutgoingCalls(listOf())
.withCurrentScreen(CurrentScreen.SomeOther)
.withCurrentScreen(CurrentScreen.SomeOther())
.withObserveE2EIRequired(E2EIRequiredResult.NoGracePeriod.Create)
.arrange()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class WireActivityViewModelTest {
.withNoCurrentSession()
.withMigrationRequired()
.withDeepLinkResult(DeepLinkResult.CustomServerConfig("url"))
.withCurrentScreen(MutableStateFlow<CurrentScreen>(CurrentScreen.Home))
.withCurrentScreen(MutableStateFlow<CurrentScreen>(CurrentScreen.Home("home")))
.arrange()

viewModel.handleDeepLink(mockedIntent(), {}, {}, arrangement.onDeepLinkResult, {}, {}, {}, {})
Expand Down Expand Up @@ -465,7 +465,7 @@ class WireActivityViewModelTest {
val (_, viewModel) = Arrangement()
.withNoCurrentSession()
.withNewClient(NewClientResult.InCurrentAccount(listOf(TestClient.CLIENT), USER_ID))
.withCurrentScreen(MutableStateFlow<CurrentScreen>(CurrentScreen.SomeOther))
.withCurrentScreen(MutableStateFlow<CurrentScreen>(CurrentScreen.SomeOther()))
.arrange()

assertEquals(
Expand All @@ -479,7 +479,7 @@ class WireActivityViewModelTest {
val (_, viewModel) = Arrangement()
.withNoCurrentSession()
.withNewClient(NewClientResult.InOtherAccount(listOf(TestClient.CLIENT), USER_ID, "name", "handle"))
.withCurrentScreen(MutableStateFlow<CurrentScreen>(CurrentScreen.SomeOther))
.withCurrentScreen(MutableStateFlow<CurrentScreen>(CurrentScreen.SomeOther()))
.arrange()

assertEquals(
Expand All @@ -495,15 +495,15 @@ class WireActivityViewModelTest {

@Test
fun `given newClient is registered when current screen does not allow dialog, then remember NewClient dialog state`() = runTest {
val currentScreenFlow = MutableStateFlow<CurrentScreen>(CurrentScreen.SomeOther)
val currentScreenFlow = MutableStateFlow<CurrentScreen>(CurrentScreen.SomeOther())
val newClientFlow = MutableSharedFlow<NewClientResult>()
val (_, viewModel) = Arrangement()
.withNoCurrentSession()
.withNewClient(newClientFlow)
.withCurrentScreen(currentScreenFlow)
.arrange()

currentScreenFlow.value = CurrentScreen.ImportMedia
currentScreenFlow.value = CurrentScreen.ImportMedia("import")
newClientFlow.emit(NewClientResult.InCurrentAccount(listOf(TestClient.CLIENT), USER_ID))

advanceUntilIdle()
Expand All @@ -513,14 +513,14 @@ class WireActivityViewModelTest {

@Test
fun `given newClient is registered when current screen changed to ImportMedea, then remember NewClient dialog state`() = runTest {
val currentScreenFlow = MutableStateFlow<CurrentScreen>(CurrentScreen.SomeOther)
val currentScreenFlow = MutableStateFlow<CurrentScreen>(CurrentScreen.SomeOther())
val (_, viewModel) = Arrangement()
.withNoCurrentSession()
.withNewClient(NewClientResult.InCurrentAccount(listOf(TestClient.CLIENT), USER_ID))
.withCurrentScreen(currentScreenFlow)
.arrange()

currentScreenFlow.value = CurrentScreen.ImportMedia
currentScreenFlow.value = CurrentScreen.ImportMedia("import")

assertEquals(null, viewModel.globalAppState.newClientDialog)
}
Expand Down Expand Up @@ -628,7 +628,7 @@ class WireActivityViewModelTest {
every { observeScreenshotCensoringConfigUseCaseProviderFactory.create(any()).observeScreenshotCensoringConfig } returns
observeScreenshotCensoringConfigUseCase
coEvery { observeScreenshotCensoringConfigUseCase() } returns flowOf(ObserveScreenshotCensoringConfigResult.Disabled)
coEvery { currentScreenManager.observeCurrentScreen(any()) } returns MutableStateFlow(CurrentScreen.SomeOther)
coEvery { currentScreenManager.observeCurrentScreen(any()) } returns MutableStateFlow(CurrentScreen.SomeOther())
coEvery { globalDataStore.selectedThemeOptionFlow() } returns flowOf(ThemeOption.LIGHT)
coEvery { observeIfE2EIRequiredDuringLoginUseCaseProviderFactory.create(any()).observeIfE2EIIsRequiredDuringLogin() } returns
flowOf(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CommonTopAppBarViewModelTest {
.withoutOngoingCall()
.withoutOutgoingCall()
.withoutIncomingCall()
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withSyncState(SyncState.SlowSync)
.arrange()

Expand All @@ -83,7 +83,7 @@ class CommonTopAppBarViewModelTest {
.withoutOngoingCall()
.withoutOutgoingCall()
.withoutIncomingCall()
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withSyncState(SyncState.GatheringPendingEvents)
.arrange()

Expand All @@ -102,7 +102,7 @@ class CommonTopAppBarViewModelTest {
.withOngoingCall()
.withoutOutgoingCall()
.withoutIncomingCall()
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withSyncState(SyncState.Waiting)
.arrange()

Expand All @@ -122,7 +122,7 @@ class CommonTopAppBarViewModelTest {
.withOngoingCall(isMuted = true)
.withoutOutgoingCall()
.withoutIncomingCall()
.withCurrentScreen(CurrentScreen.Conversation(mockk()))
.withCurrentScreen(CurrentScreen.Conversation(mockk(), mockk()))
.withSyncState(SyncState.Waiting)
.arrange()

Expand All @@ -143,7 +143,7 @@ class CommonTopAppBarViewModelTest {
.withOngoingCall(isMuted = false)
.withoutOutgoingCall()
.withoutIncomingCall()
.withCurrentScreen(CurrentScreen.Conversation(mockk()))
.withCurrentScreen(CurrentScreen.Conversation(mockk(), mockk()))
.withSyncState(SyncState.Waiting)
.arrange()

Expand All @@ -164,7 +164,7 @@ class CommonTopAppBarViewModelTest {
.withOngoingCall(isMuted = false)
.withoutOutgoingCall()
.withoutIncomingCall()
.withCurrentScreen(CurrentScreen.SomeOther)
.withCurrentScreen(CurrentScreen.SomeOther())
.withSyncState(SyncState.Waiting)
.arrange()

Expand All @@ -182,7 +182,7 @@ class CommonTopAppBarViewModelTest {
.withIncomingCall()
.withoutOngoingCall()
.withoutOutgoingCall()
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withSyncState(SyncState.Waiting)
.arrange()

Expand All @@ -200,7 +200,7 @@ class CommonTopAppBarViewModelTest {
.withOutgoingCall()
.withoutIncomingCall()
.withoutOngoingCall()
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withSyncState(SyncState.Live)
.arrange()

Expand Down Expand Up @@ -230,7 +230,7 @@ class CommonTopAppBarViewModelTest {
.withOngoingCall(isMuted = true)
.withIncomingCall()
.withOutgoingCall()
.withCurrentScreen(CurrentScreen.Home)
.withCurrentScreen(CurrentScreen.Home("home"))
.withSyncState(SyncState.Waiting)
.arrange()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ class RecordAudioViewModelTest {

coEvery { currentScreenManager.observeCurrentScreen(any()) } returns MutableStateFlow(
CurrentScreen.Conversation(
id = DUMMY_CALL.conversationId
id = DUMMY_CALL.conversationId,
"conversationScreen"
)
)

Expand Down

0 comments on commit 3277f62

Please sign in to comment.