mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
[PM-6702] Add email verification feature flag to landing create account click
This commit is contained in:
parent
bd55b9ce72
commit
1d05f5f758
2 changed files with 32 additions and 2 deletions
|
@ -6,6 +6,8 @@ import androidx.lifecycle.viewModelScope
|
||||||
import com.x8bit.bitwarden.R
|
import com.x8bit.bitwarden.R
|
||||||
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
|
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
|
||||||
import com.x8bit.bitwarden.data.auth.repository.model.UserState
|
import com.x8bit.bitwarden.data.auth.repository.model.UserState
|
||||||
|
import com.x8bit.bitwarden.data.platform.manager.FeatureFlagManager
|
||||||
|
import com.x8bit.bitwarden.data.platform.manager.model.FlagKey
|
||||||
import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository
|
import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository
|
||||||
import com.x8bit.bitwarden.data.platform.repository.model.Environment
|
import com.x8bit.bitwarden.data.platform.repository.model.Environment
|
||||||
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
|
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
|
||||||
|
@ -34,6 +36,7 @@ class LandingViewModel @Inject constructor(
|
||||||
private val authRepository: AuthRepository,
|
private val authRepository: AuthRepository,
|
||||||
private val vaultRepository: VaultRepository,
|
private val vaultRepository: VaultRepository,
|
||||||
private val environmentRepository: EnvironmentRepository,
|
private val environmentRepository: EnvironmentRepository,
|
||||||
|
private val featureFlagManager: FeatureFlagManager,
|
||||||
savedStateHandle: SavedStateHandle,
|
savedStateHandle: SavedStateHandle,
|
||||||
) : BaseViewModel<LandingState, LandingEvent, LandingAction>(
|
) : BaseViewModel<LandingState, LandingEvent, LandingAction>(
|
||||||
initialState = savedStateHandle[KEY_STATE]
|
initialState = savedStateHandle[KEY_STATE]
|
||||||
|
@ -191,8 +194,11 @@ class LandingViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleCreateAccountClicked() {
|
private fun handleCreateAccountClicked() {
|
||||||
// TODO PM-9401: ADD FEATURE FLAG email-verification and navigation to StartRegistration
|
if (featureFlagManager.getFeatureFlag(FlagKey.EmailVerification)) {
|
||||||
sendEvent(LandingEvent.NavigateToCreateAccount)
|
sendEvent(LandingEvent.NavigateToStartRegistration)
|
||||||
|
} else {
|
||||||
|
sendEvent(LandingEvent.NavigateToCreateAccount)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleDialogDismiss() {
|
private fun handleDialogDismiss() {
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.x8bit.bitwarden.R
|
||||||
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
|
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
|
||||||
import com.x8bit.bitwarden.data.auth.repository.model.UserState
|
import com.x8bit.bitwarden.data.auth.repository.model.UserState
|
||||||
import com.x8bit.bitwarden.data.auth.repository.model.VaultUnlockType
|
import com.x8bit.bitwarden.data.auth.repository.model.VaultUnlockType
|
||||||
|
import com.x8bit.bitwarden.data.platform.manager.FeatureFlagManager
|
||||||
|
import com.x8bit.bitwarden.data.platform.manager.model.FlagKey
|
||||||
import com.x8bit.bitwarden.data.platform.repository.model.Environment
|
import com.x8bit.bitwarden.data.platform.repository.model.Environment
|
||||||
import com.x8bit.bitwarden.data.platform.repository.util.FakeEnvironmentRepository
|
import com.x8bit.bitwarden.data.platform.repository.util.FakeEnvironmentRepository
|
||||||
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
|
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
|
||||||
|
@ -34,6 +36,7 @@ class LandingViewModelTest : BaseViewModelTest() {
|
||||||
every { lockVault(any()) } just runs
|
every { lockVault(any()) } just runs
|
||||||
}
|
}
|
||||||
private val fakeEnvironmentRepository = FakeEnvironmentRepository()
|
private val fakeEnvironmentRepository = FakeEnvironmentRepository()
|
||||||
|
private val featureFlagManager: FeatureFlagManager = mockk()
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `initial state should be correct when there is no remembered email`() = runTest {
|
fun `initial state should be correct when there is no remembered email`() = runTest {
|
||||||
|
@ -358,6 +361,9 @@ class LandingViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `CreateAccountClick should emit NavigateToCreateAccount`() = runTest {
|
fun `CreateAccountClick should emit NavigateToCreateAccount`() = runTest {
|
||||||
|
every {
|
||||||
|
featureFlagManager.getFeatureFlag(FlagKey.EmailVerification)
|
||||||
|
} returns false
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
viewModel.eventFlow.test {
|
viewModel.eventFlow.test {
|
||||||
viewModel.trySendAction(LandingAction.CreateAccountClick)
|
viewModel.trySendAction(LandingAction.CreateAccountClick)
|
||||||
|
@ -368,6 +374,23 @@ class LandingViewModelTest : BaseViewModelTest() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("MaxLineLength")
|
||||||
|
@Test
|
||||||
|
fun `CreateAccountClick should emit NavigateToStartRegistration if EmailVerification feature flag is true`() =
|
||||||
|
runTest {
|
||||||
|
every {
|
||||||
|
featureFlagManager.getFeatureFlag(FlagKey.EmailVerification)
|
||||||
|
} returns true
|
||||||
|
val viewModel = createViewModel()
|
||||||
|
viewModel.eventFlow.test {
|
||||||
|
viewModel.trySendAction(LandingAction.CreateAccountClick)
|
||||||
|
assertEquals(
|
||||||
|
LandingEvent.NavigateToStartRegistration,
|
||||||
|
awaitItem(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `DialogDismiss should clear the active dialog`() {
|
fun `DialogDismiss should clear the active dialog`() {
|
||||||
val initialState = DEFAULT_STATE.copy(
|
val initialState = DEFAULT_STATE.copy(
|
||||||
|
@ -543,6 +566,7 @@ class LandingViewModelTest : BaseViewModelTest() {
|
||||||
},
|
},
|
||||||
vaultRepository = vaultRepository,
|
vaultRepository = vaultRepository,
|
||||||
environmentRepository = fakeEnvironmentRepository,
|
environmentRepository = fakeEnvironmentRepository,
|
||||||
|
featureFlagManager = featureFlagManager,
|
||||||
savedStateHandle = savedStateHandle,
|
savedStateHandle = savedStateHandle,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue