mirror of
https://github.com/bitwarden/android.git
synced 2026-04-26 19:08:37 -05:00
[PM-8223] 🍒 New device verification continue button enabled at 8 digit (#4802)
This commit is contained in:
@@ -189,10 +189,12 @@ class TwoFactorLoginViewModel @Inject constructor(
|
||||
* Update the state with the new text and enable or disable the continue button.
|
||||
*/
|
||||
private fun handleCodeInputChanged(action: TwoFactorLoginAction.CodeInputChanged) {
|
||||
@Suppress("MagicNumber")
|
||||
val minLength = if (state.isNewDeviceVerification) 8 else 6
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
codeInput = action.input,
|
||||
isContinueButtonEnabled = action.input.length >= 6,
|
||||
isContinueButtonEnabled = action.input.length >= minLength,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,6 +310,33 @@ class TwoFactorLoginViewModelTest : BaseViewModelTest() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `Continue buttons should only be enabled when code is 8 digit enough on isNewDeviceVerification`() {
|
||||
val initialState = DEFAULT_STATE.copy(isNewDeviceVerification = true)
|
||||
val viewModel = createViewModel(initialState)
|
||||
viewModel.trySendAction(TwoFactorLoginAction.CodeInputChanged("123456"))
|
||||
|
||||
// 6 digit should be false when isNewDeviceVerification is true.
|
||||
assertEquals(
|
||||
initialState.copy(
|
||||
codeInput = "123456",
|
||||
isContinueButtonEnabled = false,
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
|
||||
// Set it to true.
|
||||
viewModel.trySendAction(TwoFactorLoginAction.CodeInputChanged("12345678"))
|
||||
assertEquals(
|
||||
initialState.copy(
|
||||
codeInput = "12345678",
|
||||
isContinueButtonEnabled = true,
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ContinueButtonClick login returns success should update loadingDialogState`() = runTest {
|
||||
coEvery {
|
||||
|
||||
Reference in New Issue
Block a user