mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
[PM-12319] Skip Auto-fill setup if already enabled. (#3934)
This commit is contained in:
parent
c8b1b71960
commit
71d3ae9ee8
2 changed files with 46 additions and 3 deletions
|
@ -176,7 +176,12 @@ class SetupUnlockViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun updateOnboardingStatusToNextStep() {
|
||||
authRepository.setOnboardingStatus(state.userId, OnboardingStatus.AUTOFILL_SETUP)
|
||||
val nextStep = if (settingsRepository.isAutofillEnabledStateFlow.value) {
|
||||
OnboardingStatus.FINAL_STEP
|
||||
} else {
|
||||
OnboardingStatus.AUTOFILL_SETUP
|
||||
}
|
||||
authRepository.setOnboardingStatus(state.userId, nextStep)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import io.mockk.mockk
|
|||
import io.mockk.runs
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
@ -33,9 +34,12 @@ class SetupUnlockViewModelTest : BaseViewModelTest() {
|
|||
every { userStateFlow } returns mutableUserStateFlow
|
||||
every { setOnboardingStatus(userId = any(), status = any()) } just runs
|
||||
}
|
||||
|
||||
private val mutableAutofillEnabledStateFlow = MutableStateFlow(false)
|
||||
private val settingsRepository = mockk<SettingsRepository> {
|
||||
every { isUnlockWithPinEnabled } returns false
|
||||
every { isUnlockWithBiometricsEnabled } returns false
|
||||
every { isAutofillEnabledStateFlow } returns mutableAutofillEnabledStateFlow
|
||||
}
|
||||
private val biometricsEncryptionManager: BiometricsEncryptionManager = mockk {
|
||||
every { getOrCreateCipher(userId = DEFAULT_USER_ID) } returns CIPHER
|
||||
|
@ -51,8 +55,10 @@ class SetupUnlockViewModelTest : BaseViewModelTest() {
|
|||
assertEquals(DEFAULT_STATE, viewModel.stateFlow.value)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `ContinueClick should call setOnboardingStatus`() = runTest {
|
||||
fun `ContinueClick should call setOnboardingStatus and set to AUTOFILL_SETUP if AutoFill is not enabled`() =
|
||||
runTest {
|
||||
val viewModel = createViewModel()
|
||||
viewModel.trySendAction(SetupUnlockAction.ContinueClick)
|
||||
verify {
|
||||
|
@ -63,8 +69,10 @@ class SetupUnlockViewModelTest : BaseViewModelTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `SetUpLaterClick should call setOnboardingStatus`() = runTest {
|
||||
fun `SetUpLaterClick should call setOnboardingStatus and set to AUTOFILL_SETUP if AutoFill is not enabled`() =
|
||||
runTest {
|
||||
val viewModel = createViewModel()
|
||||
viewModel.trySendAction(SetupUnlockAction.SetUpLaterClick)
|
||||
verify {
|
||||
|
@ -75,6 +83,36 @@ class SetupUnlockViewModelTest : BaseViewModelTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `ContinueClick should call setOnboardingStatus and set to FINAL_STEP if AutoFill is already enabled`() =
|
||||
runTest {
|
||||
mutableAutofillEnabledStateFlow.update { true }
|
||||
val viewModel = createViewModel()
|
||||
viewModel.trySendAction(SetupUnlockAction.ContinueClick)
|
||||
verify {
|
||||
authRepository.setOnboardingStatus(
|
||||
userId = DEFAULT_USER_ID,
|
||||
status = OnboardingStatus.FINAL_STEP,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `SetUpLaterClick should call setOnboardingStatus and set to FINAL_STEP if AutoFill is already enabled`() =
|
||||
runTest {
|
||||
mutableAutofillEnabledStateFlow.update { true }
|
||||
val viewModel = createViewModel()
|
||||
viewModel.trySendAction(SetupUnlockAction.SetUpLaterClick)
|
||||
verify {
|
||||
authRepository.setOnboardingStatus(
|
||||
userId = DEFAULT_USER_ID,
|
||||
status = OnboardingStatus.FINAL_STEP,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on UnlockWithBiometricToggle false should call clearBiometricsKey and update the state`() =
|
||||
runTest {
|
||||
|
|
Loading…
Reference in a new issue