mirror of
https://github.com/bitwarden/android.git
synced 2025-12-10 09:56:45 -06:00
[PM-24599] Add cardholderName to AutofillSaveItem.Card (#5716)
This commit is contained in:
parent
9fcfcc9e41
commit
af322b5d1f
@ -16,9 +16,11 @@ sealed class AutofillSaveItem : Parcelable {
|
||||
* @property expirationMonth The expiration month in string form (if applicable).
|
||||
* @property expirationYear The expiration year in string form (if applicable).
|
||||
* @property securityCode The security code for the card (if applicable).
|
||||
* @property cardholderName The name on the card (if applicable).
|
||||
*/
|
||||
@Parcelize
|
||||
data class Card(
|
||||
val cardholderName: String?,
|
||||
val number: String?,
|
||||
val expirationMonth: String?,
|
||||
val expirationYear: String?,
|
||||
|
||||
@ -34,6 +34,13 @@ val AutofillPartition.Card.securityCodeSaveValue: String?
|
||||
get() = this
|
||||
.extractNonNullTextValueOrNull { it is AutofillView.Card.SecurityCode }
|
||||
|
||||
/**
|
||||
* The text value representation of the cardholder name from the [AutofillPartition.Card].
|
||||
*/
|
||||
val AutofillPartition.Card.cardholderName: String?
|
||||
get() = this
|
||||
.extractNonNullTextValueOrNull { it is AutofillView.Card.CardholderName }
|
||||
|
||||
/**
|
||||
* The text value representation of the password from the [AutofillPartition.Login].
|
||||
*/
|
||||
|
||||
@ -11,6 +11,7 @@ fun AutofillRequest.Fillable.toAutofillSaveItem(): AutofillSaveItem =
|
||||
when (this.partition) {
|
||||
is AutofillPartition.Card -> {
|
||||
AutofillSaveItem.Card(
|
||||
cardholderName = partition.cardholderName,
|
||||
number = partition.numberSaveValue,
|
||||
expirationMonth = partition.expirationMonthSaveValue,
|
||||
expirationYear = partition.expirationYearSaveValue,
|
||||
|
||||
@ -21,6 +21,7 @@ fun AutofillSaveItem.toDefaultAddTypeContent(
|
||||
common = VaultAddEditState.ViewState.Content.Common(),
|
||||
isIndividualVaultDisabled = isIndividualVaultDisabled,
|
||||
type = VaultAddEditState.ViewState.Content.ItemType.Card(
|
||||
cardHolderName = this.cardholderName.orEmpty(),
|
||||
number = this.number.orEmpty(),
|
||||
expirationMonth = VaultCardExpirationMonth
|
||||
.entries
|
||||
|
||||
@ -31,11 +31,13 @@ class AutofillRequestExtensionsTest {
|
||||
every { expirationYearSaveValue } returns SAVE_VALUE_YEAR
|
||||
every { numberSaveValue } returns SAVE_VALUE_NUMBER
|
||||
every { securityCodeSaveValue } returns SAVE_VALUE_CODE
|
||||
every { cardholderName } returns SAVE_VALUE_CARDHOLDER_NAME
|
||||
}
|
||||
val autofillRequest: AutofillRequest.Fillable = mockk {
|
||||
every { partition } returns autofillPartition
|
||||
}
|
||||
val expected = AutofillSaveItem.Card(
|
||||
cardholderName = SAVE_VALUE_CARDHOLDER_NAME,
|
||||
number = SAVE_VALUE_NUMBER,
|
||||
expirationMonth = SAVE_VALUE_MONTH,
|
||||
expirationYear = SAVE_VALUE_YEAR,
|
||||
@ -109,6 +111,7 @@ private const val SAVE_VALUE_CODE: String = "SAVE_VALUE_CODE"
|
||||
private const val SAVE_VALUE_MONTH: String = "SAVE_VALUE_MONTH"
|
||||
private const val SAVE_VALUE_NUMBER: String = "SAVE_VALUE_NUMBER"
|
||||
private const val SAVE_VALUE_YEAR: String = "SAVE_VALUE_YEAR"
|
||||
private const val SAVE_VALUE_CARDHOLDER_NAME: String = "SAVE_VALUE_CARDHOLDER_NAME"
|
||||
|
||||
// LOGIN DATA
|
||||
private const val SAVE_VALUE_PASSWORD: String = "SAVE_VALUE_PASSWORD"
|
||||
|
||||
@ -32,6 +32,7 @@ class AutofillSaveItemExtensionsTest {
|
||||
common = VaultAddEditState.ViewState.Content.Common(),
|
||||
isIndividualVaultDisabled = false,
|
||||
type = VaultAddEditState.ViewState.Content.ItemType.Card(
|
||||
cardHolderName = "cardholderName",
|
||||
number = "number",
|
||||
expirationMonth = VaultCardExpirationMonth.JANUARY,
|
||||
expirationYear = "2024",
|
||||
@ -39,6 +40,7 @@ class AutofillSaveItemExtensionsTest {
|
||||
),
|
||||
),
|
||||
AutofillSaveItem.Card(
|
||||
cardholderName = "cardholderName",
|
||||
number = "number",
|
||||
expirationMonth = "1",
|
||||
expirationYear = "2024",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user