mirror of
https://github.com/bitwarden/android.git
synced 2025-03-15 18:58:59 +03:00
BIT-1584 Fix the view password overflow item visibility (#1008)
This commit is contained in:
parent
5bfa059cdb
commit
829934f7c0
4 changed files with 36 additions and 5 deletions
|
@ -20,9 +20,9 @@ fun CipherView.toOverflowActions(): List<ListingItemOverflowAction.VaultAction>
|
|||
this.login?.username?.let {
|
||||
ListingItemOverflowAction.VaultAction.CopyUsernameClick(username = it)
|
||||
},
|
||||
this.login?.password?.let {
|
||||
ListingItemOverflowAction.VaultAction.CopyPasswordClick(password = it)
|
||||
},
|
||||
this.login?.password
|
||||
?.let { ListingItemOverflowAction.VaultAction.CopyPasswordClick(password = it) }
|
||||
.takeIf { this.viewPassword },
|
||||
this.login?.totp
|
||||
?.let { ListingItemOverflowAction.VaultAction.CopyTotpClick(totpCode = it) }
|
||||
.takeIf { this.type == CipherType.LOGIN },
|
||||
|
|
|
@ -68,7 +68,7 @@ fun createMockCipherView(
|
|||
secureNote = createMockSecureNoteView().takeIf { cipherType == CipherType.SECURE_NOTE },
|
||||
edit = false,
|
||||
organizationUseTotp = false,
|
||||
viewPassword = false,
|
||||
viewPassword = true,
|
||||
localData = null,
|
||||
)
|
||||
|
||||
|
|
|
@ -475,7 +475,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
|
|||
password = "mockPassword-1",
|
||||
uri = listOf(UriItem("testId", "www.mockuri1.com", UriMatchType.HOST)),
|
||||
totpCode = "mockTotp-1",
|
||||
canViewPassword = false,
|
||||
canViewPassword = true,
|
||||
)
|
||||
.copy(totp = "mockTotp-1"),
|
||||
),
|
||||
|
|
|
@ -46,6 +46,37 @@ class CipherViewExtensionsTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `toOverflowActions should return the correct actions when viewPassword is false for a login cipher`() {
|
||||
val id = "mockId-1"
|
||||
val username = "Bitwarden"
|
||||
val password = "password"
|
||||
val totpCode = "mockTotp-1"
|
||||
val uri = "www.test.com"
|
||||
val cipher = createMockCipherView(number = 1, cipherType = CipherType.LOGIN).copy(
|
||||
id = id,
|
||||
login = createMockLoginView(number = 1).copy(
|
||||
username = username,
|
||||
password = password,
|
||||
uris = listOf(createMockUriView(number = 1).copy(uri = uri)),
|
||||
),
|
||||
viewPassword = false,
|
||||
)
|
||||
val result = cipher.toOverflowActions()
|
||||
|
||||
assertEquals(
|
||||
listOf(
|
||||
ListingItemOverflowAction.VaultAction.ViewClick(cipherId = id),
|
||||
ListingItemOverflowAction.VaultAction.EditClick(cipherId = id),
|
||||
ListingItemOverflowAction.VaultAction.CopyUsernameClick(username = username),
|
||||
ListingItemOverflowAction.VaultAction.CopyTotpClick(totpCode = totpCode),
|
||||
ListingItemOverflowAction.VaultAction.LaunchClick(url = uri),
|
||||
),
|
||||
result,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toOverflowActions should return minimum actions for a login cipher`() {
|
||||
val id = "mockId-1"
|
||||
|
|
Loading…
Add table
Reference in a new issue