mirror of
https://github.com/bitwarden/android.git
synced 2026-03-22 20:41:29 -05:00
[PM-13349] Hide Edit option in cipher list item overflow when editing not permitted (#4539)
This commit is contained in:
@@ -22,7 +22,7 @@ fun CipherView.toOverflowActions(
|
||||
cipherId = cipherId,
|
||||
requiresPasswordReprompt = hasMasterPassword,
|
||||
)
|
||||
.takeUnless { this.deletedDate != null },
|
||||
.takeUnless { this.deletedDate != null || !this.edit },
|
||||
this.login?.username?.let {
|
||||
ListingItemOverflowAction.VaultAction.CopyUsernameClick(username = it)
|
||||
},
|
||||
|
||||
@@ -277,6 +277,64 @@ class CipherViewExtensionsTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toOverflowActions should not return Edit action when cipher cannot be edited`() {
|
||||
val cipher = createMockCipherView(
|
||||
number = 1,
|
||||
isDeleted = false,
|
||||
cipherType = CipherType.LOGIN,
|
||||
)
|
||||
.copy(
|
||||
id = id,
|
||||
edit = false,
|
||||
login = createMockLoginView(number = 1).copy(
|
||||
username = null,
|
||||
password = null,
|
||||
uris = null,
|
||||
totp = null,
|
||||
),
|
||||
)
|
||||
|
||||
val result = cipher.toOverflowActions(hasMasterPassword = true, isPremiumUser = false)
|
||||
|
||||
assertEquals(
|
||||
listOf(ListingItemOverflowAction.VaultAction.ViewClick(cipherId = id)),
|
||||
result,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toOverflowActions should return Edit action when cipher can be edited`() {
|
||||
val cipher = createMockCipherView(
|
||||
number = 1,
|
||||
isDeleted = false,
|
||||
cipherType = CipherType.LOGIN,
|
||||
)
|
||||
.copy(
|
||||
id = id,
|
||||
edit = true,
|
||||
login = createMockLoginView(number = 1).copy(
|
||||
username = null,
|
||||
password = null,
|
||||
uris = null,
|
||||
totp = null,
|
||||
),
|
||||
)
|
||||
|
||||
val result = cipher.toOverflowActions(hasMasterPassword = true, isPremiumUser = false)
|
||||
|
||||
assertEquals(
|
||||
listOf(
|
||||
ListingItemOverflowAction.VaultAction.ViewClick(cipherId = id),
|
||||
ListingItemOverflowAction.VaultAction.EditClick(
|
||||
cipherId = id,
|
||||
requiresPasswordReprompt = true,
|
||||
),
|
||||
),
|
||||
result,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toTrailingIcons should return collection icon if collectionId is not empty`() {
|
||||
val cipher = createMockCipherView(1).copy(
|
||||
|
||||
Reference in New Issue
Block a user