-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add end-to-end tests for Link Card Brand
- Loading branch information
1 parent
b0a6dd8
commit 2dbbc0c
Showing
3 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
paymentsheet-example/src/androidTest/java/com/stripe/android/lpm/TestLinkCardBrand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
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.test.ext.junit.runners.AndroidJUnit4 | ||
import com.stripe.android.BasePlaygroundTest | ||
import com.stripe.android.paymentsheet.example.playground.settings.AutomaticPaymentMethodsSettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.Country | ||
import com.stripe.android.paymentsheet.example.playground.settings.CountrySettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.Currency | ||
import com.stripe.android.paymentsheet.example.playground.settings.CurrencySettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.DefaultBillingAddress | ||
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.ui.PAYMENT_SHEET_PRIMARY_BUTTON_TEST_TAG | ||
import com.stripe.android.test.core.AuthorizeAction | ||
import com.stripe.android.test.core.DEFAULT_UI_TIMEOUT | ||
import com.stripe.android.test.core.TestParameters | ||
import com.stripe.android.test.core.ui.ComposeButton | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
internal class TestLinkCardBrand : BasePlaygroundTest() { | ||
|
||
private val testParameters = TestParameters.create( | ||
paymentMethodCode = "link", | ||
) { settings -> | ||
settings[CountrySettingsDefinition] = Country.US | ||
settings[CurrencySettingsDefinition] = Currency.USD | ||
settings[AutomaticPaymentMethodsSettingsDefinition] = false | ||
settings[DefaultBillingAddressSettingsDefinition] = DefaultBillingAddress.On | ||
settings[LinkSettingsDefinition] = true | ||
settings[SupportedPaymentMethodsSettingsDefinition] = "card" | ||
} | ||
|
||
@Test | ||
fun testLinkCardBrandSuccess() { | ||
val params = testParameters.copyPlaygroundSettings { | ||
it[DefaultBillingAddressSettingsDefinition] = DefaultBillingAddress.On | ||
} | ||
|
||
testDriver.confirmLinkBankPayment( | ||
testParameters = params, | ||
afterAuthorization = { | ||
rules.compose.waitUntil(DEFAULT_UI_TIMEOUT.inWholeMilliseconds) { | ||
rules.compose | ||
.onAllNodesWithText("STRIPE TEST BANK •••• 6789") | ||
.fetchSemanticsNodes(atLeastOneRootRequired = false) | ||
.isNotEmpty() | ||
} | ||
} | ||
) | ||
} | ||
|
||
@Test | ||
fun testLinkCardBrandCancelAllowsUserToContinue() { | ||
testDriver.confirmLinkBankPayment( | ||
testParameters = testParameters.copy( | ||
authorizationAction = AuthorizeAction.Cancel, | ||
), | ||
afterAuthorization = { | ||
ComposeButton(rules.compose, hasTestTag(PAYMENT_SHEET_PRIMARY_BUTTON_TEST_TAG)) | ||
.waitFor(isEnabled()) | ||
} | ||
) | ||
} | ||
|
||
@Test | ||
fun testLinkCardBrandCancelAllowsUserToContinueInCustomFlow() { | ||
testDriver.confirmInstantDebitsInCustomFlow( | ||
testParameters = testParameters.copy( | ||
authorizationAction = AuthorizeAction.Cancel, | ||
), | ||
afterAuthorization = { | ||
ComposeButton(rules.compose, hasTestTag(PAYMENT_SHEET_PRIMARY_BUTTON_TEST_TAG)) | ||
.waitFor(isEnabled()) | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters