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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import XCTest
extension OldFellaUITests {
func testQuoteHeaderSpacingMatchesFeedContextAndDetail() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-context-quote"]
app.launch()
app.openSettings()
let toggle = app.switches["filterReplies"]
XCTAssertTrue(toggle.waitForExistence(timeout: 5))
toggle.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
app.closeSettings()
let context = app.descendants(matching: .any)["replyPostContext-post-1"].firstMatch
XCTAssertTrue(context.waitForExistence(timeout: 5))
let header = context.buttons["quotedPostLink"]
let text = context.descendants(matching: .any)["quotedPostText-post-3"].firstMatch
XCTAssertTrue(header.exists)
XCTAssertTrue(text.exists)
let contextHeight = header.frame.height
XCTAssertEqual(text.frame.minY - header.frame.maxY, 12, accuracy: 1)
context.descendants(matching: .any)["replyContext-post-1"].firstMatch.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
let detailHeader = app.buttons["quotedPostLink"].firstMatch
let detailText = app.descendants(matching: .any)["quotedPostText-post-3"].firstMatch
XCTAssertTrue(detailHeader.waitForExistence(timeout: 5))
XCTAssertTrue(detailText.exists)
XCTAssertEqual(detailHeader.frame.height, contextHeight, accuracy: 1)
XCTAssertEqual(detailText.frame.minY - detailHeader.frame.maxY, 12, accuracy: 1)
}
func testThreadContextQuoteFollowsText() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-context-quote"]
app.launch()
let context = app.descendants(matching: .any)["replyPostContext-post-1"].firstMatch
for _ in 0..<5 {
if context.exists && context.isHittable { break }
app.swipeUp()
}
XCTAssertTrue(context.waitForExistence(timeout: 5))
let text = context.buttons["replyContext-post-1"]
let quote = context.buttons["quotedPostLink"]
XCTAssertTrue(text.exists)
XCTAssertTrue(quote.exists)
XCTAssertEqual(quote.frame.minY - text.frame.maxY, 14, accuracy: 1)
quote.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
XCTAssertTrue(app.buttons["postText-post-3"].waitForExistence(timeout: 5))
}
func testHideQuotedPostsSetting() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
app.openSettings()
let setting = app.switches["showQuotedPosts"]
XCTAssertTrue(setting.waitForExistence(timeout: 5))
setting.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
XCTAssertEqual(String(describing: setting.value ?? ""), "0")
app.closeSettings()
let quote = app.buttons["quotedPostLink"]
for _ in 0..<5 {
if quote.exists && quote.isHittable { break }
app.swipeUp()
}
XCTAssertTrue(quote.exists)
XCTAssertEqual(quote.label, "See post")
quote.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
app.openSettings()
setting.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
}
func testNotificationTabShowsUnreadStatusAndClearsAfterOpening() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
let notifications = app.tabBars.buttons["Notifications"]
XCTAssertTrue(notifications.waitForExistence(timeout: 5))
expectation(for: NSPredicate(format: "value CONTAINS %@", "Unread notifications"), evaluatedWith: notifications)
waitForExpectations(timeout: 5)
let unread = XCTAttachment(screenshot: app.screenshot())
unread.name = "Unread notification bell"
unread.lifetime = .keepAlways
add(unread)
notifications.tap()
expectation(
for: NSPredicate(format: "value CONTAINS %@", "No unread notifications"), evaluatedWith: notifications)
waitForExpectations(timeout: 5)
XCTAssertTrue(app.navigationBars["Notifications"].exists)
let read = XCTAttachment(screenshot: app.screenshot())
read.name = "Read notification bell"
read.lifetime = .keepAlways
add(read)
}
func testNotificationsAndSettingsTabs() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let notifications = app.tabBars.buttons["Notifications"]
XCTAssertTrue(notifications.waitForExistence(timeout: 5))
notifications.tap()
XCTAssertTrue(app.navigationBars["Notifications"].waitForExistence(timeout: 5))
XCTAssertTrue(app.buttons["postText-reply-post-1"].waitForExistence(timeout: 5))
XCTAssertTrue(app.buttons["postText-reply-post-1"].label.contains("Thanks for the thoughtful reply."))
XCTAssertFalse(app.staticTexts["Alex Kim replied to your post"].exists)
let likedPost = app.buttons["notificationPost-notification-1"]
XCTAssertTrue(likedPost.exists)
likedPost.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
app.navigationBars.buttons["Notifications"].tap()
app.openSettings()
XCTAssertTrue(app.navigationBars["Settings"].waitForExistence(timeout: 5))
let account = app.buttons["settingsEditProfile"]
XCTAssertTrue(account.label.contains("Demo Account"))
XCTAssertTrue(account.label.contains("@demo.bsky.social"))
let signOut = app.buttons["settingsSignOutButton"]
for _ in 0..<3 where !signOut.isHittable { app.swipeUp() }
XCTAssertTrue(signOut.isHittable)
signOut.tap()
app.buttons.matching(identifier: "settingsConfirmSignOutButton").firstMatch.tap()
XCTAssertTrue(app.staticTexts["Sign in"].waitForExistence(timeout: 5))
}
func testNotificationReplyShowsContextAndOpensReply() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.tabBars.buttons["Notifications"].tap()
let reply = app.buttons["postText-reply-post-1"]
XCTAssertTrue(reply.waitForExistence(timeout: 5))
let context = app.descendants(matching: .any)["replyContext-post-1"].firstMatch
XCTAssertTrue(context.waitForExistence(timeout: 5))
XCTAssertTrue(context.label.contains("Morning walk along the water."))
XCTAssertTrue(
app.buttons.matching(NSPredicate(format: "label CONTAINS %@", "Thread started by Mae Rivers")).firstMatch
.exists)
reply.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
XCTAssertTrue(app.buttons["postText-reply-post-1"].waitForExistence(timeout: 5))
}
func testNotificationReplyParentAvatarOpensProfile() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.tabBars.buttons["Notifications"].tap()
let avatar = app.buttons["notificationReplyAvatar-post-1"]
XCTAssertTrue(avatar.waitForExistence(timeout: 5))
avatar.tap()
XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5))
XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Mae Rivers")
}
func testNotificationReplyShowsOwnParentAuthor() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-own-reply-parent"]
app.launch()
app.tabBars.buttons["Notifications"].tap()
let context = app.descendants(matching: .any)["replyContext-own-parent"].firstMatch
XCTAssertTrue(context.waitForExistence(timeout: 5))
XCTAssertTrue(context.label.contains("A post by the signed-in account."))
XCTAssertTrue(
app.buttons.matching(NSPredicate(format: "label CONTAINS %@", "Thread started by Demo Account")).firstMatch
.exists)
}
func testNotificationReplyAlwaysShowsContextWhenSettingHidesIt() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.openSettings()
let setting = app.switches["showReplyContexts"]
XCTAssertTrue(setting.waitForExistence(timeout: 5))
setting.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
app.closeSettings()
app.tabBars.buttons["Notifications"].tap()
let context = app.buttons["replyContext-post-1"]
XCTAssertTrue(context.waitForExistence(timeout: 5))
XCTAssertTrue(context.label.contains("Morning walk along the water."))
XCTAssertFalse(app.buttons["replyContextLink-reply-post-1"].exists)
context.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 5))
}
func testNativeRefreshLoadsNewPosts() {
let app = XCUIApplication()
app.launchArguments = [
"-ui-testing", "-ui-testing-signed-in", "-ui-testing-pull-refresh-delay",
"-ui-testing-refresh-new-post"
]
app.launch()
XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 10))
XCTAssertTrue(
app.descendants(matching: .any)["initialFeedRefreshControl"].firstMatch.waitForNonExistence(timeout: 5))
let list = app.collectionViews.firstMatch
let start = list.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.4))
let end = list.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.85))
start.press(forDuration: 0.05, thenDragTo: end, withVelocity: .slow, thenHoldForDuration: 0.2)
XCTAssertTrue(app.buttons["postText-refresh-new-post"].waitForExistence(timeout: 10))
XCTAssertTrue(app.navigationBars["Following"].exists)
let screenshot = XCTAttachment(screenshot: app.screenshot())
screenshot.name = "Native refresh with new posts"
screenshot.lifetime = .keepAlways
add(screenshot)
}
func testFollowingRefreshKeepsPostsVisibleAndUsable() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
let post = app.buttons["postText-post-1"]
XCTAssertTrue(post.waitForExistence(timeout: 5))
app.collectionViews.firstMatch.swipeDown()
XCTAssertTrue(post.waitForExistence(timeout: 5))
XCTAssertFalse(app.alerts.firstMatch.exists)
post.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
app.tabBars.buttons["Notifications"].tap()
XCTAssertTrue(app.navigationBars["Notifications"].waitForExistence(timeout: 5))
}
}