Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,42 @@ class ObserveAppLockConfigUseCaseTest {
}
}

@Test
fun givenValidSessionAndTeamConfigIsNull_whenObservingAppLock_thenSendDisabledStatus() = runTest {
val (_, useCase) = Arrangement()
.withValidSession()
.withTeamAppLockNull()
.withAppNonLockedByCurrentUser()
.arrange()

val result = useCase.invoke()

result.test {
val appLockStatus = awaitItem()

assertEquals(AppLockConfig.Disabled(ObserveAppLockConfigUseCase.DEFAULT_APP_LOCK_TIMEOUT), appLockStatus)
awaitComplete()
}
}

@Test
fun givenValidSessionAndTeamConfigIsNullAndLocalPasscodeSet_whenObservingAppLock_thenSendEnabledStatus() = runTest {
val (_, useCase) = Arrangement()
.withValidSession()
.withTeamAppLockNull()
.withAppLockedByCurrentUser(true)
.arrange()

val result = useCase.invoke()

result.test {
val appLockStatus = awaitItem()

assertEquals(AppLockConfig.Enabled(ObserveAppLockConfigUseCase.DEFAULT_APP_LOCK_TIMEOUT), appLockStatus)
awaitComplete()
}
}

@Test
fun givenValidSessionAndAppNotLockedByUserNorTeam_whenObservingAppLock_thenSendDisabledStatus() =
runTest {
Expand Down Expand Up @@ -189,6 +225,16 @@ class ObserveAppLockConfigUseCaseTest {
} returns flowOf(AppLockTeamConfig(false, timeout, false))
}

fun withTeamAppLockNull() = apply {
every { coreLogic.getSessionScope(any()) } returns userSessionScope
every {
userSessionScope.appLockTeamFeatureConfigObserver
} returns appLockTeamFeatureConfigObserver
every {
appLockTeamFeatureConfigObserver.invoke()
} returns flowOf(null)
}

fun withAppLockedByCurrentUser(state: Boolean) = apply {
every { globalDataStore.isAppLockPasscodeSetFlow() } returns flowOf(state)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ class FeatureFlagNotificationViewModelTest {
assertTrue(viewModel.featureFlagState.shouldShowTeamAppLockDialog)
}

@Test
fun givenTeamAppLockObserverEmitsNull_whenObservingFeatureFlags_thenTeamAppLockDialogIsNotShown() = runTest {
val (_, viewModel) = Arrangement()
.withCurrentSessionsFlow(flowOf(CurrentSessionResult.Success(AccountInfo.Valid(UserId("value", "domain")))))
.withIsAppLockSetup(false)
.arrange()
advanceUntilIdle()

assertEquals(false, viewModel.featureFlagState.shouldShowTeamAppLockDialog)
}

@Test
fun givenE2EIRequired_thenShowDialog() = runTest {
val (_, viewModel) = Arrangement()
Expand Down
2 changes: 1 addition & 1 deletion kalium
Submodule kalium updated 920 files
Loading