Skip to content

Commit

Permalink
fix: allowing empty team name when migrating [WPB-15092] 🍒 (#3764)
Browse files Browse the repository at this point in the history
Co-authored-by: Michał Saleniuk <[email protected]>
Co-authored-by: Michał Saleniuk <[email protected]>
  • Loading branch information
3 people authored Dec 23, 2024
1 parent a8898c2 commit 8847c15
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 @@ -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 -> {
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 @@ -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
Expand Down

0 comments on commit 8847c15

Please sign in to comment.