[PM-26986] Hide select other account button if user has no other account (#6041)

This commit is contained in:
aj-rosado
2025-10-20 17:02:43 +01:00
committed by GitHub
parent 13fa8a1ed0
commit d5912a5dc3
4 changed files with 28 additions and 5 deletions

View File

@@ -118,11 +118,15 @@ fun ReviewExportScreen(
BitwardenString
.your_vault_may_be_empty_or_import_some_item_types_isnt_supported,
),
primaryButton = BitwardenButtonData(
label = BitwardenString.select_a_different_account.asText(),
testTag = "SelectADifferentAccountButton",
onClick = handler.onSelectAnotherAccountClick,
),
primaryButton = if (state.hasOtherAccounts) {
BitwardenButtonData(
label = BitwardenString.select_a_different_account.asText(),
testTag = "SelectADifferentAccountButton",
onClick = handler.onSelectAnotherAccountClick,
)
} else {
null
},
secondaryButton = BitwardenButtonData(
label = BitwardenString.cancel.asText(),
testTag = "NoItemsCancelButton",

View File

@@ -59,6 +59,7 @@ class ReviewExportViewModel @Inject constructor(
itemTypeCounts = ReviewExportState.ItemTypeCounts(),
),
dialog = null,
hasOtherAccounts = authRepository.userStateFlow.value?.accounts.orEmpty().size > 1,
),
) {
@@ -296,6 +297,7 @@ data class ReviewExportState(
val dialog: DialogState? = null,
// Internally used properties
val importCredentialsRequestData: ImportCredentialsRequestData,
val hasOtherAccounts: Boolean,
) : Parcelable {
/**

View File

@@ -174,6 +174,19 @@ class ReviewExportScreenTest : BitwardenComposeTest() {
mockViewModel.trySendAction(ReviewExportAction.SelectAnotherAccountClick)
}
}
@Test
fun `SelectAnotherAccount should not be visible when user do not have other accounts`() {
mockStateFlow.tryEmit(
DEFAULT_STATE.copy(
viewState = ReviewExportState.ViewState.NoItems,
hasOtherAccounts = false,
),
)
composeTestRule
.onNodeWithText("Select a different account")
.assertDoesNotExist()
}
}
private val DEFAULT_STATE = ReviewExportState(
@@ -190,5 +203,6 @@ private val DEFAULT_STATE = ReviewExportState(
uri = Uri.EMPTY,
requestJson = "",
),
hasOtherAccounts = true,
dialog = null,
)

View File

@@ -70,6 +70,7 @@ class ReviewExportViewModelTest : BaseViewModelTest() {
viewState = ReviewExportState.ViewState.NoItems,
dialog = null,
importCredentialsRequestData = DEFAULT_REQUEST_DATA,
hasOtherAccounts = false,
)
decryptCipherListResultFlow.value = DataState.Loaded(
data = DecryptCipherListResult(
@@ -93,6 +94,7 @@ class ReviewExportViewModelTest : BaseViewModelTest() {
),
dialog = null,
importCredentialsRequestData = DEFAULT_REQUEST_DATA,
hasOtherAccounts = false,
)
val viewModel = createViewModel()
viewModel.stateFlow.test {
@@ -426,6 +428,7 @@ private val DEFAULT_CONTENT_VIEW_STATE = ReviewExportState.ViewState.Content(
private val DEFAULT_STATE: ReviewExportState = ReviewExportState(
importCredentialsRequestData = DEFAULT_REQUEST_DATA,
viewState = DEFAULT_CONTENT_VIEW_STATE,
hasOtherAccounts = false,
)
private const val DEFAULT_USER_ID: String = "activeUserId"
private val DEFAULT_USER_STATE = UserState(