diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj
index fd4f8e69..8e8611a9 100644
--- a/Tusker.xcodeproj/project.pbxproj
+++ b/Tusker.xcodeproj/project.pbxproj
@@ -2147,7 +2147,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.4;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
@@ -2203,7 +2203,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.4;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
diff --git a/Tusker.xcodeproj/xcshareddata/xcschemes/Tusker.xcscheme b/Tusker.xcodeproj/xcshareddata/xcschemes/Tusker.xcscheme
index 68917e5e..bfc43462 100644
--- a/Tusker.xcodeproj/xcshareddata/xcschemes/Tusker.xcscheme
+++ b/Tusker.xcodeproj/xcshareddata/xcschemes/Tusker.xcscheme
@@ -27,15 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
-
-
-
-
diff --git a/Tusker/LocalData.swift b/Tusker/LocalData.swift
index 5c9f51e0..9d985161 100644
--- a/Tusker/LocalData.swift
+++ b/Tusker/LocalData.swift
@@ -18,6 +18,7 @@ class LocalData: ObservableObject {
private init() {
if ProcessInfo.processInfo.environment.keys.contains("UI_TESTING") {
defaults = UserDefaults(suiteName: "\(Bundle.main.bundleIdentifier!).uitesting")!
+ defaults.removePersistentDomain(forName: "\(Bundle.main.bundleIdentifier!).uitesting")
if ProcessInfo.processInfo.environment.keys.contains("UI_TESTING_LOGIN") {
accounts = [
UserAccountInfo(
diff --git a/Tusker/Views/Profile Header/ProfileHeaderView.xib b/Tusker/Views/Profile Header/ProfileHeaderView.xib
index ec1ed427..9f388373 100644
--- a/Tusker/Views/Profile Header/ProfileHeaderView.xib
+++ b/Tusker/Views/Profile Header/ProfileHeaderView.xib
@@ -1,9 +1,9 @@
-
+
-
+
@@ -48,7 +48,7 @@
-
+
diff --git a/TuskerUITests/API Mocks/APIMocks.swift b/TuskerUITests/API Mocks/APIMocks.swift
index 3fa5084c..7a577385 100644
--- a/TuskerUITests/API Mocks/APIMocks.swift
+++ b/TuskerUITests/API Mocks/APIMocks.swift
@@ -54,9 +54,8 @@ extension Router {
]
self["/api/v1/accounts/verify_credentials"] = JSONResponse(result: selfAccount)
self["/api/v1/accounts/\\d+/statuses"] = JSONResponse(result: [])
- self["/api/v1/accounts/(\\d+)"] = DelegatingResponse { (env) in
- let captures = env["ambassador.router_captures"] as! [String]
- if captures[0] == "1" {
+ self["/api/v1/accounts/(\\d+)"] = DelegatingResponse { (ctx) in
+ if ctx.captures[0] == "1" {
return JSONResponse(result: selfAccount)
} else {
return JSONResponse(statusCode: 404, statusMessage: "Not Found", result: notFound)
diff --git a/TuskerUITests/API Mocks/DelegatingResponse.swift b/TuskerUITests/API Mocks/DelegatingResponse.swift
index 87fe0e6e..4664ce8a 100644
--- a/TuskerUITests/API Mocks/DelegatingResponse.swift
+++ b/TuskerUITests/API Mocks/DelegatingResponse.swift
@@ -10,9 +10,20 @@ import Foundation
import Ambassador
struct DelegatingResponse: WebApp {
- let handler: (_ environ: [String: Any]) -> WebApp
+ let handler: (_ ctx: Context) -> WebApp
func app(_ environ: [String : Any], startResponse: @escaping ((String, [(String, String)]) -> Void), sendBody: @escaping ((Data) -> Void)) {
- handler(environ).app(environ, startResponse: startResponse, sendBody: sendBody)
+ let ctx = Context(environ: environ)
+ handler(ctx).app(environ, startResponse: startResponse, sendBody: sendBody)
+ }
+}
+
+extension DelegatingResponse {
+ struct Context {
+ let environ: [String: Any]
+
+ var captures: [String] {
+ environ["ambassador.router_captures"] as? [String] ?? []
+ }
}
}
diff --git a/TuskerUITests/MyProfileTests.swift b/TuskerUITests/MyProfileTests.swift
index 585e3d2d..a46a1612 100644
--- a/TuskerUITests/MyProfileTests.swift
+++ b/TuskerUITests/MyProfileTests.swift
@@ -18,9 +18,56 @@ class MyProfileTests: TuskerUITests {
app.launchEnvironment["UI_TESTING_LOGIN"] = "true"
app.launch()
}
-
- func testExample() {
- sleep(10000000)
+
+ func testProfileHeader() {
+ app.tabBars.buttons["My Profile"].tap()
+
+ XCTAssertTrue(app.staticTexts["Admin Account"].exists)
+ XCTAssertTrue(app.staticTexts["@admin"].exists)
+ XCTAssertTrue(app.staticTexts["My profile description."].exists)
+
+ let segmented = app.segmentedControls.firstMatch
+ XCTAssertTrue(segmented.exists)
+ XCTAssertEqual(segmented.buttons.count, 3)
+ XCTAssertTrue(segmented.buttons["Posts"].exists)
+ XCTAssertTrue(segmented.buttons["Posts and Replies"].exists)
+ XCTAssertTrue(segmented.buttons["Media"].exists)
+
+ XCTAssertTrue(app.buttons["More Actions"].exists)
+
+ app.buttons["More Actions"].tap()
+ if #available(iOS 14.0, *) {
+ XCTAssertTrue(app.buttons["Open in Safari"].exists)
+ XCTAssertTrue(app.buttons["Share..."].exists)
+ XCTAssertTrue(app.buttons["Send Message"].exists)
+
+ app.buttons["Open in Safari"].tap()
+ XCTAssertTrue(app.otherElements["TopBrowserBar"].exists)
+ app.buttons["Done"].tap()
+ XCTAssertFalse(app.otherElements["TopBrowserBar"].exists)
+
+ app.buttons["More Actions"].tap()
+ app.buttons["Share..."].tap()
+ let activityListView = app.otherElements["ActivityListView"]
+ XCTAssertTrue(activityListView.waitForExistence(timeout: 0.2))
+ activityListView.buttons["Close"].tap()
+ XCTAssertFalse(activityListView.exists)
+
+ app.buttons["More Actions"].tap()
+ app.buttons["Send Message"].tap()
+ XCTAssertTrue(app.staticTexts["Compose"].exists)
+ XCTAssertTrue(app.buttons["Cancel"].exists)
+ XCTAssertTrue(app.buttons["Post"].exists)
+ app.buttons["Cancel"].tap()
+ } else {
+ // first tap doesn't trigger share sheet for some reason
+ app.buttons["More Actions"].tap()
+ let activityListView = app.otherElements["ActivityListView"]
+ XCTAssertTrue(activityListView.waitForExistence(timeout: 0.2))
+ activityListView.buttons["Close"].tap()
+ XCTAssertFalse(activityListView.exists)
+ // can't test individual actions :/
+ }
}
}
diff --git a/TuskerUITests/OnboardingTests.swift b/TuskerUITests/OnboardingTests.swift
index cf54c578..d3f14104 100644
--- a/TuskerUITests/OnboardingTests.swift
+++ b/TuskerUITests/OnboardingTests.swift
@@ -21,11 +21,22 @@ class OnboardingTests: TuskerUITests {
// can't test logging in because there's no way of interacting with the safari VC that's used in the OAuth flow
+ func testSearchSuggestedInstances() {
+ XCTAssertTrue(app.cells.firstMatch.waitForExistence(timeout: 2))
+ let firstInstanceLabel = app.cells.staticTexts.firstMatch.label
+ let secondInstanceLabel = app.cells.element(boundBy: 1).staticTexts.firstMatch.label
+ let searchField = app.searchFields.element
+ searchField.tap()
+ searchField.typeText(firstInstanceLabel)
+ XCTAssertTrue(app.staticTexts[firstInstanceLabel].exists)
+ XCTAssertFalse(app.staticTexts[secondInstanceLabel].exists)
+ }
+
func testCustomInstanceAppears() {
let searchField = app.searchFields.element
searchField.tap()
searchField.typeText("http://localhost:8080")
- XCTAssertTrue(app.staticTexts["localhost"].exists)
+ XCTAssertTrue(app.staticTexts["localhost"].waitForExistence(timeout: 2))
XCTAssertTrue(app.staticTexts["An instance description"].exists)
}