Skip to content

Commit

Permalink
Address code review feedback
Browse files Browse the repository at this point in the history
Fix layout issue with super-long bank name and validate with screenshot test.
  • Loading branch information
tillh-stripe committed Dec 5, 2024
1 parent 01500e5 commit 99bd861
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.stripe.android.paymentsheet.PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode
Expand Down Expand Up @@ -396,6 +397,7 @@ private fun AccountDetailsForm(
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.weight(1f)
) {
Image(
painter = painterResource(bankIcon),
Expand All @@ -405,8 +407,11 @@ private fun AccountDetailsForm(

Text(
text = "$bankName •••• $last4",
modifier = Modifier.alpha(if (isProcessing) 0.5f else 1f),
color = MaterialTheme.stripeColors.onComponent,
overflow = TextOverflow.Ellipsis,
modifier = Modifier
.alpha(if (isProcessing) 0.5f else 1f)
.weight(1f, fill = false),
)

promoBadgeState?.let { badgeState ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,32 @@ internal class AccountPreviewScreenshotTest {
}
}

@Test
fun testWithPromoBadgeNextToSuperLongAccountName() {
paparazzi.snapshot {
BankAccountForm(
state = BankFormScreenStateFactory.createWithSession(
sessionId = "session_1234",
promoText = "$5",
eligibleForPromo = false,
bankName = "SuperDuperUltraLongBankName",
),
instantDebits = true,
isPaymentFlow = true,
formArgs = formArguments,
nameController = createNameController(),
emailController = createEmailController(),
phoneController = createPhoneNumberController(),
addressController = createAddressController(fillAddress = false),
sameAsShippingElement = sameAsShippingElement,
saveForFutureUseElement = saveForFutureUseElement,
showCheckbox = false,
lastTextFieldIdentifier = null,
onRemoveAccount = {},
)
}
}

@Test
fun testWithIneligiblePromoBadge() {
paparazzi.snapshot {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ internal object BankFormScreenStateFactory {
mandateText: ResolvableString = "Some legal text".resolvableString,
promoText: String? = null,
eligibleForPromo: Boolean = true,
bankName: String = "Stripe Bank",
): BankFormScreenState {
return create(
resultIdentifier = BankFormScreenState.ResultIdentifier.Session(sessionId),
isVerifyingWithMicrodeposits = isVerifyingWithMicrodeposits,
mandateText = mandateText,
promoText = promoText,
eligibleForPromo = eligibleForPromo,
bankName = bankName,
)
}

Expand All @@ -43,14 +45,15 @@ internal object BankFormScreenStateFactory {
mandateText: ResolvableString,
promoText: String?,
eligibleForPromo: Boolean,
bankName: String = "Stripe Bank",
): BankFormScreenState {
return BankFormScreenState(
isPaymentFlow = true,
linkedBankAccount = BankFormScreenState.LinkedBankAccount(
resultIdentifier = resultIdentifier,
financialConnectionsSessionId = "session_1234",
intentId = "intent_1234",
bankName = "Stripe Bank",
bankName = bankName,
last4 = "6789",
mandateText = mandateText,
isVerifyingWithMicrodeposits = isVerifyingWithMicrodeposits,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 99bd861

Please sign in to comment.