|
|
@ -45,42 +45,13 @@ class PreferencesTest: XCTestCase { |
|
|
|
|
|
|
|
|
|
|
|
addAPlace(place: "UTC", to: app) |
|
|
|
addAPlace(place: "UTC", to: app) |
|
|
|
|
|
|
|
|
|
|
|
let matchPredicate = NSPredicate(format: "value == %@", "UTC") |
|
|
|
let matchPredicate = NSPredicate(format: "value contains %@", "UTC") |
|
|
|
let matchingFields = app.tables["TimezoneTableView"].textFields.matching(matchPredicate) |
|
|
|
let matchingFields = app.tables["TimezoneTableView"].textFields.matching(matchPredicate) |
|
|
|
XCTAssertTrue(matchingFields.count > 0, "Matching Fields count was zero") |
|
|
|
XCTAssertTrue(matchingFields.count > 0, "Matching Fields count was zero") |
|
|
|
|
|
|
|
|
|
|
|
deleteAPlace(place: "UTC", for: app) |
|
|
|
deleteAPlace(place: "UTC", for: app) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func testEditingLabel() { |
|
|
|
|
|
|
|
let placeToAdd = "Auckland" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.tapMenubarIcon() |
|
|
|
|
|
|
|
app.tables["mainTableView"].typeKey(",", modifierFlags: .command) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if app.sheets.count == 0 { |
|
|
|
|
|
|
|
app.windows["Clocker"].checkBoxes["AddTimezone"].click() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addAPlace(place: placeToAdd, to: app) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let matchPredicate = NSPredicate(format: "value == %@", placeToAdd) |
|
|
|
|
|
|
|
let matchingFields = app.windows["Clocker"].textFields.matching(matchPredicate) |
|
|
|
|
|
|
|
XCTAssertTrue(matchingFields.count > 1, "Matching Fields count was zero") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
matchingFields.element(boundBy: 1).doubleClick() |
|
|
|
|
|
|
|
matchingFields.element(boundBy: 1).typeText("NZ") |
|
|
|
|
|
|
|
app.typeKey(XCUIKeyboardKey.return, modifierFlags: []) |
|
|
|
|
|
|
|
app.tapMenubarIcon() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let labelPredicate = NSPredicate(format: "label == %@", "NZ") |
|
|
|
|
|
|
|
let cells = app.tables["mainTableView"].cells.matching(labelPredicate) |
|
|
|
|
|
|
|
XCTAssert(cells.count > 0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.tables["mainTableView"].typeKey(",", modifierFlags: .command) |
|
|
|
|
|
|
|
deleteAPlace(place: placeToAdd, for: app) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func testSortingByTimezoneDifference() { |
|
|
|
func testSortingByTimezoneDifference() { |
|
|
|
app.tapMenubarIcon() |
|
|
|
app.tapMenubarIcon() |
|
|
|
app.tables["mainTableView"].typeKey(",", modifierFlags: .command) |
|
|
|
app.tables["mainTableView"].typeKey(",", modifierFlags: .command) |
|
|
@ -341,3 +312,79 @@ extension XCUIApplication { |
|
|
|
statusItems.firstMatch.click() |
|
|
|
statusItems.firstMatch.click() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extension XCTestCase { |
|
|
|
|
|
|
|
func inverseWaiterFor(element: XCUIElement, time: TimeInterval = 25) { |
|
|
|
|
|
|
|
let spinnerPredicate = NSPredicate(format: "exists == false") |
|
|
|
|
|
|
|
let spinnerExpectation = expectation(for: spinnerPredicate, evaluatedWith: element, handler: nil) |
|
|
|
|
|
|
|
let spinnerResult = XCTWaiter().wait(for: [spinnerExpectation], timeout: time) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if spinnerResult != .completed { |
|
|
|
|
|
|
|
XCTFail("Still seeing Spinner after 25 seconds. Something's wrong") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func addAPlace(place: String, to app: XCUIApplication, shouldSleep: Bool = true) { |
|
|
|
|
|
|
|
// Let's first check if the place is already present in the list |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let matchPredicate = NSPredicate(format: "value contains %@", place) |
|
|
|
|
|
|
|
let matchingFields = app.windows["Clocker"].tables["TimezoneTableView"].textFields.matching(matchPredicate) |
|
|
|
|
|
|
|
if matchingFields.count > 0 { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if app.sheets.count == 0 { |
|
|
|
|
|
|
|
app.windows["Clocker"].checkBoxes["AddTimezone"].click() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let searchField = app.searchFields["AvailableSearchField"] |
|
|
|
|
|
|
|
searchField.reset(text: place) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let results = app.tables["AvailableTimezoneTableView"].cells.staticTexts.matching(matchPredicate) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let waiter = XCTWaiter() |
|
|
|
|
|
|
|
let isHittable = NSPredicate(format: "exists == true", "") |
|
|
|
|
|
|
|
let addExpectation = expectation(for: isHittable, |
|
|
|
|
|
|
|
evaluatedWith: results.firstMatch) { () -> Bool in |
|
|
|
|
|
|
|
print("Handler called") |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
waiter.wait(for: [addExpectation], timeout: 5) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if results.count > 0 { |
|
|
|
|
|
|
|
results.firstMatch.click() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.buttons["AddAvailableTimezone"].click() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if shouldSleep { |
|
|
|
|
|
|
|
sleep(2) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func deleteAllPlaces(app: XCUIApplication) { |
|
|
|
|
|
|
|
var rowQueryCount = app.windows["Clocker"].tables["TimezoneTableView"].tableRows.count |
|
|
|
|
|
|
|
if rowQueryCount == 0 { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let currentElement = app.windows["Clocker"].tableRows.firstMatch |
|
|
|
|
|
|
|
currentElement.click() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while rowQueryCount > 0 { |
|
|
|
|
|
|
|
app.windows["Clocker"].typeKey(XCUIKeyboardKey.delete, modifierFlags: XCUIElement.KeyModifierFlags()) |
|
|
|
|
|
|
|
rowQueryCount -= 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func deleteAPlace(place: String, for app: XCUIApplication, shouldSleep: Bool = true) { |
|
|
|
|
|
|
|
let matchPredicate = NSPredicate(format: "value contains %@", place) |
|
|
|
|
|
|
|
let row = app.tables["TimezoneTableView"].textFields.matching(matchPredicate).firstMatch |
|
|
|
|
|
|
|
row.click() |
|
|
|
|
|
|
|
row.typeKey(XCUIKeyboardKey.delete, modifierFlags: XCUIElement.KeyModifierFlags()) |
|
|
|
|
|
|
|
if shouldSleep { |
|
|
|
|
|
|
|
sleep(2) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|