Skip to content

Commit

Permalink
Update Venmo UI tests to include new ECD options button
Browse files Browse the repository at this point in the history
Signed-off-by: Jax DesMarais-Leder <[email protected]>
  • Loading branch information
scannillo authored and jaxdesmarais committed Aug 1, 2023
1 parent 975f755 commit 4041d3e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BraintreeDemoVenmoViewController: BraintreeDemoPaymentButtonBaseViewContro
venmoButton.translatesAutoresizingMaskIntoConstraints = false

let venmoECDButton = UIButton(type: .system)
venmoECDButton.setTitle("Venmo (with ECD enabled)", for: .normal)
venmoECDButton.setTitle("Venmo (with ECD options)", for: .normal)
venmoECDButton.setTitleColor(.blue, for: .normal)
venmoECDButton.setTitleColor(.lightGray, for: .highlighted)
venmoECDButton.setTitleColor(.lightGray, for: .disabled)
Expand Down
36 changes: 27 additions & 9 deletions Demo/UI Tests/Venmo UI Tests/Venmo_UITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,54 @@ class Venmo_UITests: XCTestCase {
demoApp.launchArguments.append("-ClientToken")
demoApp.launchArguments.append("-Integration:BraintreeDemoVenmoViewController")
demoApp.launch()

waitForElementToBeHittable(demoApp.buttons["Venmo (custom button)"])
demoApp.buttons["Venmo (custom button)"].tap()
waitForElementToBeHittable(demoApp.buttons["Venmo"])
waitForElementToBeHittable(demoApp.buttons["Venmo (with ECD options)"])
}

func testTokenizeVenmo_whenSignInSuccessfulWithPaymentContext_returnsNonce() {
demoApp.buttons["Venmo"].tap()

waitForElementToBeHittable(mockVenmo.buttons["SUCCESS WITH PAYMENT CONTEXT"])
mockVenmo.buttons["SUCCESS WITH PAYMENT CONTEXT"].tap()

XCTAssertTrue(demoApp.buttons["Got a nonce. Tap to make a transaction."].waitForExistence(timeout: 15))
}

func testTokenizeVenmo_withECDOptions_whenSignInSuccessfulWithPaymentContext_returnsNonce() {
demoApp.buttons["Venmo (with ECD options)"].tap()

waitForElementToBeHittable(mockVenmo.buttons["SUCCESS WITH PAYMENT CONTEXT"])
mockVenmo.buttons["SUCCESS WITH PAYMENT CONTEXT"].tap()

XCTAssertTrue(demoApp.buttons["Got a nonce. Tap to make a transaction."].waitForExistence(timeout: 15))
}

func testTokenizeVenmo_whenSignInSuccessfulWithoutPaymentContext_returnsNonce() {
demoApp.buttons["Venmo"].tap()

waitForElementToBeHittable(mockVenmo.buttons["SUCCESS WITHOUT PAYMENT CONTEXT"])
mockVenmo.buttons["SUCCESS WITHOUT PAYMENT CONTEXT"].tap()

XCTAssertTrue(demoApp.buttons["Got a nonce. Tap to make a transaction."].waitForExistence(timeout: 15))
}

func testTokenizeVenmo_whenErrorOccurs_returnsError() {
demoApp.buttons["Venmo"].tap()

waitForElementToBeHittable(mockVenmo.buttons["ERROR"])
mockVenmo.buttons["ERROR"].tap()

XCTAssertTrue(demoApp.buttons["An error occurred during the Venmo flow"].waitForExistence(timeout: 15))
}

func testTokenizeVenmo_whenUserCancels_returnsCancel() {
waitForElementToBeHittable(mockVenmo.buttons["Cancel"])
mockVenmo.buttons["Cancel"].tap()

XCTAssertTrue(demoApp.buttons["Canceled 🔰"].waitForExistence(timeout: 15))
}
// TODO: - Uncomment test once cancel case is handled as an error
// func testTokenizeVenmo_whenUserCancels_returnsCancel() {
// demoApp.buttons["Venmo"].tap()
//
// waitForElementToBeHittable(mockVenmo.buttons["Cancel"])
// mockVenmo.buttons["Cancel"].tap()
//
// XCTAssertTrue(demoApp.buttons["Canceled 🔰"].waitForExistence(timeout: 15))
// }
}

0 comments on commit 4041d3e

Please sign in to comment.