mirror of
https://github.com/bitwarden/android.git
synced 2025-12-10 20:07:59 -06:00
hide select other account button if user has no other account
This commit is contained in:
parent
4b96007a77
commit
80eef3af13
@ -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",
|
||||
|
||||
@ -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 {
|
||||
|
||||
/**
|
||||
|
||||
@ -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,
|
||||
)
|
||||
|
||||
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user