-
Notifications
You must be signed in to change notification settings - Fork 982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embedded confirm tests #4249
Merged
+268
−1
Merged
Embedded confirm tests #4249
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7e9b98d
Embedded UI tests
porter-stripe 06f3469
Fix multiple elements matching in test
porter-stripe 6fe6f54
Use first match
porter-stripe a231672
Handle small screen
porter-stripe 3772d0e
PR feedback
porter-stripe 71d5694
Try to fix test on CI
porter-stripe 203013a
Try to fix test in CI
porter-stripe c8b3cdc
Merge branch 'master' into porter/embedded-confirm-tests
porter-stripe 0011e19
Merge branch 'porter/embedded-confirm-tests' of github.com:stripe/str…
porter-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -536,6 +536,268 @@ class EmbeddedUITests: PaymentSheetUITestCase { | |
springboard.buttons["Continue"].waitForExistenceAndTap() | ||
// Stop here; Links's test playground is out of scope | ||
} | ||
|
||
func testCVCRecollection() { | ||
var settings = PaymentSheetTestPlaygroundSettings.defaultValues() | ||
settings.customerMode = .returning | ||
settings.mode = .payment | ||
settings.integrationType = .deferred_csc | ||
settings.uiStyle = .embedded | ||
settings.formSheetAction = .continue | ||
settings.requireCVCRecollection = .on | ||
loadPlayground(app, settings) | ||
app.buttons["Present embedded payment element"].waitForExistenceAndTap() | ||
|
||
// Select the saved card | ||
app.buttons["View more"].waitForExistenceAndTap() | ||
XCTAssertTrue(app.staticTexts["Select payment method"].waitForExistence(timeout: 10)) | ||
app.buttons["•••• 4242"].firstMatch.waitForExistenceAndTap() | ||
|
||
// Ensure the card is selected and start checking out | ||
XCTAssertEqual(app.staticTexts["Payment method"].label, "•••• 4242") | ||
app.swipeUp() // scroll to see the checkout button | ||
XCTAssertTrue(app.buttons["Checkout"].isEnabled) | ||
app.buttons["Checkout"].waitForExistenceAndTap() | ||
|
||
// CVC field should already be selected | ||
app.typeText("123") | ||
app.buttons["Confirm"].waitForExistenceAndTap() | ||
|
||
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 10)) | ||
} | ||
|
||
func testCashAppPay() { | ||
var settings = PaymentSheetTestPlaygroundSettings.defaultValues() | ||
settings.customerMode = .returning | ||
settings.mode = .payment | ||
settings.integrationType = .deferred_csc | ||
settings.uiStyle = .embedded | ||
settings.formSheetAction = .continue | ||
loadPlayground(app, settings) | ||
app.buttons["Present embedded payment element"].waitForExistenceAndTap() | ||
|
||
app.buttons["Cash App Pay"].waitForExistenceAndTap() | ||
|
||
// Ensure Cash App Pay is selected and start checking out | ||
XCTAssertEqual(app.staticTexts["Payment method"].label, "Cash App Pay") | ||
app.swipeUp() // scroll to see the checkout button | ||
XCTAssertTrue(app.buttons["Checkout"].isEnabled) | ||
app.buttons["Checkout"].waitForExistenceAndTap() | ||
|
||
webviewAuthorizePaymentButton.waitForExistenceAndTap(timeout: 10) | ||
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 10)) | ||
} | ||
|
||
func testCashAppPayAndSetup() { | ||
var settings = PaymentSheetTestPlaygroundSettings.defaultValues() | ||
settings.customerMode = .returning | ||
settings.mode = .paymentWithSetup | ||
settings.integrationType = .deferred_csc | ||
settings.uiStyle = .embedded | ||
settings.formSheetAction = .continue | ||
loadPlayground(app, settings) | ||
app.buttons["Present embedded payment element"].waitForExistenceAndTap() | ||
|
||
app.buttons["Cash App Pay"].waitForExistenceAndTap() | ||
|
||
// Ensure Cash App Pay is selected and start checking out | ||
XCTAssertEqual(app.staticTexts["Payment method"].label, "Cash App Pay") | ||
app.swipeUp() // scroll to see the checkout button | ||
XCTAssertTrue(app.buttons["Checkout"].isEnabled) | ||
app.buttons["Checkout"].waitForExistenceAndTap() | ||
|
||
webviewAuthorizePaymentButton.waitForExistenceAndTap(timeout: 10) | ||
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 10)) | ||
} | ||
|
||
func testCashAppPaySetup() { | ||
var settings = PaymentSheetTestPlaygroundSettings.defaultValues() | ||
settings.customerMode = .returning | ||
settings.mode = .setup | ||
settings.integrationType = .deferred_csc | ||
settings.uiStyle = .embedded | ||
settings.formSheetAction = .continue | ||
loadPlayground(app, settings) | ||
app.buttons["Present embedded payment element"].waitForExistenceAndTap() | ||
|
||
app.buttons["Cash App Pay"].waitForExistenceAndTap() | ||
|
||
// Ensure Cash App Pay is selected and start checking out | ||
XCTAssertEqual(app.staticTexts["Payment method"].label, "Cash App Pay") | ||
app.swipeUp() // scroll to see the checkout button | ||
XCTAssertTrue(app.buttons["Checkout"].isEnabled) | ||
app.buttons["Checkout"].waitForExistenceAndTap() | ||
|
||
webviewAuthorizeSetupButton.waitForExistenceAndTap(timeout: 10) | ||
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 10)) | ||
} | ||
|
||
func testCashAppPayBillingAddressCollection() { | ||
var settings = PaymentSheetTestPlaygroundSettings.defaultValues() | ||
settings.customerMode = .returning | ||
settings.mode = .payment | ||
settings.integrationType = .deferred_csc | ||
settings.uiStyle = .embedded | ||
settings.formSheetAction = .continue | ||
settings.collectName = .always | ||
loadPlayground(app, settings) | ||
app.buttons["Present embedded payment element"].waitForExistenceAndTap() | ||
|
||
app.buttons["Cash App Pay"].waitForExistenceAndTap() | ||
|
||
let fullNameField = app.textFields["Full name"] | ||
XCTAssertTrue(fullNameField.waitForExistence(timeout: 10)) | ||
fullNameField.forceTapElement() | ||
fullNameField.typeText("Jane Doe") | ||
|
||
app.buttons["Continue"].tap() | ||
|
||
// Ensure Cash App Pay is selected and start checking out | ||
XCTAssertTrue(app.staticTexts["Payment method"].waitForExistence(timeout: 10)) | ||
XCTAssertEqual(app.staticTexts["Payment method"].label, "Cash App Pay") | ||
app.swipeUp() // scroll to see the checkout button | ||
XCTAssertTrue(app.buttons["Checkout"].isEnabled) | ||
app.buttons["Checkout"].waitForExistenceAndTap() | ||
|
||
webviewAuthorizePaymentButton.waitForExistenceAndTap(timeout: 10) | ||
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 10)) | ||
} | ||
|
||
func testExternalPayPal() { | ||
var settings = PaymentSheetTestPlaygroundSettings.defaultValues() | ||
settings.customerMode = .new | ||
settings.mode = .payment | ||
settings.integrationType = .deferred_csc | ||
settings.uiStyle = .embedded | ||
settings.formSheetAction = .continue | ||
settings.externalPaymentMethods = .paypal | ||
loadPlayground(app, settings) | ||
app.buttons["Present embedded payment element"].waitForExistenceAndTap() | ||
|
||
app.buttons["PayPal"].waitForExistenceAndTap() | ||
|
||
// Ensure PayPal is selected and start checking out | ||
XCTAssertEqual(app.staticTexts["Payment method"].label, "PayPal") | ||
app.swipeUp() // scroll to see the checkout button | ||
XCTAssertTrue(app.buttons["Checkout"].isEnabled) | ||
app.buttons["Checkout"].waitForExistenceAndTap() | ||
|
||
XCTAssertNotNil(app.staticTexts["Confirm external_paypal?"]) | ||
app.buttons["Cancel"].waitForExistenceAndTap() | ||
|
||
app.buttons["Checkout"].waitForExistenceAndTap() | ||
let payButton = app.buttons["Confirm"] | ||
payButton.waitForExistenceAndTap() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
|
||
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 10)) | ||
} | ||
|
||
func testSEPA() { | ||
var settings = PaymentSheetTestPlaygroundSettings.defaultValues() | ||
settings.currency = .eur | ||
settings.allowsDelayedPMs = .on | ||
settings.customerMode = .new | ||
settings.mode = .payment | ||
settings.integrationType = .deferred_csc | ||
settings.uiStyle = .embedded | ||
settings.formSheetAction = .confirm | ||
loadPlayground(app, settings) | ||
app.buttons["Present embedded payment element"].waitForExistenceAndTap() | ||
|
||
app.buttons["SEPA Debit"].waitForExistenceAndTap() | ||
|
||
app.textFields["Full name"].waitForExistenceAndTap() | ||
app.typeText("John Doe" + XCUIKeyboardKey.return.rawValue) | ||
app.typeText("[email protected]" + XCUIKeyboardKey.return.rawValue) | ||
app.typeText("AT611904300234573201" + XCUIKeyboardKey.return.rawValue) | ||
app.textFields["Address line 1"].tap() | ||
app.typeText("510 Townsend St" + XCUIKeyboardKey.return.rawValue) | ||
app.typeText("Floor 3" + XCUIKeyboardKey.return.rawValue) | ||
app.typeText("San Francisco" + XCUIKeyboardKey.return.rawValue) | ||
app.textFields["ZIP"].tap() | ||
app.typeText("94102" + XCUIKeyboardKey.return.rawValue) | ||
app.buttons["Pay €50.99"].tap() | ||
|
||
let successText = app.staticTexts["Success!"] | ||
XCTAssertTrue(successText.waitForExistence(timeout: 10.0)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
} | ||
|
||
func testUSBankAccount() { | ||
var settings = PaymentSheetTestPlaygroundSettings.defaultValues() | ||
settings.customerMode = .returning | ||
settings.mode = .payment | ||
settings.integrationType = .deferred_csc | ||
settings.uiStyle = .embedded | ||
settings.formSheetAction = .confirm | ||
loadPlayground(app, settings) | ||
app.buttons["Present embedded payment element"].waitForExistenceAndTap() | ||
|
||
XCTAssertTrue(app.buttons["US bank account"].waitForExistenceAndTap()) | ||
|
||
// Fill out name and email fields | ||
let continueButton = app.buttons["Continue"] | ||
XCTAssertFalse(continueButton.isEnabled) | ||
app.textFields["Full name"].tap() | ||
app.typeText("John Doe" + XCUIKeyboardKey.return.rawValue) | ||
app.typeText("test-\(UUID().uuidString)@example.com" + XCUIKeyboardKey.return.rawValue) | ||
XCTAssertTrue(continueButton.isEnabled) | ||
continueButton.tap() | ||
|
||
// Go through connections flow | ||
app.buttons["Agree and continue"].tap() | ||
app.staticTexts["Test Institution"].forceTapElement() | ||
// "Success" institution is automatically selected because its the first | ||
app.buttons["connect_accounts_button"].waitForExistenceAndTap(timeout: 10) | ||
|
||
let notNowButton = app.buttons["Not now"] | ||
if notNowButton.waitForExistence(timeout: 10.0) { | ||
app.typeText(XCUIKeyboardKey.return.rawValue) // dismiss keyboard | ||
notNowButton.tap() | ||
} | ||
|
||
XCTAssertTrue(app.staticTexts["Success"].waitForExistence(timeout: 10)) | ||
app.buttons.matching(identifier: "Done").allElementsBoundByIndex.last?.tap() | ||
|
||
// Make sure bottom notice mandate is visible | ||
XCTAssertTrue(app.textViews["By continuing, you agree to authorize payments pursuant to these terms."].waitForExistence(timeout: 5)) | ||
|
||
let saveThisAccountToggle = app.switches["Save this account for future Example, Inc. payments"] | ||
XCTAssertFalse(saveThisAccountToggle.isSelected) | ||
saveThisAccountToggle.tap() | ||
|
||
// Confirm | ||
app.buttons["Pay $50.99"].waitForExistenceAndTap() | ||
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 10.0)) | ||
} | ||
|
||
func test3DS2CardAlwaysAuthenticate() throws { | ||
var settings = PaymentSheetTestPlaygroundSettings.defaultValues() | ||
settings.customerMode = .new | ||
settings.mode = .payment | ||
settings.integrationType = .deferred_csc | ||
settings.uiStyle = .embedded | ||
settings.formSheetAction = .continue | ||
settings.currency = .eur | ||
loadPlayground(app, settings) | ||
app.buttons["Present embedded payment element"].waitForExistenceAndTap() | ||
|
||
XCTAssertTrue(app.buttons["Card"].waitForExistenceAndTap()) | ||
XCTAssertTrue(app.staticTexts["Add card"].waitForExistence(timeout: 10)) | ||
|
||
// Card number from https://docs.stripe.com/testing#regulatory-cards | ||
try! fillCardData(app, cardNumber: "4000002760003184") | ||
app.toolbars.buttons["Done"].waitForExistenceAndTap() | ||
app.buttons["Continue"].waitForExistenceAndTap() | ||
app.swipeUp() // scroll to see the checkout button | ||
app.buttons["Checkout"].waitForExistenceAndTap() | ||
|
||
// Finish the 3DS2 payment | ||
let challengeCodeTextField = app.textFields["STDSTextField"] | ||
XCTAssertTrue(challengeCodeTextField.waitForExistenceAndTap(timeout: 10)) | ||
challengeCodeTextField.typeText("424242" + XCUIKeyboardKey.return.rawValue) | ||
app.buttons["Submit"].waitForExistenceAndTap() | ||
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 10.0)) | ||
} | ||
|
||
func dismissAlertView(alertBody: String, alertTitle: String, buttonToTap: String) { | ||
let alertText = app.staticTexts[alertBody] | ||
|
@@ -561,3 +823,8 @@ class EmbeddedUITests: PaymentSheetUITestCase { | |
XCTAssertTrue(app.buttons[label1].waitForExistence(timeout: 3.0)) | ||
} | ||
} | ||
|
||
extension EmbeddedUITests { | ||
var webviewAuthorizePaymentButton: XCUIElement { app.firstDescendant(withLabel: "AUTHORIZE TEST PAYMENT") } | ||
var webviewAuthorizeSetupButton: XCUIElement { app.firstDescendant(withLabel: "AUTHORIZE TEST SETUP") } | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: probably should:
(seems to be copied to multiple tests)