-
Notifications
You must be signed in to change notification settings - Fork 996
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Link] Add signup and sign-in flow UI tests (#1006)
* Add signup flow UI tests * Refactor virtual keyboard text entry * Add signin test * Add comment
- Loading branch information
1 parent
fffab3f
commit e60f3c3
Showing
4 changed files
with
127 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,6 +310,8 @@ class PaymentSheetUITest: XCTestCase { | |
|
||
extension PaymentSheetUITest { | ||
|
||
// MARK: Inline signup | ||
|
||
/// Tests the Link inline signup flow. | ||
func testLinkInlineSignup() throws { | ||
loadPlayground(app, settings: [ | ||
|
@@ -335,9 +337,7 @@ extension PaymentSheetUITest { | |
|
||
// XCUIApplication cannot synthesize typing events to the phone field. | ||
// So we need to punch-in each digit via the keyboard. | ||
"3105551234".forEach { digit in | ||
app.keys[String(digit)].tap() | ||
} | ||
app.typeTextWithKeyboard("3105551234") | ||
|
||
// Pay! | ||
app.buttons["Pay $50.99"].tap() | ||
|
@@ -376,11 +376,112 @@ extension PaymentSheetUITest { | |
let codeField = app.descendants(matching: .any)["Code field"] | ||
XCTAssert(codeField.waitForExistence(timeout: 10)) | ||
codeField.tap() | ||
app.typeTextWithKeyboard("000000") | ||
|
||
let successText = app.alerts.staticTexts["Success!"] | ||
XCTAssertTrue(successText.waitForExistence(timeout: 10)) | ||
|
||
let okButton = app.alerts.buttons["OK"] | ||
okButton.tap() | ||
} | ||
|
||
// MARK: Modal | ||
|
||
func testLinkSignup() throws { | ||
loadPlayground(app, settings: [ | ||
"customer_mode": "new", | ||
"automatic_payment_methods": "off", | ||
"link": "on" | ||
]) | ||
|
||
app.buttons["Checkout (Complete)"].tap() | ||
|
||
let payWithLinkButton = app.buttons["Pay with Link"] | ||
XCTAssertTrue(payWithLinkButton.waitForExistence(timeout: 10)) | ||
payWithLinkButton.tap() | ||
|
||
let modal = app.otherElements["Stripe.Link.PayWithLinkViewController"] | ||
XCTAssertTrue(modal.waitForExistence(timeout: 10)) | ||
|
||
let emailField = modal.textFields["Email"] | ||
XCTAssertTrue(emailField.waitForExistence(timeout: 10)) | ||
emailField.tap() | ||
emailField.typeText("mobile-payments-sdk-ci+\(UUID())@stripe.com") | ||
|
||
let phoneField = modal.otherElements["Mobile number"] | ||
XCTAssert(phoneField.waitForExistence(timeout: 10)) | ||
phoneField.tap() | ||
app.typeTextWithKeyboard("3105551234") | ||
|
||
// Terms and privacy policy | ||
for linkText in ["Terms", "Privacy Policy"] { | ||
modal.links[linkText].tap() | ||
let closeTermsButton = app.otherElements["TopBrowserBar"].buttons["Close"] | ||
XCTAssert(closeTermsButton.waitForExistence(timeout: 10)) | ||
closeTermsButton.tap() | ||
} | ||
|
||
modal.buttons["Join Link"].tap() | ||
|
||
// Because we are presenting view controllers with `modalPresentationStyle = .overFullScreen`, | ||
// there are currently 2 card forms on screen. Specifying a container helps the `fillCardData()` | ||
// method operate on the correct card form. | ||
try fillCardData(app, container: modal) | ||
|
||
// Pay! | ||
let payButton = modal.buttons["Pay $50.99"] | ||
expectation(for: NSPredicate(format: "enabled == true"), evaluatedWith: payButton, handler: nil) | ||
waitForExpectations(timeout: 10, handler: nil) | ||
payButton.tap() | ||
|
||
let successText = app.alerts.staticTexts["Success!"] | ||
XCTAssertTrue(successText.waitForExistence(timeout: 10)) | ||
|
||
let okButton = app.alerts.buttons["OK"] | ||
okButton.tap() | ||
} | ||
|
||
func testLinkSignIn() throws { | ||
loadPlayground(app, settings: [ | ||
"customer_mode": "new", | ||
"automatic_payment_methods": "off", | ||
"link": "on" | ||
]) | ||
|
||
app.buttons["Checkout (Complete)"].tap() | ||
|
||
let payWithLinkButton = app.buttons["Pay with Link"] | ||
XCTAssertTrue(payWithLinkButton.waitForExistence(timeout: 10)) | ||
payWithLinkButton.tap() | ||
|
||
let modal = app.otherElements["Stripe.Link.PayWithLinkViewController"] | ||
XCTAssertTrue(modal.waitForExistence(timeout: 10)) | ||
|
||
let emailField = modal.textFields["Email"] | ||
XCTAssertTrue(emailField.waitForExistence(timeout: 10)) | ||
emailField.tap() | ||
emailField.typeText("[email protected]") | ||
|
||
// Wait for OTP screen and enter the code | ||
let codeField = app.descendants(matching: .any)["Code field"] | ||
XCTAssert(codeField.waitForExistence(timeout: 10)) | ||
codeField.tap() | ||
app.typeTextWithKeyboard("000000") | ||
|
||
"000000".forEach { digit in | ||
app.keys[String(digit)].tap() | ||
let paymentMethodPicker = app.otherElements["Stripe.Link.PaymentMethodPicker"] | ||
if paymentMethodPicker.waitForExistence(timeout: 10) { | ||
paymentMethodPicker.tap() | ||
paymentMethodPicker.buttons["Add new payment method"].tap() | ||
} | ||
|
||
try fillCardData(app, container: modal) | ||
|
||
// Pay! | ||
let payButton = modal.buttons["Pay $50.99"] | ||
expectation(for: NSPredicate(format: "enabled == true"), evaluatedWith: payButton, handler: nil) | ||
waitForExpectations(timeout: 10, handler: nil) | ||
payButton.tap() | ||
|
||
let successText = app.alerts.staticTexts["Success!"] | ||
XCTAssertTrue(successText.waitForExistence(timeout: 10)) | ||
|
||
|
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
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
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