Skip to content

Commit

Permalink
fix: allowing empty team name when migrating [WPB-15092] (#3763)
Browse files Browse the repository at this point in the history
  • Loading branch information
saleniuk authored Dec 20, 2024
1 parent df5ef14 commit 4427e89
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,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
Expand Down

0 comments on commit 4427e89

Please sign in to comment.