mirror of
https://github.com/bitwarden/android.git
synced 2026-11-19 17:40:12 -06:00
Ensure more overflow action types get reprompts on Search (#940)
This commit is contained in:
committed by
Álison Fernandes
parent
b800b77194
commit
624e60fd71
+7
-85
@@ -389,9 +389,8 @@ class SearchScreenTest : BaseComposeTest() {
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = "password",
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData.Autofill(
|
||||
cipherId = "mockId-1",
|
||||
type = MasterPasswordRepromptData.Type.Autofill,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -425,9 +424,8 @@ class SearchScreenTest : BaseComposeTest() {
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = "password",
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData.AutofillAndSave(
|
||||
cipherId = "mockId-1",
|
||||
type = MasterPasswordRepromptData.Type.AutofillAndSave,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -613,7 +611,7 @@ class SearchScreenTest : BaseComposeTest() {
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `on cipher item overflow edit click when reprompt required should show the master password dialog`() {
|
||||
fun `on cipher item overflow item click when reprompt required should show the master password dialog`() {
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
viewState = SearchState.ViewState.Content(
|
||||
@@ -642,7 +640,7 @@ class SearchScreenTest : BaseComposeTest() {
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `clicking submit on the master password dialog for edit should close the dialog and send MasterPasswordRepromptSubmit`() {
|
||||
fun `clicking submit on the master password dialog for overflow item should close the dialog and send MasterPasswordRepromptSubmit`() {
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
viewState = SearchState.ViewState.Content(
|
||||
@@ -676,85 +674,9 @@ class SearchScreenTest : BaseComposeTest() {
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = "password",
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
cipherId = "mockId-1",
|
||||
type = MasterPasswordRepromptData.Type.Edit,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `on cipher item overflow copy password click when reprompt required should show the master password dialog`() {
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
viewState = SearchState.ViewState.Content(
|
||||
displayItems = listOf(
|
||||
createMockDisplayItemForCipher(number = 1)
|
||||
.copy(shouldDisplayMasterPasswordReprompt = true),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("Copy password")
|
||||
.assert(hasAnyAncestor(isDialog()))
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
verify(exactly = 0) { viewModel.trySendAction(any()) }
|
||||
|
||||
composeTestRule.assertMasterPasswordDialogDisplayed()
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `clicking submit on the master password dialog for copy password should close the dialog and send MasterPasswordRepromptSubmit`() {
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
viewState = SearchState.ViewState.Content(
|
||||
displayItems = listOf(
|
||||
createMockDisplayItemForCipher(number = 1)
|
||||
.copy(shouldDisplayMasterPasswordReprompt = true),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
composeTestRule
|
||||
.onNodeWithText("Copy password")
|
||||
.assert(hasAnyAncestor(isDialog()))
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
composeTestRule
|
||||
.onAllNodesWithText(text = "Master password")
|
||||
.filterToOne(hasAnyAncestor(isDialog()))
|
||||
.performTextInput("password")
|
||||
composeTestRule
|
||||
.onAllNodesWithText(text = "Submit")
|
||||
.filterToOne(hasAnyAncestor(isDialog()))
|
||||
.performClick()
|
||||
|
||||
verify {
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = "password",
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
cipherId = "mockId-1",
|
||||
type = MasterPasswordRepromptData.Type.CopyPassword(
|
||||
password = "mockPassword-1",
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData.OverflowItem(
|
||||
action = ListingItemOverflowAction.VaultAction.EditClick(
|
||||
cipherId = "mockId-1",
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
+10
-40
@@ -328,9 +328,8 @@ class SearchViewModelTest : BaseViewModelTest() {
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = password,
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData.Autofill(
|
||||
cipherId = cipherId,
|
||||
type = MasterPasswordRepromptData.Type.Autofill,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -366,9 +365,8 @@ class SearchViewModelTest : BaseViewModelTest() {
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = password,
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData.Autofill(
|
||||
cipherId = cipherId,
|
||||
type = MasterPasswordRepromptData.Type.Autofill,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -401,9 +399,8 @@ class SearchViewModelTest : BaseViewModelTest() {
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = password,
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData.Autofill(
|
||||
cipherId = cipherId,
|
||||
type = MasterPasswordRepromptData.Type.Autofill,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -445,9 +442,8 @@ class SearchViewModelTest : BaseViewModelTest() {
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = password,
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData.AutofillAndSave(
|
||||
cipherId = cipherId,
|
||||
type = MasterPasswordRepromptData.Type.AutofillAndSave,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -462,7 +458,7 @@ class SearchViewModelTest : BaseViewModelTest() {
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `MasterPasswordRepromptSubmit for a request Success with a valid password for edit should emit NavigateToEditCipher`() =
|
||||
fun `MasterPasswordRepromptSubmit for a request Success with a valid password for an overflow action should perform the action`() =
|
||||
runTest {
|
||||
val cipherId = "cipherId-1234"
|
||||
val password = "password"
|
||||
@@ -475,44 +471,18 @@ class SearchViewModelTest : BaseViewModelTest() {
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = password,
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
cipherId = cipherId,
|
||||
type = MasterPasswordRepromptData.Type.Edit,
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData.OverflowItem(
|
||||
action = ListingItemOverflowAction.VaultAction.EditClick(
|
||||
cipherId = cipherId,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
// Edit actions should navigate to the Edit screen
|
||||
assertEquals(SearchEvent.NavigateToEditCipher(cipherId), awaitItem())
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `MasterPasswordRepromptSubmit for a request Success with a valid password for copy password should call setText on the ClipboardManager`() =
|
||||
runTest {
|
||||
val cipherId = "cipherId-1234"
|
||||
val password = "password"
|
||||
val viewModel = createViewModel()
|
||||
coEvery {
|
||||
authRepository.validatePassword(password = password)
|
||||
} returns ValidatePasswordResult.Success(isValid = true)
|
||||
|
||||
viewModel.trySendAction(
|
||||
SearchAction.MasterPasswordRepromptSubmit(
|
||||
password = password,
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData(
|
||||
cipherId = cipherId,
|
||||
type = MasterPasswordRepromptData.Type.CopyPassword(
|
||||
password = password,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
verify(exactly = 1) {
|
||||
clipboardManager.setText(password)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `OverflowOptionClick Send EditClick should emit NavigateToEditSend`() = runTest {
|
||||
val sendId = "sendId"
|
||||
|
||||
Reference in New Issue
Block a user