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

Add extra phone number length validation for link inline signup #8266

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ internal class InlineSignupViewModel @Inject constructor(
): UserInput? {
val signUpMode = initialViewState.signupMode

return if (email != null && phoneNumber != null && signUpMode != null) {
val isNameValid = !requiresNameCollection || !name.isNullOrBlank()
val isNameValid = !requiresNameCollection || !name.isNullOrBlank()
val isPhoneNumberValid = phoneController.isComplete.value

return if (email != null && phoneNumber != null && signUpMode != null && isNameValid && isPhoneNumberValid) {
val phone = phoneController.getE164PhoneNumber(phoneNumber)
val country = phoneController.getCountryCode()

Expand All @@ -204,7 +205,7 @@ internal class InlineSignupViewModel @Inject constructor(
hasPrefilledEmail = prefilledEmail != null,
hasPrefilledPhone = prefilledPhone.isNotBlank(),
)
).takeIf { isNameValid }
)
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,20 @@ class InlineSignupViewModelTest {
)
}

@Test
fun `Sign up not attempted if phone number is too short`() =
runTest(UnconfinedTestDispatcher()) {
val viewModel = createViewModel(countryCode = CountryCode.US)

viewModel.toggleExpanded()
viewModel.emailController.onRawValueChange("[email protected]")
viewModel.phoneController.onRawValueChange("800867530")

assertThat(viewModel.viewState.value.userInput).isNull()
}



@Test
fun `Prefilled values are handled correctly`() = runTest(UnconfinedTestDispatcher()) {
val viewModel = createViewModel(
Expand Down