Skip to content

Commit

Permalink
Streamline 3DS UI Tests (#1466)
Browse files Browse the repository at this point in the history
  • Loading branch information
scannillo authored Nov 21, 2024
1 parent 3d4a3d3 commit 8941506
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,18 @@ internal extension XCUIApplication {
return buttons["Tokenize and Verify New Card"]
}

var webViewPasswordTextField: XCUIElement {
return webViews.element.otherElements.children(matching: .other).children(matching: .secureTextField).element
}

var webViewSubmitButton: XCUIElement {
return webViews.element.otherElements.children(matching: .other).children(matching: .other).buttons["Submit"]
}

var cardinalSubmitButton: XCUIElement {
return buttons["SUBMIT"]
}

var liabilityShiftedMessage: XCUIElement {
return buttons["Liability shift possible and liability shifted"]
}

var authenticationFailedMessage: XCUIElement {
return buttons["Failed to authenticate, please try a different form of payment."]
}


var liabilityCouldNotBeShiftedMessage: XCUIElement {
return buttons["3D Secure authentication was attempted but liability shift is not possible"]
}

var unexpectedErrorMessage: XCUIElement {
return buttons["An unexpected error occurred"]
}

var internalErrorMessage: XCUIElement {
return buttons["Internal Error."]
}

func enterCardDetailsWith(cardNumber: String, expirationDate: String = UITestDateGenerator.sharedInstance.futureDate()) {
cardNumberTextField.tap()
cardNumberTextField.typeText(cardNumber)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ class ThreeDSecure_V2_UITests: XCTestCase {
app.launch()
}

func testThreeDSecurePaymentFlowV2_frictionlessFlow_andTransacts() {
waitForElementToAppear(app.cardNumberTextField)
app.enterCardDetailsWith(cardNumber: "4000000000001000", expirationDate: expirationDate)
app.tokenizeButton.tap()
sleep(2)

waitForElementToAppear(app.liabilityShiftedMessage)
}

func testThreeDSecurePaymentFlowV2_challengeFlow_andTransacts() {
waitForElementToAppear(app.cardNumberTextField)
app.enterCardDetailsWith(cardNumber: "4000000000001091", expirationDate: expirationDate)
Expand All @@ -44,16 +35,7 @@ class ThreeDSecure_V2_UITests: XCTestCase {

waitForElementToAppear(app.liabilityShiftedMessage)
}

func testThreeDSecurePaymentFlowV2_noChallenge_andFails() {
waitForElementToAppear(app.cardNumberTextField)
app.enterCardDetailsWith(cardNumber: "5200000000001013", expirationDate: expirationDate)
app.tokenizeButton.tap()
sleep(2)

waitForElementToAppear(app.liabilityCouldNotBeShiftedMessage)
}


func testThreeDSecurePaymentFlowV2_challengeFlow_andFails() {
waitForElementToAppear(app.cardNumberTextField)
app.enterCardDetailsWith(cardNumber: "4000000000001109", expirationDate: expirationDate)
Expand All @@ -74,26 +56,6 @@ class ThreeDSecure_V2_UITests: XCTestCase {
waitForElementToAppear(app.liabilityCouldNotBeShiftedMessage, timeout: 30)
}

func testThreeDSecurePaymentFlowV2_acceptsPassword_failsToAuthenticateNonce_dueToCardinalError() {
waitForElementToAppear(app.cardNumberTextField)
app.enterCardDetailsWith(cardNumber: "4000000000001125")
app.tokenizeButton.tap()
sleep(2)

waitForElementToAppear(app.staticTexts["Purchase Authentication"], timeout: .threeDSecureTimeout)

let textField = app.textFields.element(boundBy: 0)
waitForElementToBeHittable(textField)
textField.forceTapElement()
sleep(2)
textField.typeText("1234")

app.cardinalSubmitButton.forceTapElement()
sleep(2)

waitForElementToAppear(app.internalErrorMessage, timeout: 30)
}

func testThreeDSecurePaymentFlowV2_returnsToApp_whenCancelTapped() {
waitForElementToAppear(app.cardNumberTextField)
app.enterCardDetailsWith(cardNumber: "4000000000001091")
Expand All @@ -106,31 +68,4 @@ class ThreeDSecure_V2_UITests: XCTestCase {

waitForElementToAppear(app.buttons["Canceled 🎲"])
}

func testThreeDSecurePaymentFlowV2_bypassedAuthentication() {
waitForElementToAppear(app.cardNumberTextField)
app.enterCardDetailsWith(cardNumber: "4000000000001083")
app.tokenizeButton.tap()
sleep(2)

waitForElementToAppear(app.liabilityCouldNotBeShiftedMessage)
}

func testThreeDSecurePaymentFlowV2_lookupError() {
waitForElementToAppear(app.cardNumberTextField)
app.enterCardDetailsWith(cardNumber: "4000000000001034")
app.tokenizeButton.tap()
sleep(2)

waitForElementToAppear(app.liabilityCouldNotBeShiftedMessage)
}

func testThreeDSecurePaymentFlowV2_timeout() {
waitForElementToAppear(app.cardNumberTextField)
app.enterCardDetailsWith(cardNumber: "4000000000001075")
app.tokenizeButton.tap()
sleep(2)

waitForElementToAppear(app.liabilityCouldNotBeShiftedMessage, timeout: 45)
}
}

0 comments on commit 8941506

Please sign in to comment.