BIT-2156: auto-prompt the user for biometrics (#1307)

This commit is contained in:
David Perez
2024-06-20 17:08:07 +01:00
committed by Álison Fernandes
parent bb1fd4ae4f
commit bde338ef44
4 changed files with 71 additions and 14 deletions
@@ -75,6 +75,19 @@ class VaultUnlockScreenTest : BaseComposeTest() {
}
}
@Test
fun `on PromptForBiometrics should call launchUri on intentManager`() {
mutableEventFlow.tryEmit(VaultUnlockEvent.PromptForBiometrics)
verify {
biometricsManager.promptBiometrics(
onSuccess = any(),
onCancel = any(),
onError = any(),
onLockOut = any(),
)
}
}
@Test
fun `account icon click should show the account switcher`() {
composeTestRule.assertSwitcherIsNotDisplayed(
@@ -1,6 +1,7 @@
package com.x8bit.bitwarden.ui.auth.feature.vaultunlock
import androidx.lifecycle.SavedStateHandle
import app.cash.turbine.test
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.auth.datasource.disk.model.EnvironmentUrlDataJson
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
@@ -54,6 +55,19 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
every { isBiometricIntegrityValid(userId = DEFAULT_USER_STATE.activeUserId) } returns true
}
@Test
fun `on init with biometrics enabled and valid should emit PromptForBiometrics`() = runTest {
val initialState = DEFAULT_STATE.copy(
isBiometricEnabled = true,
isBiometricsValid = true,
)
val viewModel = createViewModel(state = initialState)
viewModel.eventFlow.test {
assertEquals(VaultUnlockEvent.PromptForBiometrics, awaitItem())
}
}
@Test
fun `initial state should be correct when not set`() {
val viewModel = createViewModel()