hide select other account button if user has no other account

This commit is contained in:
Andre Rosado 2025-10-16 19:10:07 +01:00
parent 4b96007a77
commit 80eef3af13
No known key found for this signature in database
GPG Key ID: 99F68267CCD45AA9
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?.size ?: 0) > 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 = true,
)
decryptCipherListResultFlow.value = DataState.Loaded(
data = DecryptCipherListResult(
@ -93,6 +94,7 @@ class ReviewExportViewModelTest : BaseViewModelTest() {
),
dialog = null,
importCredentialsRequestData = DEFAULT_REQUEST_DATA,
hasOtherAccounts = true,
)
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 = true,
)
private const val DEFAULT_USER_ID: String = "activeUserId"
private val DEFAULT_USER_STATE = UserState(