Skip to content

Commit

Permalink
Use test tag instead of text comparison in LBP tests (#9394)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe authored Oct 3, 2024
1 parent 671c858 commit 87f527e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.stripe.android.lpm

import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.isEnabled
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.stripe.android.BasePlaygroundTest
import com.stripe.android.model.PaymentMethod
Expand All @@ -15,6 +15,7 @@ import com.stripe.android.paymentsheet.example.playground.settings.DefaultBillin
import com.stripe.android.paymentsheet.example.playground.settings.DefaultBillingAddressSettingsDefinition
import com.stripe.android.paymentsheet.example.playground.settings.LinkSettingsDefinition
import com.stripe.android.paymentsheet.example.playground.settings.SupportedPaymentMethodsSettingsDefinition
import com.stripe.android.paymentsheet.paymentdatacollection.ach.TEST_TAG_ACCOUNT_DETAILS
import com.stripe.android.paymentsheet.ui.PAYMENT_SHEET_PRIMARY_BUTTON_TEST_TAG
import com.stripe.android.test.core.AuthorizeAction
import com.stripe.android.test.core.DEFAULT_UI_TIMEOUT
Expand Down Expand Up @@ -51,7 +52,7 @@ internal class TestInstantDebits : BasePlaygroundTest() {
afterAuthorization = {
rules.compose.waitUntil(DEFAULT_UI_TIMEOUT.inWholeMilliseconds) {
rules.compose
.onAllNodesWithText("STRIPE TEST BANK •••• 6789")
.onAllNodesWithTag(TEST_TAG_ACCOUNT_DETAILS)
.fetchSemanticsNodes(atLeastOneRootRequired = false)
.isNotEmpty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.stripe.android.lpm

import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.isEnabled
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.stripe.android.BasePlaygroundTest
import com.stripe.android.paymentsheet.example.playground.settings.AutomaticPaymentMethodsSettingsDefinition
Expand All @@ -14,6 +14,7 @@ import com.stripe.android.paymentsheet.example.playground.settings.DefaultBillin
import com.stripe.android.paymentsheet.example.playground.settings.DefaultBillingAddressSettingsDefinition
import com.stripe.android.paymentsheet.example.playground.settings.LinkSettingsDefinition
import com.stripe.android.paymentsheet.example.playground.settings.SupportedPaymentMethodsSettingsDefinition
import com.stripe.android.paymentsheet.paymentdatacollection.ach.TEST_TAG_ACCOUNT_DETAILS
import com.stripe.android.paymentsheet.ui.PAYMENT_SHEET_PRIMARY_BUTTON_TEST_TAG
import com.stripe.android.test.core.AuthorizeAction
import com.stripe.android.test.core.DEFAULT_UI_TIMEOUT
Expand Down Expand Up @@ -47,7 +48,7 @@ internal class TestLinkCardBrand : BasePlaygroundTest() {
afterAuthorization = {
rules.compose.waitUntil(DEFAULT_UI_TIMEOUT.inWholeMilliseconds) {
rules.compose
.onAllNodesWithText("STRIPE TEST BANK •••• 6789")
.onAllNodesWithTag(TEST_TAG_ACCOUNT_DETAILS)
.fetchSemanticsNodes(atLeastOneRootRequired = false)
.isNotEmpty()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stripe.android.paymentsheet.paymentdatacollection.ach

import androidx.annotation.RestrictTo
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -22,6 +23,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
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
Expand Down Expand Up @@ -52,6 +54,9 @@ import com.stripe.android.uicore.utils.collectAsState
import com.stripe.android.R as StripeR
import com.stripe.android.ui.core.R as PaymentsUiCoreR

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
const val TEST_TAG_ACCOUNT_DETAILS = "TEST_TAG_ACCOUNT_DETAILS"

@Composable
internal fun USBankAccountForm(
formArgs: FormArguments,
Expand Down Expand Up @@ -408,6 +413,7 @@ private fun AccountDetailsForm(
Modifier
.fillMaxWidth()
.padding(bottom = 8.dp)
.testTag(TEST_TAG_ACCOUNT_DETAILS)
) {
H6Text(
text = stringResource(StripeR.string.stripe_title_bank_account),
Expand Down

0 comments on commit 87f527e

Please sign in to comment.