More UI tests for onboarding/my profile

This commit is contained in:
Shadowfacts 2020-09-12 22:15:45 -04:00
parent 8ac3deb55a
commit acd01a81cc
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
8 changed files with 83 additions and 23 deletions

View File

@ -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;

View File

@ -27,15 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D6D4DDCB212518A000E1C4BB"
BuildableName = "Tusker.app"
BlueprintName = "Tusker"
ReferencedContainer = "container:Tusker.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">

View File

@ -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(

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17147" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17120"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17124"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@ -48,7 +48,7 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bRJ-Xf-kc9" customClass="VisualEffectImageButton" customModule="Tusker" customModuleProvider="target">
<rect key="frame" x="374" y="154" width="32" height="32"/>
<viewLayoutGuide key="safeArea" id="kQa-ou-pQz"/>
<accessibility key="accessibilityConfiguration">
<accessibility key="accessibilityConfiguration" label="More Actions">
<accessibilityTraits key="traits" button="YES"/>
</accessibility>
<constraints>

View File

@ -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)

View File

@ -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] ?? []
}
}
}

View File

@ -19,8 +19,55 @@ class MyProfileTests: TuskerUITests {
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 :/
}
}
}

View File

@ -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)
}