diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/twofactorlogin/TwoFactorLoginViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/twofactorlogin/TwoFactorLoginViewModelTest.kt index fc95e971ff7..c7ba138fb94 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/twofactorlogin/TwoFactorLoginViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/twofactorlogin/TwoFactorLoginViewModelTest.kt @@ -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 {