mirror of
https://github.com/bitwarden/android.git
synced 2026-10-22 19:13:34 -05:00
removed unnecessary hasPersonalVaultItems method
This commit is contained in:
3 files changed
-106
No files matched your search
@@ -166,11 +166,4 @@ interface VaultRepository :
|
||||
* `null` if the item cannot be found.
|
||||
*/
|
||||
fun getVaultListItemStateFlow(itemId: String): StateFlow<DataState<CipherListView?>>
|
||||
|
||||
/**
|
||||
* Checks if there are any personal vault items (items without an organization ID) in the vault.
|
||||
*
|
||||
* @return `true` if there are personal vault items, `false` otherwise.
|
||||
*/
|
||||
fun hasPersonalVaultItems(): Boolean
|
||||
}
|
||||
@@ -550,9 +550,4 @@ class VaultRepositoryImpl(
|
||||
organizationKeys = organizationKeys,
|
||||
)
|
||||
}
|
||||
|
||||
override fun hasPersonalVaultItems(): Boolean {
|
||||
val vaultData = vaultSyncManager.vaultDataStateFlow.value.data ?: return false
|
||||
return vaultData.decryptCipherListResult.successes.any { it.organizationId.isNullOrEmpty() }
|
||||
}
|
||||
}
|
||||
@@ -1390,100 +1390,6 @@ class VaultRepositoryTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasPersonalVaultItems returns false when vault data is loading`() {
|
||||
mutableVaultDataStateFlow.value = DataState.Loading
|
||||
|
||||
val result = vaultRepository.hasPersonalVaultItems()
|
||||
|
||||
assertEquals(false, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasPersonalVaultItems returns false when all items belong to organizations`() {
|
||||
mutableVaultDataStateFlow.value = DataState.Loaded(
|
||||
data = VaultData(
|
||||
decryptCipherListResult = DecryptCipherListResult(
|
||||
successes = listOf(
|
||||
createMockCipherListView(number = 1, organizationId = "org-1"),
|
||||
createMockCipherListView(number = 2, organizationId = "org-2"),
|
||||
),
|
||||
failures = emptyList(),
|
||||
),
|
||||
collectionViewList = emptyList(),
|
||||
folderViewList = emptyList(),
|
||||
sendViewList = emptyList(),
|
||||
),
|
||||
)
|
||||
|
||||
val result = vaultRepository.hasPersonalVaultItems()
|
||||
|
||||
assertEquals(false, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasPersonalVaultItems returns true when there are items without organization ID`() {
|
||||
mutableVaultDataStateFlow.value = DataState.Loaded(
|
||||
data = VaultData(
|
||||
decryptCipherListResult = DecryptCipherListResult(
|
||||
successes = listOf(
|
||||
createMockCipherListView(number = 1, organizationId = null),
|
||||
createMockCipherListView(number = 2, organizationId = "org-2"),
|
||||
),
|
||||
failures = emptyList(),
|
||||
),
|
||||
collectionViewList = emptyList(),
|
||||
folderViewList = emptyList(),
|
||||
sendViewList = emptyList(),
|
||||
),
|
||||
)
|
||||
|
||||
val result = vaultRepository.hasPersonalVaultItems()
|
||||
|
||||
assertEquals(true, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasPersonalVaultItems returns true when there are items with empty organization ID`() {
|
||||
mutableVaultDataStateFlow.value = DataState.Loaded(
|
||||
data = VaultData(
|
||||
decryptCipherListResult = DecryptCipherListResult(
|
||||
successes = listOf(
|
||||
createMockCipherListView(number = 1, organizationId = ""),
|
||||
createMockCipherListView(number = 2, organizationId = "org-2"),
|
||||
),
|
||||
failures = emptyList(),
|
||||
),
|
||||
collectionViewList = emptyList(),
|
||||
folderViewList = emptyList(),
|
||||
sendViewList = emptyList(),
|
||||
),
|
||||
)
|
||||
|
||||
val result = vaultRepository.hasPersonalVaultItems()
|
||||
|
||||
assertEquals(true, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasPersonalVaultItems returns false when successes list is empty`() {
|
||||
mutableVaultDataStateFlow.value = DataState.Loaded(
|
||||
data = VaultData(
|
||||
decryptCipherListResult = DecryptCipherListResult(
|
||||
successes = emptyList(),
|
||||
failures = emptyList(),
|
||||
),
|
||||
collectionViewList = emptyList(),
|
||||
folderViewList = emptyList(),
|
||||
sendViewList = emptyList(),
|
||||
),
|
||||
)
|
||||
|
||||
val result = vaultRepository.hasPersonalVaultItems()
|
||||
|
||||
assertEquals(false, result)
|
||||
}
|
||||
|
||||
//region Helper functions
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user