mirror of
https://github.com/bitwarden/android.git
synced 2026-04-29 20:38:41 -05:00
Clear MP field when switching account on unlock screen (#1178)
This commit is contained in:
committed by
Álison Fernandes
parent
166a39354a
commit
9253a7b682
@@ -259,6 +259,7 @@ class VaultUnlockViewModel @Inject constructor(
|
|||||||
email = activeAccountSummary.email,
|
email = activeAccountSummary.email,
|
||||||
isBiometricEnabled = userState.activeAccount.isBiometricsEnabled,
|
isBiometricEnabled = userState.activeAccount.isBiometricsEnabled,
|
||||||
vaultUnlockType = userState.activeAccount.vaultUnlockType,
|
vaultUnlockType = userState.activeAccount.vaultUnlockType,
|
||||||
|
input = "",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import com.x8bit.bitwarden.data.vault.repository.model.VaultUnlockResult
|
|||||||
import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest
|
import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
import com.x8bit.bitwarden.ui.platform.components.model.AccountSummary
|
import com.x8bit.bitwarden.ui.platform.components.model.AccountSummary
|
||||||
|
import com.x8bit.bitwarden.ui.vault.feature.vault.util.toAccountSummary
|
||||||
import io.mockk.coEvery
|
import io.mockk.coEvery
|
||||||
import io.mockk.coVerify
|
import io.mockk.coVerify
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
@@ -31,6 +32,7 @@ import kotlinx.coroutines.test.runTest
|
|||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
@Suppress("LargeClass")
|
||||||
class VaultUnlockViewModelTest : BaseViewModelTest() {
|
class VaultUnlockViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
private val mutableUserStateFlow = MutableStateFlow<UserState?>(DEFAULT_USER_STATE)
|
private val mutableUserStateFlow = MutableStateFlow<UserState?>(DEFAULT_USER_STATE)
|
||||||
@@ -181,6 +183,35 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `UserState updates with a non-null locked account should clear view state input`() {
|
||||||
|
val password = "abc1234"
|
||||||
|
val initialState = DEFAULT_STATE.copy(
|
||||||
|
input = password,
|
||||||
|
accountSummaries = listOf(
|
||||||
|
DEFAULT_ACCOUNT.copy(isVaultUnlocked = false)
|
||||||
|
.toAccountSummary(true),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
val viewModel = createViewModel(state = initialState)
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
initialState,
|
||||||
|
viewModel.stateFlow.value,
|
||||||
|
)
|
||||||
|
|
||||||
|
mutableUserStateFlow.value = DEFAULT_USER_STATE.copy(
|
||||||
|
accounts = listOf(
|
||||||
|
DEFAULT_ACCOUNT.copy(isVaultUnlocked = false),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
initialState.copy(input = ""),
|
||||||
|
viewModel.stateFlow.value,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `on AddAccountClick should set hasPendingAccountAddition to true on the AuthRepository`() {
|
fun `on AddAccountClick should set hasPendingAccountAddition to true on the AuthRepository`() {
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
|
|||||||
Reference in New Issue
Block a user