@@ -72,6 +72,8 @@ private val SELECTED_HOMESERVER_STATE = SelectedHomeserverState(preferredLoginMo
7272private val SELECTED_HOMESERVER_STATE_SUPPORTED_LOGOUT_DEVICES = SelectedHomeserverState (isLogoutDevicesSupported = true )
7373private const val AN_EMAIL = " [email protected] " 7474private const val A_PASSWORD = " a-password"
75+ private const val A_USERNAME = " hello-world"
76+ private const val A_MATRIX_ID = " @$A_USERNAME :matrix.org"
7577
7678class OnboardingViewModelTest {
7779
@@ -405,15 +407,6 @@ class OnboardingViewModelTest {
405407 .finish()
406408 }
407409
408- private fun availableRegistrationState (userName : String , homeServerUrl : String ) = RegistrationState (
409- isUserNameAvailable = true ,
410- selectedMatrixId = " @$userName :${homeServerUrl.removePrefix(" https://" )} "
411- )
412-
413- private fun initialRegistrationState (homeServerUrl : String ) = initialState.copy(
414- onboardingFlow = OnboardingFlow .SignUp , selectedHomeserver = SelectedHomeserverState (userFacingUrl = homeServerUrl)
415- )
416-
417410 @Test
418411 fun `given in the sign up flow, when editing homeserver errors, then does not update the selected homeserver state and emits error` () = runTest {
419412 viewModelWith(initialState.copy(onboardingFlow = OnboardingFlow .SignUp ))
@@ -433,7 +426,8 @@ class OnboardingViewModelTest {
433426 }
434427
435428 @Test
436- fun `given personalisation enabled, when registering account, then updates state and emits account created event` () = runTest {
429+ fun `given matrix id and personalisation enabled, when registering account, then updates state and emits account created event` () = runTest {
430+ viewModelWith(initialState.copy(registrationState = RegistrationState (selectedMatrixId = A_MATRIX_ID )))
437431 fakeVectorFeatures.givenPersonalisationEnabled()
438432 givenSuccessfullyCreatesAccount(A_HOMESERVER_CAPABILITIES )
439433 givenRegistrationResultFor(RegisterAction .StartRegistration , RegistrationActionHandler .Result .RegistrationComplete (fakeSession))
@@ -445,7 +439,7 @@ class OnboardingViewModelTest {
445439 .assertStatesChanges(
446440 initialState,
447441 { copy(isLoading = true ) },
448- { copy(isLoading = false , personalizationState = A_HOMESERVER_CAPABILITIES .toPersonalisationState()) }
442+ { copy(isLoading = false , personalizationState = A_HOMESERVER_CAPABILITIES .toPersonalisationState(A_USERNAME )) }
449443 )
450444 .assertEvents(OnboardingViewEvents .OnAccountCreated )
451445 .finish()
@@ -738,9 +732,20 @@ class OnboardingViewModelTest {
738732 private fun givenUserNameIsUnavailable (userName : String , failure : Failure .ServerError ) {
739733 fakeAuthenticationService.givenRegistrationWizard(FakeRegistrationWizard ().also { it.givenUserNameIsUnavailable(userName, failure) })
740734 }
735+
736+ private fun availableRegistrationState (userName : String , homeServerUrl : String ) = RegistrationState (
737+ isUserNameAvailable = true ,
738+ selectedMatrixId = " @$userName :${homeServerUrl.removePrefix(" https://" )} "
739+ )
740+
741+ private fun initialRegistrationState (homeServerUrl : String ) = initialState.copy(
742+ onboardingFlow = OnboardingFlow .SignUp , selectedHomeserver = SelectedHomeserverState (userFacingUrl = homeServerUrl)
743+ )
744+
741745}
742746
743- private fun HomeServerCapabilities.toPersonalisationState () = PersonalizationState (
747+ private fun HomeServerCapabilities.toPersonalisationState (displayName : String? = null ) = PersonalizationState (
744748 supportsChangingDisplayName = canChangeDisplayName,
745- supportsChangingProfilePicture = canChangeAvatar
749+ supportsChangingProfilePicture = canChangeAvatar,
750+ displayName = displayName,
746751)
0 commit comments