fixing wrong action for starting the sign up

This commit is contained in:
Adam Brown 2022-03-04 14:00:59 +00:00
parent fc5c0579bb
commit fe206fe130
2 changed files with 20 additions and 1 deletions

View File

@ -373,7 +373,7 @@ class OnboardingViewModel @AssistedInject constructor(
}
when (action.signMode) {
SignMode.SignUp -> handleRegisterAction(RegisterAction.RegisterDummy)
SignMode.SignUp -> handleRegisterAction(RegisterAction.StartRegistration)
SignMode.SignIn -> startAuthenticationFlow()
SignMode.SignInWithMatrixId -> _viewEvents.post(OnboardingViewEvents.OnSignModeSelected(SignMode.SignInWithMatrixId))
SignMode.Unknown -> Unit

View File

@ -23,6 +23,7 @@ import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized
import com.airbnb.mvrx.test.MvRxTestRule
import im.vector.app.features.login.ReAuthHelper
import im.vector.app.features.login.SignMode
import im.vector.app.test.fakes.FakeActiveSessionHolder
import im.vector.app.test.fakes.FakeAnalyticsTracker
import im.vector.app.test.fakes.FakeAuthenticationService
@ -117,6 +118,24 @@ class OnboardingViewModelTest {
.finish()
}
@Test
fun `when handling SignUp then sets sign mode to sign up and starts registration`() = runBlockingTest {
givenRegistrationResultFor(RegisterAction.StartRegistration, ANY_CONTINUING_REGISTRATION_RESULT)
val test = viewModel.test(this)
viewModel.handle(OnboardingAction.UpdateSignMode(SignMode.SignUp))
test
.assertStatesWithPrevious(
initialState,
{ copy(signMode = SignMode.SignUp) },
{ copy(asyncRegistration = Loading()) },
{ copy(asyncRegistration = Uninitialized) }
)
.assertEvents(OnboardingViewEvents.RegistrationFlowResult(ANY_CONTINUING_REGISTRATION_RESULT.flowResult, isRegistrationStarted = true))
.finish()
}
@Test
fun `given register action requires more steps, when handling action, then posts next steps`() = runBlockingTest {
val test = viewModel.test(this)