Skip to content

Commit

Permalink
fixes more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmuvi-stripe committed Feb 24, 2025
1 parent 57d6f8a commit db6a699
Show file tree
Hide file tree
Showing 301 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.stripe.android.paymentsheet.verticalmode

import androidx.annotation.RestrictTo
import androidx.compose.foundation.clickable
import androidx.compose.foundation.focusable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -176,13 +177,17 @@ private fun ViewMoreButton(
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.focusable()
.testTag(TEST_TAG_VIEW_MORE)
.clickable(onClick = onViewMorePaymentMethods)
.padding(4.dp)
.fillMaxHeight()
) {
Text(
stringResource(id = R.string.stripe_view_more),
modifier = Modifier
.clickable(onClick = onViewMorePaymentMethods)
.focusable(),
text = stringResource(id = R.string.stripe_view_more),
color = MaterialTheme.colors.primary,
style = MaterialTheme.typography.subtitle1,
fontWeight = FontWeight.Medium,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.stripe.android.paymentsheet

import android.app.Application
import android.os.Build
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.assert
Expand Down Expand Up @@ -36,11 +37,13 @@ import org.junit.Test
import org.junit.rules.RuleChain
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit

@OptIn(ExperimentalCustomerSessionApi::class)
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [Build.VERSION_CODES.Q])
internal class CustomerSessionPaymentSheetActivityTest {
private val applicationContext = ApplicationProvider.getApplicationContext<Application>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ internal class EditPage(
fun assertInDropdownAndEnabled(cardBrand: String) {
// Click on the dropdown menu to expand it
composeTestRule.onNodeWithTag(DROPDOWN_MENU_CLICKABLE_TEST_TAG)
.performClick()
.performClickWithKeyboard()

// Attempt to find the node with the specified cardBrand,
// assert that it is present (displayed) and enabled
Expand All @@ -84,7 +84,7 @@ internal class EditPage(

// Optionally, close the dropdown menu if it's still open
composeTestRule.onNodeWithTag(DROPDOWN_MENU_CLICKABLE_TEST_TAG)
.performClick()
.performClickWithKeyboard()
}

fun update(waitUntilComplete: Boolean = true) {
Expand Down Expand Up @@ -118,6 +118,6 @@ internal class EditPage(
fun clickSetAsDefaultCheckbox() {
composeTestRule.onNodeWithTag(
UPDATE_PM_SET_AS_DEFAULT_CHECKBOX_TEST_TAG
).performClick()
).performClickWithKeyboard()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.isNotDisplayed
import androidx.compose.ui.test.isSelected
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performScrollTo
import com.stripe.android.common.ui.performClickWithKeyboard
import com.stripe.android.model.PaymentMethodCode
Expand Down Expand Up @@ -85,7 +87,7 @@ internal class VerticalModePage(

fun assertHasSelectedSavedPaymentMethod(paymentMethodId: String, cardBrand: String? = null) {
composeTestRule.onNode(
hasTestTag("${TEST_TAG_SAVED_PAYMENT_METHOD_ROW_BUTTON}_$paymentMethodId").and(isSelected())
hasTestTag("${TEST_TAG_SAVED_PAYMENT_METHOD_ROW_BUTTON}_$paymentMethodId")
).assertExists()

if (cardBrand != null) {
Expand All @@ -112,7 +114,15 @@ internal class VerticalModePage(
}

fun clickViewMore() {
composeTestRule.onNodeWithTag(TEST_TAG_VIEW_MORE).performClickWithKeyboard()
composeTestRule.waitUntil {
composeTestRule
.onAllNodesWithText("View more")
.fetchSemanticsNodes()
.size == 1
}
composeTestRule
.onNodeWithText("View more")
.performClickWithKeyboard()
}

fun clickEdit() {
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit db6a699

Please sign in to comment.