mirror of
https://github.com/bitwarden/android.git
synced 2026-11-19 17:40:12 -06:00
BIT-1147: Adding navigation to block auto fill screen and skeleton UI (#671)
This commit is contained in:
committed by
Álison Fernandes
parent
3500f90812
commit
8c64d6b01b
+17
@@ -29,6 +29,7 @@ class AutoFillScreenTest : BaseComposeTest() {
|
||||
|
||||
private var isSystemSettingsRequestSuccess = false
|
||||
private var onNavigateBackCalled = false
|
||||
private var onNavigateToBlockAutoFillScreenCalled = false
|
||||
|
||||
private val mutableEventFlow = bufferedMutableSharedFlow<AutoFillEvent>()
|
||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||
@@ -45,6 +46,7 @@ class AutoFillScreenTest : BaseComposeTest() {
|
||||
composeTestRule.setContent {
|
||||
AutoFillScreen(
|
||||
onNavigateBack = { onNavigateBackCalled = true },
|
||||
onNavigateToBlockAutoFillScreen = { onNavigateToBlockAutoFillScreenCalled = true },
|
||||
viewModel = viewModel,
|
||||
intentManager = intentManager,
|
||||
)
|
||||
@@ -234,6 +236,21 @@ class AutoFillScreenTest : BaseComposeTest() {
|
||||
mutableEventFlow.tryEmit(AutoFillEvent.NavigateBack)
|
||||
assertTrue(onNavigateBackCalled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on block auto fill click should send BlockAutoFillClick`() {
|
||||
composeTestRule
|
||||
.onNodeWithText("Block auto-fill")
|
||||
.performScrollTo()
|
||||
.performClick()
|
||||
verify { viewModel.trySendAction(AutoFillAction.BlockAutoFillClick) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on NavigateToBlockAutoFill should call onNavigateToBlockAutoFillScreen`() {
|
||||
mutableEventFlow.tryEmit(AutoFillEvent.NavigateToBlockAutoFill)
|
||||
assertTrue(onNavigateToBlockAutoFillScreenCalled)
|
||||
}
|
||||
}
|
||||
|
||||
private val DEFAULT_STATE: AutoFillState = AutoFillState(
|
||||
|
||||
+9
@@ -153,6 +153,15 @@ class AutoFillViewModelTest : BaseViewModelTest() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on BlockAutoFillClick should emit NavigateToBlockAutoFill`() = runTest {
|
||||
val viewModel = createViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(AutoFillAction.BlockAutoFillClick)
|
||||
assertEquals(AutoFillEvent.NavigateToBlockAutoFill, awaitItem())
|
||||
}
|
||||
}
|
||||
|
||||
private fun createViewModel(
|
||||
state: AutoFillState? = DEFAULT_STATE,
|
||||
): AutoFillViewModel = AutoFillViewModel(
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.x8bit.bitwarden.ui.platform.feature.settings.autofill.blockautofill
|
||||
|
||||
import androidx.lifecycle.SavedStateHandle
|
||||
import app.cash.turbine.test
|
||||
import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class BlockAutoFillViewModelTest : BaseViewModelTest() {
|
||||
|
||||
@Test
|
||||
fun `on BackClick should emit NavigateBack`() = runTest {
|
||||
val viewModel = createViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(BlockAutoFillAction.BackClick)
|
||||
assertEquals(BlockAutoFillEvent.NavigateBack, awaitItem())
|
||||
}
|
||||
}
|
||||
|
||||
private fun createViewModel(
|
||||
state: BlockAutoFillState? = DEFAULT_STATE,
|
||||
): BlockAutoFillViewModel = BlockAutoFillViewModel(
|
||||
savedStateHandle = SavedStateHandle().apply { set("state", state) },
|
||||
)
|
||||
}
|
||||
|
||||
private val DEFAULT_STATE: BlockAutoFillState = BlockAutoFillState(
|
||||
BlockAutoFillState.ViewState.Empty,
|
||||
)
|
||||
Reference in New Issue
Block a user