mirror of
https://github.com/bitwarden/android.git
synced 2026-11-20 11:37:52 -06:00
BIT-1411, BIT-1414: Add delete send confirmation dialog (#680)
This commit is contained in:
committed by
Álison Fernandes
parent
a706db2b28
commit
2fa7851b42
+30
@@ -605,6 +605,36 @@ class VaultItemListingScreenTest : BaseComposeTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `delete send confirmation dialog should be displayed according to state and emits DeleteSendConfirmClick on confirmation`() {
|
||||
val sendId = "sendId"
|
||||
val message = "Are you sure you want to delete this Send?"
|
||||
composeTestRule.onNode(isDialog()).assertDoesNotExist()
|
||||
composeTestRule.onNodeWithText(message).assertDoesNotExist()
|
||||
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
dialogState = VaultItemListingState.DialogState.DeleteSendConfirmation(
|
||||
sendId = sendId,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText(message)
|
||||
.assertIsDisplayed()
|
||||
.assert(hasAnyAncestor(isDialog()))
|
||||
composeTestRule
|
||||
.onNodeWithText("Yes")
|
||||
.assert(hasAnyAncestor(isDialog()))
|
||||
.performClick()
|
||||
|
||||
verify(exactly = 1) {
|
||||
viewModel.trySendAction(VaultItemListingsAction.DeleteSendConfirmClick(sendId))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `error dialog should be displayed according to state`() {
|
||||
val errorMessage = "Fail"
|
||||
|
||||
+19
-4
@@ -200,14 +200,29 @@ class VaultItemListingViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `DeleteSendClick with deleteSend error should display error dialog`() = runTest {
|
||||
fun `DeleteSendClick should display delete confirmation dialog`() {
|
||||
val sendId = "sendId"
|
||||
val viewModel = createVaultItemListingViewModel()
|
||||
viewModel.trySendAction(VaultItemListingsAction.DeleteSendClick(sendId))
|
||||
assertEquals(
|
||||
initialState.copy(
|
||||
dialogState = VaultItemListingState.DialogState.DeleteSendConfirmation(
|
||||
sendId = sendId,
|
||||
),
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `DeleteSendConfirmClick with deleteSend error should display error dialog`() = runTest {
|
||||
val sendId = "sendId1234"
|
||||
coEvery { vaultRepository.deleteSend(sendId) } returns DeleteSendResult.Error
|
||||
|
||||
val viewModel = createVaultItemListingViewModel()
|
||||
viewModel.stateFlow.test {
|
||||
assertEquals(initialState, awaitItem())
|
||||
viewModel.trySendAction(VaultItemListingsAction.DeleteSendClick(sendId))
|
||||
viewModel.trySendAction(VaultItemListingsAction.DeleteSendConfirmClick(sendId))
|
||||
assertEquals(
|
||||
initialState.copy(
|
||||
dialogState = VaultItemListingState.DialogState.Loading(
|
||||
@@ -229,13 +244,13 @@ class VaultItemListingViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `DeleteSendClick with deleteSend success should emit ShowToast`() = runTest {
|
||||
fun `DeleteSendConfirmClick with deleteSend success should emit ShowToast`() = runTest {
|
||||
val sendId = "sendId1234"
|
||||
coEvery { vaultRepository.deleteSend(sendId) } returns DeleteSendResult.Success
|
||||
|
||||
val viewModel = createVaultItemListingViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(VaultItemListingsAction.DeleteSendClick(sendId))
|
||||
viewModel.trySendAction(VaultItemListingsAction.DeleteSendConfirmClick(sendId))
|
||||
assertEquals(
|
||||
VaultItemListingEvent.ShowToast(R.string.send_deleted.asText()),
|
||||
awaitItem(),
|
||||
|
||||
Reference in New Issue
Block a user