[PM-24599] Add cardholderName to AutofillSaveItem.Card (#5716)

This commit is contained in:
Patrick Honkonen 2025-08-18 12:29:26 -04:00 committed by GitHub
parent 9fcfcc9e41
commit af322b5d1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 16 additions and 0 deletions

View File

@ -16,9 +16,11 @@ sealed class AutofillSaveItem : Parcelable {
* @property expirationMonth The expiration month in string form (if applicable). * @property expirationMonth The expiration month in string form (if applicable).
* @property expirationYear The expiration year 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 securityCode The security code for the card (if applicable).
* @property cardholderName The name on the card (if applicable).
*/ */
@Parcelize @Parcelize
data class Card( data class Card(
val cardholderName: String?,
val number: String?, val number: String?,
val expirationMonth: String?, val expirationMonth: String?,
val expirationYear: String?, val expirationYear: String?,

View File

@ -34,6 +34,13 @@ val AutofillPartition.Card.securityCodeSaveValue: String?
get() = this get() = this
.extractNonNullTextValueOrNull { it is AutofillView.Card.SecurityCode } .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]. * The text value representation of the password from the [AutofillPartition.Login].
*/ */

View File

@ -11,6 +11,7 @@ fun AutofillRequest.Fillable.toAutofillSaveItem(): AutofillSaveItem =
when (this.partition) { when (this.partition) {
is AutofillPartition.Card -> { is AutofillPartition.Card -> {
AutofillSaveItem.Card( AutofillSaveItem.Card(
cardholderName = partition.cardholderName,
number = partition.numberSaveValue, number = partition.numberSaveValue,
expirationMonth = partition.expirationMonthSaveValue, expirationMonth = partition.expirationMonthSaveValue,
expirationYear = partition.expirationYearSaveValue, expirationYear = partition.expirationYearSaveValue,

View File

@ -21,6 +21,7 @@ fun AutofillSaveItem.toDefaultAddTypeContent(
common = VaultAddEditState.ViewState.Content.Common(), common = VaultAddEditState.ViewState.Content.Common(),
isIndividualVaultDisabled = isIndividualVaultDisabled, isIndividualVaultDisabled = isIndividualVaultDisabled,
type = VaultAddEditState.ViewState.Content.ItemType.Card( type = VaultAddEditState.ViewState.Content.ItemType.Card(
cardHolderName = this.cardholderName.orEmpty(),
number = this.number.orEmpty(), number = this.number.orEmpty(),
expirationMonth = VaultCardExpirationMonth expirationMonth = VaultCardExpirationMonth
.entries .entries

View File

@ -31,11 +31,13 @@ class AutofillRequestExtensionsTest {
every { expirationYearSaveValue } returns SAVE_VALUE_YEAR every { expirationYearSaveValue } returns SAVE_VALUE_YEAR
every { numberSaveValue } returns SAVE_VALUE_NUMBER every { numberSaveValue } returns SAVE_VALUE_NUMBER
every { securityCodeSaveValue } returns SAVE_VALUE_CODE every { securityCodeSaveValue } returns SAVE_VALUE_CODE
every { cardholderName } returns SAVE_VALUE_CARDHOLDER_NAME
} }
val autofillRequest: AutofillRequest.Fillable = mockk { val autofillRequest: AutofillRequest.Fillable = mockk {
every { partition } returns autofillPartition every { partition } returns autofillPartition
} }
val expected = AutofillSaveItem.Card( val expected = AutofillSaveItem.Card(
cardholderName = SAVE_VALUE_CARDHOLDER_NAME,
number = SAVE_VALUE_NUMBER, number = SAVE_VALUE_NUMBER,
expirationMonth = SAVE_VALUE_MONTH, expirationMonth = SAVE_VALUE_MONTH,
expirationYear = SAVE_VALUE_YEAR, 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_MONTH: String = "SAVE_VALUE_MONTH"
private const val SAVE_VALUE_NUMBER: String = "SAVE_VALUE_NUMBER" 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_YEAR: String = "SAVE_VALUE_YEAR"
private const val SAVE_VALUE_CARDHOLDER_NAME: String = "SAVE_VALUE_CARDHOLDER_NAME"
// LOGIN DATA // LOGIN DATA
private const val SAVE_VALUE_PASSWORD: String = "SAVE_VALUE_PASSWORD" private const val SAVE_VALUE_PASSWORD: String = "SAVE_VALUE_PASSWORD"

View File

@ -32,6 +32,7 @@ class AutofillSaveItemExtensionsTest {
common = VaultAddEditState.ViewState.Content.Common(), common = VaultAddEditState.ViewState.Content.Common(),
isIndividualVaultDisabled = false, isIndividualVaultDisabled = false,
type = VaultAddEditState.ViewState.Content.ItemType.Card( type = VaultAddEditState.ViewState.Content.ItemType.Card(
cardHolderName = "cardholderName",
number = "number", number = "number",
expirationMonth = VaultCardExpirationMonth.JANUARY, expirationMonth = VaultCardExpirationMonth.JANUARY,
expirationYear = "2024", expirationYear = "2024",
@ -39,6 +40,7 @@ class AutofillSaveItemExtensionsTest {
), ),
), ),
AutofillSaveItem.Card( AutofillSaveItem.Card(
cardholderName = "cardholderName",
number = "number", number = "number",
expirationMonth = "1", expirationMonth = "1",
expirationYear = "2024", expirationYear = "2024",