🍒 [PM-21537] Fix remove individual vault collection selection cherrypick (#5261)

This commit is contained in:
aj-rosado
2025-05-23 20:40:48 +01:00
committed by GitHub
parent 04e06904f2
commit 1e665db8ae
2 changed files with 54 additions and 1 deletions
@@ -960,11 +960,12 @@ class VaultAddEditViewModel @Inject constructor(
) {
updateCommonContent { currentCommonContentState ->
currentCommonContentState.copy(
selectedOwnerId = currentCommonContentState.selectedOwner?.id,
availableOwners = currentCommonContentState
.availableOwners
.toUpdatedOwners(
selectedCollectionId = action.collection.id,
selectedOwnerId = currentCommonContentState.selectedOwnerId,
selectedOwnerId = currentCommonContentState.selectedOwner?.id,
),
)
}
@@ -4056,6 +4056,58 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
assertEquals(expectedState, viewModel.stateFlow.value)
}
@Suppress("MaxLineLength")
@Test
fun `CollectionSelect should update selectedOwnerId when isIndividualVaultDisabled is true`() =
runTest {
every {
policyManager.getActivePolicies(type = PolicyTypeJson.PERSONAL_OWNERSHIP)
} returns listOf(
SyncResponseJson.Policy(
organizationId = "Test Org",
id = "testId",
type = PolicyTypeJson.PERSONAL_OWNERSHIP,
isEnabled = true,
data = null,
),
)
val vaultAddEditType = VaultAddEditType.AddItem
val vaultItemCipherType = VaultItemCipherType.LOGIN
mutableVaultDataFlow.value = DataState.Loaded(
data = createVaultData(),
)
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = null,
vaultAddEditType = vaultAddEditType,
vaultItemCipherType = vaultItemCipherType,
),
)
val action = collectionSelectAction()
viewModel.trySendAction(action)
val expectedState = vaultAddItemInitialState.copy(
viewState = VaultAddEditState.ViewState.Content(
common = createCommonContentViewState(
availableOwners = listOf(
VaultAddEditState.Owner(
id = "organizationId",
name = "organizationName",
collections = emptyList(),
),
),
selectedOwnerId = "organizationId",
),
isIndividualVaultDisabled = true,
type = createLoginTypeContentViewState(),
),
)
assertEquals(expectedState, viewModel.stateFlow.value)
}
@Suppress("MaxLineLength")
@Test
fun `UserVerificationLockout should set isUserVerified to false and display Fido2ErrorDialog`() {