mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
BIT-1663: Display toast when auth request is declined or approved (#968)
This commit is contained in:
parent
8cb167d522
commit
b8e2f7856a
2 changed files with 20 additions and 3 deletions
|
@ -99,7 +99,7 @@ class LoginApprovalViewModel @Inject constructor(
|
||||||
private fun handleApproveRequestClicked() {
|
private fun handleApproveRequestClicked() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
trySendAction(
|
trySendAction(
|
||||||
LoginApprovalAction.Internal.DeclineRequestResultReceive(
|
LoginApprovalAction.Internal.ApproveRequestResultReceive(
|
||||||
result = authRepository.updateAuthRequest(
|
result = authRepository.updateAuthRequest(
|
||||||
requestId = mutableStateFlow.value.requestId,
|
requestId = mutableStateFlow.value.requestId,
|
||||||
masterPasswordHash = mutableStateFlow.value.masterPasswordHash,
|
masterPasswordHash = mutableStateFlow.value.masterPasswordHash,
|
||||||
|
@ -195,6 +195,7 @@ class LoginApprovalViewModel @Inject constructor(
|
||||||
) {
|
) {
|
||||||
when (action.result) {
|
when (action.result) {
|
||||||
is AuthRequestResult.Success -> {
|
is AuthRequestResult.Success -> {
|
||||||
|
sendEvent(LoginApprovalEvent.ShowToast(R.string.log_in_denied.asText()))
|
||||||
sendEvent(LoginApprovalEvent.NavigateBack)
|
sendEvent(LoginApprovalEvent.NavigateBack)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.x8bit.bitwarden.ui.platform.feature.settings.accountsecurity.loginap
|
||||||
|
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import app.cash.turbine.test
|
import app.cash.turbine.test
|
||||||
|
import com.x8bit.bitwarden.R
|
||||||
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
|
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
|
||||||
import com.x8bit.bitwarden.data.auth.repository.model.AuthRequest
|
import com.x8bit.bitwarden.data.auth.repository.model.AuthRequest
|
||||||
import com.x8bit.bitwarden.data.auth.repository.model.AuthRequestResult
|
import com.x8bit.bitwarden.data.auth.repository.model.AuthRequestResult
|
||||||
|
@ -13,6 +14,7 @@ import com.x8bit.bitwarden.data.platform.manager.model.SpecialCircumstance
|
||||||
import com.x8bit.bitwarden.data.platform.repository.model.Environment
|
import com.x8bit.bitwarden.data.platform.repository.model.Environment
|
||||||
import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow
|
import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow
|
||||||
import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest
|
import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest
|
||||||
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
import io.mockk.coEvery
|
import io.mockk.coEvery
|
||||||
import io.mockk.coVerify
|
import io.mockk.coVerify
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
|
@ -176,7 +178,14 @@ class LoginApprovalViewModelTest : BaseViewModelTest() {
|
||||||
)
|
)
|
||||||
} returns AuthRequestResult.Success(AUTH_REQUEST)
|
} returns AuthRequestResult.Success(AUTH_REQUEST)
|
||||||
|
|
||||||
viewModel.trySendAction(LoginApprovalAction.ApproveRequestClick)
|
viewModel.eventFlow.test {
|
||||||
|
viewModel.trySendAction(LoginApprovalAction.ApproveRequestClick)
|
||||||
|
assertEquals(
|
||||||
|
LoginApprovalEvent.ShowToast(R.string.login_approved.asText()),
|
||||||
|
awaitItem(),
|
||||||
|
)
|
||||||
|
assertEquals(LoginApprovalEvent.NavigateBack, awaitItem())
|
||||||
|
}
|
||||||
|
|
||||||
coVerify {
|
coVerify {
|
||||||
mockAuthRepository.updateAuthRequest(
|
mockAuthRepository.updateAuthRequest(
|
||||||
|
@ -200,7 +209,14 @@ class LoginApprovalViewModelTest : BaseViewModelTest() {
|
||||||
)
|
)
|
||||||
} returns AuthRequestResult.Success(AUTH_REQUEST)
|
} returns AuthRequestResult.Success(AUTH_REQUEST)
|
||||||
|
|
||||||
viewModel.trySendAction(LoginApprovalAction.DeclineRequestClick)
|
viewModel.eventFlow.test {
|
||||||
|
viewModel.trySendAction(LoginApprovalAction.DeclineRequestClick)
|
||||||
|
assertEquals(
|
||||||
|
LoginApprovalEvent.ShowToast(R.string.log_in_denied.asText()),
|
||||||
|
awaitItem(),
|
||||||
|
)
|
||||||
|
assertEquals(LoginApprovalEvent.NavigateBack, awaitItem())
|
||||||
|
}
|
||||||
|
|
||||||
coVerify {
|
coVerify {
|
||||||
mockAuthRepository.updateAuthRequest(
|
mockAuthRepository.updateAuthRequest(
|
||||||
|
|
Loading…
Reference in a new issue