diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/teammigration/TeamMigrationViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/teammigration/TeamMigrationViewModel.kt index b4080251aa6..818a70b9b27 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/teammigration/TeamMigrationViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/teammigration/TeamMigrationViewModel.kt @@ -95,7 +95,7 @@ class TeamMigrationViewModel @Inject constructor( fun migrateFromPersonalToTeamAccount(onSuccess: () -> Unit) { viewModelScope.launch { migrateFromPersonalToTeam.invoke( - teamMigrationState.teamNameTextState.text.toString(), + teamMigrationState.teamNameTextState.text.trim().toString(), ).let { result -> when (result) { is MigrateFromPersonalToTeamResult.Success -> { diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/teammigration/step2/TeamMigrationTeamNameStepScreen.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/teammigration/step2/TeamMigrationTeamNameStepScreen.kt index aa1e8a9ecf6..da3d8ab4504 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/teammigration/step2/TeamMigrationTeamNameStepScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/teammigration/step2/TeamMigrationTeamNameStepScreen.kt @@ -129,7 +129,7 @@ private fun TeamMigrationTeamNameStepScreenContent( textFieldState = teamNameTextFieldState, ) } - val isContinueButtonEnabled = teamNameTextFieldState.text.isNotEmpty() + val isContinueButtonEnabled = teamNameTextFieldState.text.isNotEmpty() && teamNameTextFieldState.text.isNotBlank() BottomLineButtons( isContinueButtonEnabled = isContinueButtonEnabled, onContinue = onContinueButtonClicked, diff --git a/app/src/test/kotlin/com/wire/android/ui/userprofile/teammigration/TeamMigrationViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/userprofile/teammigration/TeamMigrationViewModelTest.kt index 42a7a926e05..ef00ce0c20c 100644 --- a/app/src/test/kotlin/com/wire/android/ui/userprofile/teammigration/TeamMigrationViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/userprofile/teammigration/TeamMigrationViewModelTest.kt @@ -243,6 +243,22 @@ class TeamMigrationViewModelTest { Assertions.assertNull(viewModel.teamMigrationState.migrationFailure) } + @Test + fun `given team name with spaces at start or end, when invoking migration, then trim the name`() = runTest { + // given + val (arrangement, viewModel) = Arrangement() + .withMigrateFromPersonalToTeamSuccess() + .arrange() + val onSuccess = {} + viewModel.teamMigrationState.teamNameTextState.setTextAndPlaceCursorAtEnd(" ${Arrangement.TEAM_NAME} ") + // when + viewModel.migrateFromPersonalToTeamAccount(onSuccess) + // then + coVerify(exactly = 1) { + arrangement.migrateFromPersonalToTeam(Arrangement.TEAM_NAME) + } + } + private class Arrangement { @MockK