1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import XCTest
final class OldFellaUITests: XCTestCase {
func testTabIconsKeepAccessibleNames() throws {
try XCTSkipIf(UIDevice.current.userInterfaceIdiom == .pad, "Requires the iPhone tab layout")
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
let tabs = app.tabBars.firstMatch
for name in ["Timeline", "Notifications", "Search", "Saved Posts", "New post"] {
XCTAssertTrue(tabs.buttons[name].waitForExistence(timeout: 10))
}
let screenshot = XCTAttachment(screenshot: app.screenshot())
screenshot.name = "Tab bar"
screenshot.lifetime = .keepAlways
add(screenshot)
tabs.buttons["Saved Posts"].tap()
XCTAssertTrue(app.navigationBars["Saved Posts"].waitForExistence(timeout: 5))
tabs.buttons["Timeline"].tap()
XCTAssertTrue(app.navigationBars["Following"].waitForExistence(timeout: 5))
}
func testFontSettingPersists() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.openSettings()
let picker = app.buttons["appFont"]
if !picker.isHittable { app.swipeUp() }
XCTAssertTrue(picker.waitForExistence(timeout: 5))
let description = app.staticTexts["distractionsDescription"]
XCTAssertTrue(description.waitForExistence(timeout: 5))
let systemHeight = description.frame.height
picker.tap()
let atkinson = app.buttons["Atkinson Hyperlegible Next"]
XCTAssertTrue(atkinson.waitForExistence(timeout: 5))
atkinson.tap()
XCTAssertLessThan(description.frame.height, systemHeight * 1.4)
picker.tap()
let choice = app.buttons["Paper Mono"]
XCTAssertTrue(choice.waitForExistence(timeout: 5))
choice.tap()
XCTAssertLessThan(description.frame.height, systemHeight * 1.4)
XCTAssertTrue(picker.waitForExistence(timeout: 5))
XCTAssertTrue(picker.label.contains("Paper Mono") || (picker.value as? String) == "Paper Mono")
app.terminate()
app.launchArguments.append("-ui-testing-preserve-defaults")
app.launch()
app.openSettings()
if !picker.isHittable { app.swipeUp() }
XCTAssertTrue(picker.waitForExistence(timeout: 5))
XCTAssertTrue(picker.label.contains("Paper Mono") || (picker.value as? String) == "Paper Mono")
}
func testHiddenPicturesOpenImageViewerDirectly() throws {
try XCTSkipIf(UIDevice.current.userInterfaceIdiom == .pad, "Requires the iPhone tab layout")
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-image-grid", "3"]
app.launch()
app.openSettings()
let setting = app.switches["showPictures"]
XCTAssertTrue(setting.waitForExistence(timeout: 5))
XCTAssertEqual(setting.value as? String, "1")
setting.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
XCTAssertEqual(setting.value as? String, "0")
app.closeSettings()
let row = app.cells.containing(.button, identifier: "postText-post-1").firstMatch
let first = row.buttons["showImageButton-1"]
XCTAssertTrue(first.waitForExistence(timeout: 5))
XCTAssertTrue(row.buttons["showImageButton-2"].exists)
XCTAssertTrue(row.buttons["showImageButton-3"].exists)
XCTAssertFalse(row.descendants(matching: .any)["postImageTile-1"].firstMatch.exists)
XCTAssertFalse(row.descendants(matching: .any)["postImageTile-2"].firstMatch.exists)
first.tap()
let close = app.buttons["imageViewerClose"]
XCTAssertTrue(close.waitForExistence(timeout: 5))
XCTAssertTrue(app.images["Image 1 of 3"].firstMatch.waitForExistence(timeout: 5))
close.tap()
XCTAssertTrue(first.waitForExistence(timeout: 5))
XCTAssertFalse(row.descendants(matching: .any)["postImageTile-1"].firstMatch.exists)
row.buttons["showImageButton-2"].tap()
XCTAssertTrue(close.waitForExistence(timeout: 5))
XCTAssertTrue(app.images["Image 2 of 3"].firstMatch.waitForExistence(timeout: 5))
close.tap()
XCTAssertTrue(first.waitForExistence(timeout: 5))
XCTAssertTrue(row.buttons["showImageButton-2"].exists)
XCTAssertTrue(row.buttons["showImageButton-3"].exists)
app.terminate()
app.launchArguments.append("-ui-testing-preserve-defaults")
app.launch()
XCTAssertTrue(first.waitForExistence(timeout: 10))
XCTAssertFalse(row.descendants(matching: .any)["postImageTile-1"].firstMatch.exists)
}
func testDisplayPreferencesPersistAndKeepProfileNavigation() throws {
try XCTSkipIf(UIDevice.current.userInterfaceIdiom == .pad, "Requires the iPhone tab layout")
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.openSettings()
let showAvatars = app.switches["showAvatars"]
let showDisplayNames = app.switches["showDisplayNames"]
XCTAssertTrue(showAvatars.waitForExistence(timeout: 5))
XCTAssertEqual(showAvatars.value as? String, "1")
XCTAssertEqual(showDisplayNames.value as? String, "1")
showAvatars.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
XCTAssertEqual(showAvatars.value as? String, "0")
showDisplayNames.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
XCTAssertEqual(showDisplayNames.value as? String, "0")
app.closeSettings()
let author = app.buttons["profileLink-mae"]
XCTAssertTrue(author.waitForExistence(timeout: 5))
XCTAssertTrue(author.label.contains("@mae.example"))
XCTAssertFalse(author.label.contains("Mae Rivers"))
author.tap()
XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5))
XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "@mae.example")
XCTAssertTrue(app.staticTexts["profileFollowsYou"].exists)
XCTAssertFalse(app.buttons["profileAvatarButton"].exists)
app.terminate()
app.launchArguments.append("-ui-testing-preserve-defaults")
app.launch()
app.openSettings()
XCTAssertTrue(showAvatars.waitForExistence(timeout: 5))
XCTAssertEqual(showAvatars.value as? String, "0")
XCTAssertEqual(showDisplayNames.value as? String, "0")
app.closeSettings()
app.openOwnProfile()
XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5))
XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "@demo.bsky.social")
XCTAssertFalse(app.staticTexts["profileFollowsYou"].exists)
XCTAssertFalse(app.buttons["profileAvatarButton"].exists)
}
}