mirror of
https://github.com/bitwarden/android.git
synced 2026-11-19 17:40:12 -06:00
BIT-1724: No folder vault section (#1021)
This commit is contained in:
committed by
Álison Fernandes
parent
e9fba5b99c
commit
6b4e367c66
+2
-1
@@ -28,11 +28,12 @@ fun createMockCipherView(
|
||||
isDeleted: Boolean = false,
|
||||
cipherType: CipherType = CipherType.LOGIN,
|
||||
totp: String? = "mockTotp-$number",
|
||||
folderId: String? = "mockId-$number",
|
||||
): CipherView =
|
||||
CipherView(
|
||||
id = "mockId-$number",
|
||||
organizationId = "mockOrganizationId-$number",
|
||||
folderId = "mockId-$number",
|
||||
folderId = folderId,
|
||||
collectionIds = listOf("mockId-$number"),
|
||||
key = "mockKey-$number",
|
||||
name = "mockName-$number",
|
||||
|
||||
+30
@@ -244,6 +244,36 @@ class VaultItemListingDataExtensionsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `determineListingPredicate should return the correct predicate for item not in a folder`() {
|
||||
val cipherView = createMockCipherView(
|
||||
number = 1,
|
||||
isDeleted = false,
|
||||
cipherType = CipherType.SECURE_NOTE,
|
||||
folderId = null,
|
||||
)
|
||||
|
||||
mapOf(
|
||||
VaultItemListingState.ItemListingType.Vault.Login to false,
|
||||
VaultItemListingState.ItemListingType.Vault.Card to false,
|
||||
VaultItemListingState.ItemListingType.Vault.SecureNote to true,
|
||||
VaultItemListingState.ItemListingType.Vault.Identity to false,
|
||||
VaultItemListingState.ItemListingType.Vault.Trash to false,
|
||||
VaultItemListingState.ItemListingType.Vault.Folder(folderId = null) to true,
|
||||
VaultItemListingState.ItemListingType.Vault.Collection(collectionId = "mockId-1") to true,
|
||||
)
|
||||
.forEach { (type, expected) ->
|
||||
val result = cipherView.determineListingPredicate(
|
||||
itemListingType = type,
|
||||
)
|
||||
assertEquals(
|
||||
expected,
|
||||
result,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `determineListingPredicate should return the correct predicate for trash SecureNote cipherView`() {
|
||||
|
||||
+47
@@ -419,4 +419,51 @@ class VaultDataExtensionsTest {
|
||||
actual,
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `toViewState with over 100 no folder items should show no folder option`() {
|
||||
mockkStatic(Uri::class)
|
||||
val uriMock = mockk<Uri>()
|
||||
every { Uri.parse(any()) } returns uriMock
|
||||
every { uriMock.host } returns "www.mockuri1.com"
|
||||
val vaultData = VaultData(
|
||||
cipherViewList = List(100) {
|
||||
createMockCipherView(number = it, folderId = null)
|
||||
},
|
||||
collectionViewList = listOf(),
|
||||
folderViewList = listOf(),
|
||||
sendViewList = listOf(),
|
||||
)
|
||||
|
||||
val actual = vaultData.toViewState(
|
||||
isPremium = true,
|
||||
isIconLoadingDisabled = false,
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
VaultState.ViewState.Content(
|
||||
loginItemsCount = 100,
|
||||
cardItemsCount = 0,
|
||||
identityItemsCount = 0,
|
||||
secureNoteItemsCount = 0,
|
||||
favoriteItems = listOf(),
|
||||
folderItems = listOf(
|
||||
VaultState.ViewState.FolderItem(
|
||||
id = null,
|
||||
name = R.string.folder_none.asText(),
|
||||
itemCount = 100,
|
||||
),
|
||||
),
|
||||
collectionItems = listOf(),
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 100,
|
||||
),
|
||||
actual,
|
||||
)
|
||||
unmockkStatic(Uri::class)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user