diff --git a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/CustomerSheetPage.kt b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/CustomerSheetPage.kt index 38dc0dd4af0..5cb28e1d8d2 100644 --- a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/CustomerSheetPage.kt +++ b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/CustomerSheetPage.kt @@ -158,6 +158,11 @@ internal class CustomerSheetPage( .performTextReplacement(text) } + private fun fillExpirationDate(text: String) { + composeTestRule.onNode(hasContentDescription(value = "Expiration date", substring = true)) + .performTextReplacement(text) + } + private fun clickDropdownMenu() { waitForIdle() diff --git a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/PaymentSheetBillingConfigurationTest.kt b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/PaymentSheetBillingConfigurationTest.kt index 50bff2310c0..a6c209bf31e 100644 --- a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/PaymentSheetBillingConfigurationTest.kt +++ b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/PaymentSheetBillingConfigurationTest.kt @@ -213,7 +213,7 @@ internal class PaymentSheetBillingConfigurationTest { } page.replaceText("123 Main Street", "123 Main Road") - page.replaceText("MM / YY", "12/34") + page.fillExpirationDate("12/34") // Check that line 1 was not reset to default value page.waitForText("123 Main Road") diff --git a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/PaymentSheetPage.kt b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/PaymentSheetPage.kt index c69cbbcbef0..a85822ce479 100644 --- a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/PaymentSheetPage.kt +++ b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/PaymentSheetPage.kt @@ -7,6 +7,7 @@ import android.widget.Button import androidx.compose.ui.test.ExperimentalTestApi import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsEnabled +import androidx.compose.ui.test.hasContentDescription import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.hasText import androidx.compose.ui.test.isEnabled @@ -38,7 +39,7 @@ internal class PaymentSheetPage( waitForText("Card number") replaceText("Card number", "4242424242424242") - replaceText("MM / YY", "12/34") + fillExpirationDate("12/34") replaceText("CVC", "123") if (fillOutZipCode) { @@ -106,7 +107,7 @@ internal class PaymentSheetPage( waitForText("Card number") replaceText("Card number", "4000002500001001") - replaceText("MM / YY", "12/34") + fillExpirationDate("12/34") replaceText("CVC", "123") clickDropdownMenu() @@ -201,6 +202,11 @@ internal class PaymentSheetPage( .performTextReplacement(text) } + fun fillExpirationDate(text: String) { + composeTestRule.onNode(hasContentDescription(value = "Expiration date", substring = true)) + .performTextReplacement(text) + } + private fun clickDropdownMenu() { composeTestRule.onNode(hasTestTag(DROPDOWN_MENU_CLICKABLE_TEST_TAG)) .performScrollTo() diff --git a/paymentsheet/src/test/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodScreenTest.kt b/paymentsheet/src/test/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodScreenTest.kt index 2e902f8b97c..c8caa838a78 100644 --- a/paymentsheet/src/test/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodScreenTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodScreenTest.kt @@ -7,6 +7,7 @@ import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotDisplayed +import androidx.compose.ui.test.hasContentDescription import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onChild @@ -189,7 +190,9 @@ internal class PaymentMethodScreenTest { private fun onCvc() = composeTestRule.onNode(hasText("CVC")) - private fun onExpiryDate() = composeTestRule.onNode(hasText("MM / YY")) + private fun onExpiryDate() = composeTestRule.onNode( + hasContentDescription(value = "Expiration date", substring = true) + ) private fun onZipCode() = composeTestRule.onNode(hasText("ZIP Code"))