From 3084b2a7e8347d068a9370986687a2e3493ed87a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 14 Sep 2019 16:42:38 -0700 Subject: [PATCH] Tests + Version bump. --- Clocker/Clocker/Clocker-Info.plist | 4 +- Clocker/ClockerUITests/AboutUsTests.swift | 2 +- Clocker/ClockerUITests/PreferencesTest.swift | 49 ++++++++++++++++++-- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Clocker/Clocker/Clocker-Info.plist b/Clocker/Clocker/Clocker-Info.plist index f0b2b41..f5a7934 100755 --- a/Clocker/Clocker/Clocker-Info.plist +++ b/Clocker/Clocker/Clocker-Info.plist @@ -13,11 +13,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.6.14 + 1.6.15 CFBundleSignature ???? CFBundleVersion - 69 + 70 Fabric APIKey diff --git a/Clocker/ClockerUITests/AboutUsTests.swift b/Clocker/ClockerUITests/AboutUsTests.swift index d576647..d0ba955 100644 --- a/Clocker/ClockerUITests/AboutUsTests.swift +++ b/Clocker/ClockerUITests/AboutUsTests.swift @@ -32,7 +32,7 @@ class AboutUsTests: XCTestCase { tapAboutTab() - let expectedVersion = "Clocker 1.6.13 (68)" + let expectedVersion = "Clocker 1.6.15 (70)" guard let presentVersion = app.windows["Clocker"].staticTexts["ClockerVersion"].value as? String else { XCTFail("Present version not present") return diff --git a/Clocker/ClockerUITests/PreferencesTest.swift b/Clocker/ClockerUITests/PreferencesTest.swift index 63d50c7..eb95563 100644 --- a/Clocker/ClockerUITests/PreferencesTest.swift +++ b/Clocker/ClockerUITests/PreferencesTest.swift @@ -53,7 +53,7 @@ class PreferencesTest: XCTestCase { deleteAPlace(place: "UTC", for: app) } - func testSortingByTimezoneDifference() { + func testSortingCitiesByTimezoneDifference() { app.tapMenubarIcon() app.tables["mainTableView"].typeKey(",", modifierFlags: .command) @@ -95,10 +95,9 @@ class PreferencesTest: XCTestCase { addAPlace(place: "Mumbai", to: app) } - func testSortingByTimezoneName() { + func testSortingCitiesByTimezoneName() { app.tapMenubarIcon() app.tables["mainTableView"].typeKey(",", modifierFlags: .command) -// app.windows["Clocker"].checkBoxes["SortButton"].click() XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Time Difference"].exists) XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Label"].exists) @@ -138,7 +137,7 @@ class PreferencesTest: XCTestCase { XCTAssertFalse(app.windows["Clocker"].checkBoxes["Sort by Name"].exists) } - func testSortingByCustomLabel() { + func testSortingCitiesByCustomLabel() { app.tapMenubarIcon() app.tables["mainTableView"].typeKey(",", modifierFlags: .command) @@ -180,6 +179,48 @@ class PreferencesTest: XCTestCase { deleteAPlace(place: "Portland", for: app, shouldSleep: false) } + func testSortingTimezonesByCustomLabel() { + app.tapMenubarIcon() + app.tables["mainTableView"].typeKey(",", modifierFlags: .command) + + addAPlace(place: "Europe/Lisbon", to: app) + addAPlace(place: "Asia/Kolkata", to: app) + addAPlace(place: "Anywhere on Earth", to: app, shouldSleep: false) + + XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Label"].exists) + + var expectedLabels: [String] = [] + + let formattedAddressQuery = app.windows["Clocker"].textFields + + for elementIndex in 0 ..< formattedAddressQuery.count { + if let currentValue = formattedAddressQuery.element(boundBy: elementIndex).value as? String, elementIndex % 2 == 1 { + expectedLabels.append(currentValue) + } + } + + expectedLabels.sort() + + if let value = app.windows["Clocker"].checkBoxes["Sort by Label"].value as? Int, value == 0 { + app.windows["Clocker"].checkBoxes["Sort by Label"].click() + } + + var actualLabels: [String] = [] + let newFormattedAddressQuery = app.windows["Clocker"].textFields + + for elementIndex in 0 ..< newFormattedAddressQuery.count { + if let currentValue = newFormattedAddressQuery.element(boundBy: elementIndex).value as? String, elementIndex % 2 == 1 { + actualLabels.append(currentValue) + } + } + + XCTAssertEqual(actualLabels, expectedLabels) + + deleteAPlace(place: "Europe/Lisbon", for: app) + deleteAPlace(place: "Asia/Kolkata", for: app) + deleteAPlace(place: "Anywhere on Earth", for: app, shouldSleep: false) + } + func testSearchingWithMisspelledName() { app.tapMenubarIcon() app.tables["mainTableView"].typeKey(",", modifierFlags: .command)