Skip to content
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

Remove extra space from UITest TransferMethod folder #19

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions HyperwalletUISDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,15 @@
path = Responses;
sourceTree = "<group>";
};
C358A9A12272644000E5AE47 /* TransferMethod */ = {
C358A9A12272644000E5AE47 /* TransferMethod */ = {
isa = PBXGroup;
children = (
C358A9A22272644000E5AE47 /* AddTransferMethod.swift */,
C358A9A32272644000E5AE47 /* ListTransferMethods.swift */,
C358A9A42272644000E5AE47 /* SelectTransferMethodType.swift */,
C38DC07822727F9300B1F00E /* SelectTransferMethodCountryType.swift */,
);
path = "TransferMethod ";
path = TransferMethod;
sourceTree = "<group>";
};
C358A9A8227265C300E5AE47 /* TransferMethod */ = {
Expand Down Expand Up @@ -475,7 +475,7 @@
DBB2B6F52261C13F006C48D3 /* Helper */ = {
isa = PBXGroup;
children = (
C358A9A12272644000E5AE47 /* TransferMethod */,
C358A9A12272644000E5AE47 /* TransferMethod */,
DBB2B6FA2261C140006C48D3 /* HyperwalletMockWebServer.swift */,
);
path = Helper;
Expand Down
102 changes: 102 additions & 0 deletions UITests/Helper/TransferMethod/AddTransferMethod.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import XCTest

enum AccountType: String {
case bankAccount = "Bank Account"
case debitCard = "Debit Card"
case payPalAccount = "PayPal"
}

class AddTransferMethod {
let defaultTimeout = 5.0

var app: XCUIApplication

var addTMTableView: XCUIElement
var branchIdInput: XCUIElement
var accountNumberInput: XCUIElement
var accountTypeSelect: XCUIElement
var createTransferMethodButton: XCUIElement
var cardNumberInput: XCUIElement
var cvvInput: XCUIElement
var dateOfExpiryInput: XCUIElement
var emailInput: XCUIElement
var title: XCUIElement
var navigationBar: XCUIElement

init(app: XCUIApplication, for accountType: AccountType) {
self.app = app

addTMTableView = app.tables["addTransferMethodTable"]
branchIdInput = addTMTableView.textFields["branchId"]
accountNumberInput = addTMTableView.textFields["bankAccountId"]
accountTypeSelect = addTMTableView.cells.staticTexts["Account Type"]
createTransferMethodButton = addTMTableView.cells.containing(.button,
identifier: "createAccountBtn")
.buttons["createAccountBtn"]
cardNumberInput = addTMTableView.textFields["cardNumber"]
dateOfExpiryInput = addTMTableView.textFields["dateOfExpiry"]
cvvInput = addTMTableView.textFields["cvv"]
emailInput = addTMTableView.textFields["email"]
title = addTMTableView.staticTexts["Account Information - United States (USD)"]
navigationBar = app.navigationBars[accountType.rawValue]
}

func setBranchId(branchId: String) {
branchIdInput.tap()
app.typeText(branchId)

title.tap()
}

func setAccountNumber(accountNumber: String) {
accountNumberInput.tap()
app.typeText(accountNumber)
title.tap()
}

func selectAccountType(accountType: String) {
accountTypeSelect.tap()
app.tables.staticTexts[accountType].tap()
}

func clickCreateTransferMethodButton() {
createTransferMethodButton.tap()
}

func setCardNumber(cardNumber: String) {
cardNumberInput.tap()
app.typeText(cardNumber)
title.tap()
}

func setDateOfExpiry(expiryMonth: String, expiryYear: String) {
dateOfExpiryInput.tap()

// Supporting multiple localizations for month and year
let dateComponent = Calendar.current.dateComponents([.month, .year], from: Date())
let formatter = DateFormatter()
formatter.dateFormat = "MMMM"
let monthText = formatter.string(from: Date())

// Selecting year and month from PickerWheel
app.pickerWheels[String(dateComponent.year!)].adjust(toPickerWheelValue: expiryYear)
app.pickerWheels[monthText].adjust(toPickerWheelValue: expiryMonth)
app.toolbars.buttons["Done"].tap()
}

func clickBackButton() {
navigationBar.children(matching: .button).matching(identifier: "Back").element(boundBy: 0).tap()
}

func setCvv(cvvNumber: String) {
cvvInput.tap()
app.typeText(cvvNumber)
title.tap()
}

func setEmail(email: String) {
emailInput.tap()
app.typeText(email)
title.tap()
}
}
49 changes: 49 additions & 0 deletions UITests/Helper/TransferMethod/ListTransferMethods.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import XCTest

class ListTransferMethod {
let defaultTimeout = 5.0

var app: XCUIApplication

var addTransferMethodButton: XCUIElement
var addTransferMethodEmptyScreenButton: XCUIElement
var removeAccountButton: XCUIElement
var confirmAccountRemoveButton: XCUIElement
var cancelAccountRemoveButton: XCUIElement
var navigationBar: XCUIElement

init(app: XCUIApplication) {
self.app = app

addTransferMethodButton = app.navigationBars.buttons["Add"]
addTransferMethodEmptyScreenButton = app.buttons["Add Account"]
removeAccountButton = app.buttons["Remove Account"]
confirmAccountRemoveButton = app.alerts["Remove Account"].buttons["Remove"]
cancelAccountRemoveButton = app.alerts["Remove Account"].buttons["Cancel"]
navigationBar = app.navigationBars["Accounts"]
}

func tapAddTransferMethodButton() {
addTransferMethodButton.tap()
}

func tapAddTransferMethodEmptyScreenButton() {
addTransferMethodEmptyScreenButton.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
}

func tapRemoveAccountButton() {
removeAccountButton.tap()
}

func tapConfirmAccountRemoveButton() {
confirmAccountRemoveButton.tap()
}

func tapCancelAccountRemoveButton() {
cancelAccountRemoveButton.tap()
}

func clickBackButton() {
navigationBar.children(matching: .button).matching(identifier: "Back").element(boundBy: 0).tap()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import XCTest

class SelectTransferMethodCountryType {
var app: XCUIApplication
var countryTable: XCUIElement
var navigationBar: XCUIElement

init(app: XCUIApplication) {
self.app = app

countryTable = app.otherElements.containing(.navigationBar, identifier: "Select Country").element
navigationBar = app.navigationBars["Select Country"]
}

func clickBackButton() {
navigationBar.children(matching: .button).matching(identifier: "Back").element(boundBy: 0).tap()
}
}
54 changes: 54 additions & 0 deletions UITests/Helper/TransferMethod/SelectTransferMethodType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import XCTest

class SelectTransferMethodType {
let defaultTimeout = 5.0

var app: XCUIApplication

var countrySelect: XCUIElement
var currencySelect: XCUIElement
var countryTable: XCUIElement
var currencyTable: XCUIElement
var searchBar: XCUIElement
var navigationBar: XCUIElement

init(app: XCUIApplication) {
self.app = app

countrySelect = app.tables.cells["cellCountry"].staticTexts["Country"]
currencySelect = app.tables.cells["cellCurrency"].staticTexts["Currency"]
countryTable = app.otherElements.containing(.navigationBar, identifier: "Select Country").element
currencyTable = app.otherElements.containing(.navigationBar, identifier: "Select Currency").element
searchBar = app.searchFields["Search"]
navigationBar = app.navigationBars["Add Account"]
}

func tapCountry() {
countrySelect.tap()
_ = countryTable.waitForExistence(timeout: defaultTimeout)
}

func tapCurrency() {
currencySelect.tap()
_ = currencyTable.waitForExistence(timeout: defaultTimeout)
}

func selectCountry(country: String) {
tapCountry()
app.tables.staticTexts[country].tap()
}

func selectCurrency(currency: String) {
tapCurrency()
app.tables.staticTexts[currency].tap()
}

func typeSearch(input: String) {
searchBar.tap()
app.typeText(input)
}

func clickBackButton() {
navigationBar.children(matching: .button).matching(identifier: "Back").element(boundBy: 0).tap()
}
}