Move the 'isPremiumUser' flag from a common VaultItem property to a Login specific property (#486)

This commit is contained in:
David Perez
2024-01-03 13:34:11 -06:00
committed by GitHub
parent f522e63815
commit f75aa1fdeb
7 changed files with 18 additions and 34 deletions

View File

@@ -528,6 +528,7 @@ class VaultItemScreenTest : BaseComposeTest() {
uris = emptyList(),
passwordRevisionDate = null,
totp = null,
isPremiumUser = true,
),
),
)
@@ -1064,7 +1065,6 @@ private val DEFAULT_COMMON: VaultItemState.ViewState.Content.Common =
lastUpdated = "12/31/69 06:16 PM",
name = "cipher",
notes = "Lots of notes",
isPremiumUser = true,
customFields = listOf(
VaultItemState.ViewState.Content.Common.Custom.TextField(
name = "text",
@@ -1102,6 +1102,7 @@ private val DEFAULT_LOGIN: VaultItemState.ViewState.Content.ItemType.Login =
),
passwordRevisionDate = "4/14/83 3:56 PM",
totp = "otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example",
isPremiumUser = true,
)
private val DEFAULT_IDENTITY: VaultItemState.ViewState.Content.ItemType.Identity =
@@ -1122,7 +1123,6 @@ private val EMPTY_COMMON: VaultItemState.ViewState.Content.Common =
name = "cipher",
lastUpdated = "12/31/69 06:16 PM",
notes = null,
isPremiumUser = true,
customFields = emptyList(),
requiresReprompt = true,
)
@@ -1135,6 +1135,7 @@ private val EMPTY_LOGIN_TYPE: VaultItemState.ViewState.Content.ItemType.Login =
uris = emptyList(),
passwordRevisionDate = null,
totp = null,
isPremiumUser = true,
)
private val EMPTY_IDENTITY_TYPE: VaultItemState.ViewState.Content.ItemType.Identity =

View File

@@ -681,6 +681,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
passwordRevisionDate = "12/31/69 06:16 PM",
totp = "otpauth://totp/Example:alice@google.com" +
"?secret=JBSWY3DPEHPK3PXP&issuer=Example",
isPremiumUser = true,
)
private val DEFAULT_COMMON: VaultItemState.ViewState.Content.Common =
@@ -688,7 +689,6 @@ class VaultItemViewModelTest : BaseViewModelTest() {
name = "login cipher",
lastUpdated = "12/31/69 06:16 PM",
notes = "Lots of notes",
isPremiumUser = true,
customFields = listOf(
VaultItemState.ViewState.Content.Common.Custom.TextField(
name = "text",

View File

@@ -45,8 +45,8 @@ class CipherViewExtensionsTest {
assertEquals(
VaultItemState.ViewState.Content(
common = createCommonContent(isEmpty = false).copy(isPremiumUser = isPremiumUser),
type = createLoginContent(isEmpty = false),
common = createCommonContent(isEmpty = false),
type = createLoginContent(isEmpty = false).copy(isPremiumUser = isPremiumUser),
),
viewState,
)
@@ -66,9 +66,8 @@ class CipherViewExtensionsTest {
)
}
@Suppress("MaxLineLength")
@Test
fun `toViewState should transform full CipherView into ViewState Identity Content with premium`() {
fun `toViewState should transform full CipherView into ViewState Identity Content`() {
val viewState = createCipherView(type = CipherType.IDENTITY, isEmpty = false)
.toViewState(isPremiumUser = true)
@@ -81,22 +80,6 @@ class CipherViewExtensionsTest {
)
}
@Suppress("MaxLineLength")
@Test
fun `toViewState should transform full CipherView into ViewState Identity Content without premium`() {
val isPremiumUser = false
val viewState = createCipherView(type = CipherType.IDENTITY, isEmpty = false)
.toViewState(isPremiumUser = isPremiumUser)
assertEquals(
VaultItemState.ViewState.Content(
common = createCommonContent(isEmpty = false).copy(isPremiumUser = isPremiumUser),
type = createIdentityContent(isEmpty = false),
),
viewState,
)
}
@Test
fun `toViewState should transform empty CipherView into ViewState Identity Content`() {
val viewState = createCipherView(type = CipherType.IDENTITY, isEmpty = true)
@@ -171,9 +154,8 @@ class CipherViewExtensionsTest {
)
}
@Suppress("MaxLineLength")
@Test
fun `toViewState should transform full CipherView into ViewState Secure Note Content with premium`() {
fun `toViewState should transform full CipherView into ViewState Secure Note Content`() {
val viewState = createCipherView(type = CipherType.SECURE_NOTE, isEmpty = false)
.toViewState(isPremiumUser = true)
@@ -193,7 +175,7 @@ class CipherViewExtensionsTest {
.toViewState(isPremiumUser = true)
val expectedState = VaultItemState.ViewState.Content(
common = createCommonContent(isEmpty = true).copy(isPremiumUser = true),
common = createCommonContent(isEmpty = true),
type = VaultItemState.ViewState.Content.ItemType.SecureNote,
)

View File

@@ -137,7 +137,6 @@ fun createCommonContent(isEmpty: Boolean): VaultItemState.ViewState.Content.Comm
name = "mockName",
lastUpdated = "1/1/70 12:16 AM",
notes = null,
isPremiumUser = true,
customFields = emptyList(),
requiresReprompt = true,
)
@@ -146,7 +145,6 @@ fun createCommonContent(isEmpty: Boolean): VaultItemState.ViewState.Content.Comm
name = "mockName",
lastUpdated = "1/1/70 12:16 AM",
notes = "Lots of notes",
isPremiumUser = true,
customFields = listOf(
VaultItemState.ViewState.Content.Common.Custom.TextField(
name = "text",
@@ -199,6 +197,7 @@ fun createLoginContent(isEmpty: Boolean): VaultItemState.ViewState.Content.ItemT
passwordRevisionDate = "1/1/70 12:16 AM".takeUnless { isEmpty },
totp = "otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"
.takeUnless { isEmpty },
isPremiumUser = true,
)
fun createIdentityContent(