mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 07:11:51 +03:00
[PM-9755] Change error message from a toast to a dialog (#3963)
This commit is contained in:
parent
72cb9918ac
commit
9d19a73fd6
2 changed files with 29 additions and 12 deletions
|
@ -205,11 +205,18 @@ class TwoFactorLoginViewModel @Inject constructor(
|
|||
-> {
|
||||
val authUrl = authRepository.twoFactorResponse.twoFactorDuoAuthUrl
|
||||
// The url should not be empty unless the environment is somehow not supported.
|
||||
sendEvent(
|
||||
event = authUrl
|
||||
?.let { TwoFactorLoginEvent.NavigateToDuo(uri = Uri.parse(it)) }
|
||||
?: TwoFactorLoginEvent.ShowToast(R.string.error_connecting_with_the_duo_service_use_a_different_two_step_login_method_or_contact_duo_for_assistance.asText()),
|
||||
)
|
||||
authUrl
|
||||
?.let {
|
||||
sendEvent(event = TwoFactorLoginEvent.NavigateToDuo(uri = Uri.parse(it)))
|
||||
}
|
||||
?: mutableStateFlow.update {
|
||||
it.copy(
|
||||
dialogState = TwoFactorLoginState.DialogState.Error(
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.error_connecting_with_the_duo_service_use_a_different_two_step_login_method_or_contact_duo_for_assistance.asText(),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
TwoFactorAuthMethod.WEB_AUTH -> {
|
||||
|
|
|
@ -362,7 +362,7 @@ class TwoFactorLoginViewModelTest : BaseViewModelTest() {
|
|||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `ContinueButtonClick login should emit ShowToast when auth method is Duo and authUrl is null`() =
|
||||
fun `ContinueButtonClick login should show a dialog when auth method is Duo and authUrl is null`() =
|
||||
runTest {
|
||||
val authMethodsData = mapOf(
|
||||
TwoFactorAuthMethod.DUO to JsonObject(
|
||||
|
@ -376,15 +376,25 @@ class TwoFactorLoginViewModelTest : BaseViewModelTest() {
|
|||
twoFactorProviders = null,
|
||||
)
|
||||
every { authRepository.twoFactorResponse } returns response
|
||||
val viewModel = createViewModel(
|
||||
state = DEFAULT_STATE.copy(
|
||||
authMethod = TwoFactorAuthMethod.DUO,
|
||||
),
|
||||
val state = DEFAULT_STATE.copy(
|
||||
authMethod = TwoFactorAuthMethod.DUO,
|
||||
)
|
||||
viewModel.eventFlow.test {
|
||||
val viewModel = createViewModel(
|
||||
state = state,
|
||||
)
|
||||
viewModel.stateFlow.test {
|
||||
assertEquals(
|
||||
state,
|
||||
awaitItem(),
|
||||
)
|
||||
viewModel.trySendAction(TwoFactorLoginAction.ContinueButtonClick)
|
||||
assertEquals(
|
||||
TwoFactorLoginEvent.ShowToast(R.string.error_connecting_with_the_duo_service_use_a_different_two_step_login_method_or_contact_duo_for_assistance.asText()),
|
||||
state.copy(
|
||||
dialogState = TwoFactorLoginState.DialogState.Error(
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.error_connecting_with_the_duo_service_use_a_different_two_step_login_method_or_contact_duo_for_assistance.asText(),
|
||||
),
|
||||
),
|
||||
awaitItem(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue