mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
Update CipherViewExtensions to use previous state to avoid clearing user set values (#3368)
This commit is contained in:
parent
2720a80e2a
commit
d9d1e9a12c
4 changed files with 156 additions and 4 deletions
|
@ -918,6 +918,7 @@ class VaultItemViewModel @Inject constructor(
|
||||||
.data
|
.data
|
||||||
?.cipher
|
?.cipher
|
||||||
?.toViewState(
|
?.toViewState(
|
||||||
|
previousState = state.viewState as? VaultItemState.ViewState.Content,
|
||||||
isPremiumUser = account.isPremium,
|
isPremiumUser = account.isPremium,
|
||||||
hasMasterPassword = account.hasMasterPassword,
|
hasMasterPassword = account.hasMasterPassword,
|
||||||
totpCodeItemData = this.data?.totpCodeItemData,
|
totpCodeItemData = this.data?.totpCodeItemData,
|
||||||
|
|
|
@ -35,6 +35,7 @@ private const val FIDO2_CREDENTIAL_CREATION_TIME_PATTERN: String = "h:mm a"
|
||||||
*/
|
*/
|
||||||
@Suppress("CyclomaticComplexMethod", "LongMethod")
|
@Suppress("CyclomaticComplexMethod", "LongMethod")
|
||||||
fun CipherView.toViewState(
|
fun CipherView.toViewState(
|
||||||
|
previousState: VaultItemState.ViewState.Content?,
|
||||||
isPremiumUser: Boolean,
|
isPremiumUser: Boolean,
|
||||||
hasMasterPassword: Boolean,
|
hasMasterPassword: Boolean,
|
||||||
totpCodeItemData: TotpCodeItemData?,
|
totpCodeItemData: TotpCodeItemData?,
|
||||||
|
@ -44,7 +45,8 @@ fun CipherView.toViewState(
|
||||||
common = VaultItemState.ViewState.Content.Common(
|
common = VaultItemState.ViewState.Content.Common(
|
||||||
currentCipher = this,
|
currentCipher = this,
|
||||||
name = name,
|
name = name,
|
||||||
requiresReprompt = reprompt == CipherRepromptType.PASSWORD && hasMasterPassword,
|
requiresReprompt = (reprompt == CipherRepromptType.PASSWORD && hasMasterPassword) &&
|
||||||
|
previousState?.common?.requiresReprompt != false,
|
||||||
customFields = fields.orEmpty().map { it.toCustomField() },
|
customFields = fields.orEmpty().map { it.toCustomField() },
|
||||||
lastUpdated = revisionDate.toFormattedPattern(
|
lastUpdated = revisionDate.toFormattedPattern(
|
||||||
pattern = LAST_UPDATED_DATE_TIME_PATTERN,
|
pattern = LAST_UPDATED_DATE_TIME_PATTERN,
|
||||||
|
@ -87,7 +89,10 @@ fun CipherView.toViewState(
|
||||||
passwordData = loginValues.password?.let {
|
passwordData = loginValues.password?.let {
|
||||||
VaultItemState.ViewState.Content.ItemType.Login.PasswordData(
|
VaultItemState.ViewState.Content.ItemType.Login.PasswordData(
|
||||||
password = it,
|
password = it,
|
||||||
isVisible = false,
|
isVisible = (previousState?.type as?
|
||||||
|
VaultItemState.ViewState.Content.ItemType.Login)
|
||||||
|
?.passwordData
|
||||||
|
?.isVisible == true,
|
||||||
canViewPassword = viewPassword,
|
canViewPassword = viewPassword,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -118,7 +123,10 @@ fun CipherView.toViewState(
|
||||||
number = card?.number?.let {
|
number = card?.number?.let {
|
||||||
VaultItemState.ViewState.Content.ItemType.Card.NumberData(
|
VaultItemState.ViewState.Content.ItemType.Card.NumberData(
|
||||||
number = it,
|
number = it,
|
||||||
isVisible = false,
|
isVisible = (previousState?.type
|
||||||
|
as? VaultItemState.ViewState.Content.ItemType.Card)
|
||||||
|
?.number
|
||||||
|
?.isVisible == true,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
brand = card?.cardBrand,
|
brand = card?.cardBrand,
|
||||||
|
@ -126,7 +134,10 @@ fun CipherView.toViewState(
|
||||||
securityCode = card?.code?.let {
|
securityCode = card?.code?.let {
|
||||||
VaultItemState.ViewState.Content.ItemType.Card.CodeData(
|
VaultItemState.ViewState.Content.ItemType.Card.CodeData(
|
||||||
code = it,
|
code = it,
|
||||||
isVisible = false,
|
isVisible = (previousState?.type
|
||||||
|
as? VaultItemState.ViewState.Content.ItemType.Card)
|
||||||
|
?.securityCode
|
||||||
|
?.isVisible == true,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -157,6 +157,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -179,6 +180,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -197,6 +199,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -239,6 +242,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -270,6 +274,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -312,6 +317,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -357,6 +363,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -396,6 +403,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -435,6 +443,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -483,6 +492,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = any(),
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -514,6 +524,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = any(),
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -527,6 +538,14 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
viewModel.eventFlow.test {
|
viewModel.eventFlow.test {
|
||||||
viewModel.trySendAction(VaultItemAction.Common.EditClick)
|
viewModel.trySendAction(VaultItemAction.Common.EditClick)
|
||||||
|
verify {
|
||||||
|
mockCipherView.toViewState(
|
||||||
|
previousState = loginViewState,
|
||||||
|
isPremiumUser = true,
|
||||||
|
hasMasterPassword = true,
|
||||||
|
totpCodeItemData = null,
|
||||||
|
)
|
||||||
|
}
|
||||||
assertEquals(
|
assertEquals(
|
||||||
VaultItemEvent.NavigateToAddEdit(
|
VaultItemEvent.NavigateToAddEdit(
|
||||||
itemId = VAULT_ITEM_ID,
|
itemId = VAULT_ITEM_ID,
|
||||||
|
@ -547,6 +566,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = any(),
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -609,6 +629,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = any(),
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -661,6 +682,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = any(),
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -724,6 +746,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -746,6 +769,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -760,6 +784,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -776,6 +801,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
clipboardManager.setText(text = field)
|
clipboardManager.setText(text = field)
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -814,6 +840,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -844,6 +871,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -875,6 +903,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -905,6 +934,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -924,6 +954,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -946,6 +977,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -964,6 +996,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -997,6 +1030,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1021,6 +1055,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1043,6 +1078,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1090,6 +1126,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1112,6 +1149,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1130,6 +1168,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1160,6 +1199,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1182,6 +1222,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1200,6 +1241,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1241,6 +1283,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = any(),
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1296,6 +1339,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = any(),
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1360,6 +1404,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = any(),
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1537,6 +1582,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1576,6 +1622,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1593,6 +1640,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1618,6 +1666,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1631,6 +1680,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1648,6 +1698,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
clipboardManager.setText(text = DEFAULT_LOGIN_PASSWORD)
|
clipboardManager.setText(text = DEFAULT_LOGIN_PASSWORD)
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1687,6 +1738,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1702,6 +1754,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
clipboardManager.setText(text = DEFAULT_LOGIN_USERNAME)
|
clipboardManager.setText(text = DEFAULT_LOGIN_USERNAME)
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1725,6 +1778,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1748,6 +1802,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1762,6 +1817,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1787,6 +1843,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1802,6 +1859,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1829,6 +1887,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1847,6 +1906,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1877,6 +1937,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = createTotpCodeData(),
|
totpCodeItemData = createTotpCodeData(),
|
||||||
|
@ -1910,6 +1971,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1934,6 +1996,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1947,6 +2010,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1965,6 +2029,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
clipboardManager.setText(text = "12345436")
|
clipboardManager.setText(text = "12345436")
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -1979,6 +2044,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2003,6 +2069,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2016,6 +2083,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2040,6 +2108,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2054,6 +2123,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2078,6 +2148,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2091,6 +2162,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2109,6 +2181,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
clipboardManager.setText(text = "987")
|
clipboardManager.setText(text = "987")
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2123,6 +2196,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2147,6 +2221,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
verify(exactly = 1) {
|
verify(exactly = 1) {
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2160,6 +2235,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val mockCipherView = mockk<CipherView> {
|
val mockCipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2184,6 +2260,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
mockCipherView.toViewState(
|
mockCipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2218,6 +2295,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val cipherView = mockk<CipherView> {
|
val cipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2253,6 +2331,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val cipherView = mockk<CipherView> {
|
val cipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2289,6 +2368,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val cipherView = mockk<CipherView> {
|
val cipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -2324,6 +2404,7 @@ class VaultItemViewModelTest : BaseViewModelTest() {
|
||||||
val cipherView = mockk<CipherView> {
|
val cipherView = mockk<CipherView> {
|
||||||
every {
|
every {
|
||||||
toViewState(
|
toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
|
|
@ -16,11 +16,61 @@ class CipherViewExtensionsTest {
|
||||||
ZoneOffset.UTC,
|
ZoneOffset.UTC,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Suppress("MaxLineLength")
|
||||||
|
@Test
|
||||||
|
fun `toViewState should transform full CipherView into ViewState Login Content maintaining re-prompt and visibility state`() {
|
||||||
|
val cipherView = createCipherView(type = CipherType.LOGIN, isEmpty = false)
|
||||||
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = VaultItemState.ViewState.Content(
|
||||||
|
common = createCommonContent(isEmpty = false, isPremiumUser = true).copy(
|
||||||
|
currentCipher = cipherView,
|
||||||
|
// This re-prompt state should be preserved
|
||||||
|
requiresReprompt = false,
|
||||||
|
),
|
||||||
|
type = createLoginContent(isEmpty = false).copy(
|
||||||
|
passwordData = VaultItemState.ViewState.Content.ItemType.Login.PasswordData(
|
||||||
|
password = "password",
|
||||||
|
// This visibility state should be preserved
|
||||||
|
isVisible = true,
|
||||||
|
canViewPassword = false,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
isPremiumUser = true,
|
||||||
|
hasMasterPassword = true,
|
||||||
|
totpCodeItemData = TotpCodeItemData(
|
||||||
|
periodSeconds = 30,
|
||||||
|
timeLeftSeconds = 15,
|
||||||
|
verificationCode = "123456",
|
||||||
|
totpCode = "testCode",
|
||||||
|
),
|
||||||
|
clock = fixedClock,
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
VaultItemState.ViewState.Content(
|
||||||
|
common = createCommonContent(isEmpty = false, isPremiumUser = true).copy(
|
||||||
|
currentCipher = cipherView,
|
||||||
|
requiresReprompt = false,
|
||||||
|
),
|
||||||
|
type = createLoginContent(isEmpty = false).copy(
|
||||||
|
passwordData = VaultItemState.ViewState.Content.ItemType.Login.PasswordData(
|
||||||
|
password = "password",
|
||||||
|
isVisible = true,
|
||||||
|
canViewPassword = false,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
viewState,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("MaxLineLength")
|
@Suppress("MaxLineLength")
|
||||||
@Test
|
@Test
|
||||||
fun `toViewState should transform full CipherView into ViewState Login Content without master password reprompt`() {
|
fun `toViewState should transform full CipherView into ViewState Login Content without master password reprompt`() {
|
||||||
val cipherView = createCipherView(type = CipherType.LOGIN, isEmpty = false)
|
val cipherView = createCipherView(type = CipherType.LOGIN, isEmpty = false)
|
||||||
val viewState = cipherView.toViewState(
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = false,
|
hasMasterPassword = false,
|
||||||
totpCodeItemData = TotpCodeItemData(
|
totpCodeItemData = TotpCodeItemData(
|
||||||
|
@ -48,6 +98,7 @@ class CipherViewExtensionsTest {
|
||||||
fun `toViewState should transform full CipherView into ViewState Login Content with premium`() {
|
fun `toViewState should transform full CipherView into ViewState Login Content with premium`() {
|
||||||
val cipherView = createCipherView(type = CipherType.LOGIN, isEmpty = false)
|
val cipherView = createCipherView(type = CipherType.LOGIN, isEmpty = false)
|
||||||
val viewState = cipherView.toViewState(
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = TotpCodeItemData(
|
totpCodeItemData = TotpCodeItemData(
|
||||||
|
@ -75,6 +126,7 @@ class CipherViewExtensionsTest {
|
||||||
val isPremiumUser = false
|
val isPremiumUser = false
|
||||||
val cipherView = createCipherView(type = CipherType.LOGIN, isEmpty = false)
|
val cipherView = createCipherView(type = CipherType.LOGIN, isEmpty = false)
|
||||||
val viewState = cipherView.toViewState(
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = isPremiumUser,
|
isPremiumUser = isPremiumUser,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = TotpCodeItemData(
|
totpCodeItemData = TotpCodeItemData(
|
||||||
|
@ -100,6 +152,7 @@ class CipherViewExtensionsTest {
|
||||||
fun `toViewState should transform empty CipherView into ViewState Login Content`() {
|
fun `toViewState should transform empty CipherView into ViewState Login Content`() {
|
||||||
val cipherView = createCipherView(type = CipherType.LOGIN, isEmpty = true)
|
val cipherView = createCipherView(type = CipherType.LOGIN, isEmpty = true)
|
||||||
val viewState = cipherView.toViewState(
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -121,6 +174,7 @@ class CipherViewExtensionsTest {
|
||||||
fun `toViewState should transform full CipherView into ViewState Identity Content`() {
|
fun `toViewState should transform full CipherView into ViewState Identity Content`() {
|
||||||
val cipherView = createCipherView(type = CipherType.IDENTITY, isEmpty = false)
|
val cipherView = createCipherView(type = CipherType.IDENTITY, isEmpty = false)
|
||||||
val viewState = cipherView.toViewState(
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -141,6 +195,7 @@ class CipherViewExtensionsTest {
|
||||||
fun `toViewState should transform empty CipherView into ViewState Identity Content`() {
|
fun `toViewState should transform empty CipherView into ViewState Identity Content`() {
|
||||||
val cipherView = createCipherView(type = CipherType.IDENTITY, isEmpty = true)
|
val cipherView = createCipherView(type = CipherType.IDENTITY, isEmpty = true)
|
||||||
val viewState = cipherView.toViewState(
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -171,6 +226,7 @@ class CipherViewExtensionsTest {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
val viewState = cipherView.toViewState(
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -206,6 +262,7 @@ class CipherViewExtensionsTest {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
val result = cipherView.toViewState(
|
val result = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -243,6 +300,7 @@ class CipherViewExtensionsTest {
|
||||||
fun `toViewState should transform full CipherView into ViewState Secure Note Content`() {
|
fun `toViewState should transform full CipherView into ViewState Secure Note Content`() {
|
||||||
val cipherView = createCipherView(type = CipherType.SECURE_NOTE, isEmpty = false)
|
val cipherView = createCipherView(type = CipherType.SECURE_NOTE, isEmpty = false)
|
||||||
val viewState = cipherView.toViewState(
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
@ -264,6 +322,7 @@ class CipherViewExtensionsTest {
|
||||||
fun `toViewState should transform empty Secure Note CipherView into ViewState Secure Note Content`() {
|
fun `toViewState should transform empty Secure Note CipherView into ViewState Secure Note Content`() {
|
||||||
val cipherView = createCipherView(type = CipherType.SECURE_NOTE, isEmpty = true)
|
val cipherView = createCipherView(type = CipherType.SECURE_NOTE, isEmpty = true)
|
||||||
val viewState = cipherView.toViewState(
|
val viewState = cipherView.toViewState(
|
||||||
|
previousState = null,
|
||||||
isPremiumUser = true,
|
isPremiumUser = true,
|
||||||
hasMasterPassword = true,
|
hasMasterPassword = true,
|
||||||
totpCodeItemData = null,
|
totpCodeItemData = null,
|
||||||
|
|
Loading…
Reference in a new issue