Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allowing empty team name when migrating [WPB-15092] 🍒 #3764

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading