Skip to content
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 @@ -71,6 +71,7 @@ class LoginWithDeviceViewModel @Inject constructor(

private fun handleErrorDialogDismissed() {
mutableStateFlow.update { it.copy(dialogState = null) }
sendEvent(LoginWithDeviceEvent.NavigateBack)
}

private fun handleResendNotificationClicked() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,27 @@ class LoginWithDeviceViewModelTest : BaseViewModelTest() {
}

@Test
fun `DismissDialog should clear the dialog state`() {
fun `DismissDialog should clear the dialog state and emit NavigateBack`() = runTest {
val initialState = DEFAULT_STATE.copy(
dialogState = LoginWithDeviceState.DialogState.Error(
title = BitwardenString.an_error_has_occurred.asText(),
message = BitwardenString.generic_error_message.asText(),
),
)
val viewModel = createViewModel(initialState)
viewModel.trySendAction(LoginWithDeviceAction.DismissDialog)
assertEquals(initialState.copy(dialogState = null), viewModel.stateFlow.value)

viewModel.eventFlow.test {
viewModel.trySendAction(LoginWithDeviceAction.DismissDialog)
assertEquals(
LoginWithDeviceEvent.NavigateBack,
awaitItem(),
)
}

assertEquals(
initialState.copy(dialogState = null),
viewModel.stateFlow.value,
)
}

@Test
Expand Down
Loading