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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import XCTest
extension OldFellaUITests {
func testGroupedNotificationsUsePeopleListSheets() throws {
try XCTSkipUnless(UIDevice.current.userInterfaceIdiom == .phone, "Requires iPhone")
continueAfterFailure = false
XCUIDevice.shared.orientation = .portrait
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-grouped-notifications"]
app.launch()
app.tabBars.buttons["Notifications"].tap()
let likes = app.buttons["Many liked this post"]
XCTAssertTrue(likes.waitForExistence(timeout: 5))
likes.tap()
let likedBy = app.navigationBars["Liked by"]
XCTAssertTrue(likedBy.waitForExistence(timeout: 5))
let mae = app.buttons["notificationGroupAccount-mae"]
XCTAssertTrue(mae.label.contains("Mae Rivers"))
XCTAssertTrue(mae.label.contains("@mae.example"))
XCTAssertTrue(mae.label.contains("Writer, walker, and amateur cloud spotter"))
XCTAssertTrue(app.buttons["notificationGroupAccountAvatar-mae"].exists)
likedBy.buttons["Done"].tap()
XCTAssertTrue(likedBy.waitForNonExistence(timeout: 5))
let reposts = app.buttons["Many reposted this post"]
XCTAssertTrue(reposts.waitForExistence(timeout: 5))
reposts.tap()
let repostedBy = app.navigationBars["Reposted by"]
XCTAssertTrue(repostedBy.waitForExistence(timeout: 5))
let alex = app.buttons["notificationGroupAccount-alex"]
XCTAssertTrue(alex.label.contains("@alex.example"))
alex.tap()
XCTAssertTrue(repostedBy.waitForNonExistence(timeout: 5))
let name = app.staticTexts["profileDisplayName"]
XCTAssertTrue(name.waitForExistence(timeout: 5))
XCTAssertEqual(name.label, "Alex Kim")
}
func testNotificationRefreshKeepsListVisibleAndUsable() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.tabBars.buttons["Notifications"].tap()
let post = app.buttons["notificationPost-notification-1"]
XCTAssertTrue(post.waitForExistence(timeout: 5))
let list = app.collectionViews.firstMatch
list.swipeDown()
XCTAssertTrue(post.waitForExistence(timeout: 5))
XCTAssertFalse(app.staticTexts["No notifications to show"].exists)
XCTAssertFalse(app.alerts.firstMatch.exists)
app.buttons["notificationAvatar-notification-1"].tap()
XCTAssertTrue(app.navigationBars["Profile"].waitForExistence(timeout: 5))
XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Mae Rivers")
app.tabBars.buttons["Timeline"].tap()
XCTAssertTrue(app.navigationBars["Following"].waitForExistence(timeout: 5))
}
func testYourPostContextUsesCompactHeaderSpacing() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.tabBars.buttons["Notifications"].tap()
let header = app.buttons["notificationPost-notification-1"]
XCTAssertTrue(header.waitForExistence(timeout: 5))
let text = app.descendants(matching: .any)["quotedPostText-post-1"].firstMatch
XCTAssertTrue(text.exists)
XCTAssertTrue(header.label.hasPrefix("Your post"))
XCTAssertLessThan(header.frame.height, 44)
XCTAssertEqual(text.frame.minY - header.frame.maxY, 12, accuracy: 1)
header.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
}
func testNotificationsLoadNextPageAfterExplicitTap() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.tabBars.buttons["Notifications"].tap()
XCTAssertTrue(app.buttons["notificationPost-notification-1"].waitForExistence(timeout: 5))
let repost = app.buttons["notificationPost-notification-5"]
XCTAssertFalse(repost.exists)
let loadMore = app.buttons["loadMoreNotificationsButton"]
for _ in 0..<5 {
if loadMore.exists && loadMore.isHittable { break }
app.swipeUp()
}
XCTAssertTrue(loadMore.waitForExistence(timeout: 5))
loadMore.tap()
for _ in 0..<5 {
if repost.exists { break }
app.swipeUp()
}
XCTAssertTrue(repost.waitForExistence(timeout: 5))
XCTAssertTrue(repost.label.hasPrefix("Your post"))
let quote = app.buttons["quotedPostLink"]
for _ in 0..<5 {
if quote.exists && quote.isHittable { break }
app.swipeUp()
}
XCTAssertTrue(quote.waitForExistence(timeout: 5))
}
func testLikeNotificationAvatarOpensProfile() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.tabBars.buttons["Notifications"].tap()
let avatar = app.buttons["notificationAvatar-notification-1"]
XCTAssertTrue(avatar.waitForExistence(timeout: 5))
avatar.tap()
XCTAssertTrue(app.navigationBars["Profile"].waitForExistence(timeout: 5))
XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Mae Rivers")
}
func testFollowNotificationAvatarOpensProfile() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"]
app.launch()
app.tabBars.buttons["Notifications"].tap()
let avatar = app.buttons["notificationAvatar-notification-3"]
XCTAssertTrue(avatar.waitForExistence(timeout: 5))
XCTAssertTrue(
app.buttons["notification-notification-3"].label.contains(
"Learning to cook one seasonal recipe at a time."))
avatar.tap()
XCTAssertTrue(app.navigationBars["Profile"].waitForExistence(timeout: 5))
XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Sam Lee")
}
func testMentionShowsFullPostAndActions() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
XCTAssertTrue(app.tabBars.buttons["Notifications"].waitForExistence(timeout: 5))
app.tabBars.buttons["Notifications"].tap()
let loadMore = app.buttons["loadMoreNotificationsButton"]
XCTAssertTrue(loadMore.waitForExistence(timeout: 5))
loadMore.tap()
let post = app.buttons["postText-mention-post-1"]
for _ in 0..<8 {
if post.exists && post.isHittable { break }
app.swipeUp()
}
XCTAssertTrue(post.isHittable)
XCTAssertTrue(post.label.contains("Take a look at this, @demo.bsky.social."))
XCTAssertTrue(app.staticTexts["notificationActivity-notification-7"].exists)
XCTAssertFalse(app.buttons["notification-notification-7"].exists)
post.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
}
func testSignInCanEnterEmailCodeAfterChallenge() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-auth-factor"]
app.launch()
let handleField = app.textFields["handleField"]
XCTAssertTrue(handleField.waitForExistence(timeout: 5))
handleField.tap()
handleField.typeText("demo.bsky.social")
let passwordField = app.secureTextFields["appPasswordField"]
passwordField.tap()
passwordField.typeText("test-only")
let signInButton = app.buttons["signInButton"]
signInButton.tap()
let codeField = app.textFields["authFactorTokenField"]
XCTAssertTrue(codeField.waitForExistence(timeout: 5))
codeField.tap()
XCTAssertTrue(app.keyboards.keys["a"].waitForExistence(timeout: 5))
codeField.typeText(" ")
XCTAssertFalse(signInButton.isEnabled)
codeField.typeText("aB12c3 ")
XCTAssertEqual(codeField.value as? String, " aB12c3 ")
signInButton.tap()
XCTAssertTrue(app.navigationBars["Following"].waitForExistence(timeout: 5))
}
func testThreadStartsAtSelectedPostAfterLoading() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-thread-delay"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let timelinePost = app.buttons["quotedPostText-post-2"]
XCTAssertTrue(timelinePost.waitForExistence(timeout: 5))
timelinePost.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
let thread = app.scrollViews["threadScrollView"]
let loading = app.otherElements["postDetailLoading"].firstMatch
XCTAssertTrue(loading.waitForExistence(timeout: 2))
XCTAssertFalse(thread.exists)
let selectedPost = thread.buttons["postText-post-2"]
let rootPost = thread.buttons["postText-post-1"]
XCTAssertTrue(selectedPost.waitForExistence(timeout: 5))
XCTAssertTrue(rootPost.exists)
let selectedAuthor = app.buttons["profileLink-alex"]
let navigationBarBottom = app.navigationBars["Post"].frame.maxY
XCTAssertGreaterThanOrEqual(selectedAuthor.frame.minY, navigationBarBottom)
XCTAssertLessThan(selectedAuthor.frame.minY, navigationBarBottom + 40)
XCTAssertGreaterThanOrEqual(selectedPost.frame.minY, navigationBarBottom)
XCTAssertLessThan(selectedPost.frame.minY, navigationBarBottom + 120)
app.swipeDown()
let rootAuthor = app.buttons["profileLink-mae"]
XCTAssertTrue(rootAuthor.isHittable)
XCTAssertGreaterThanOrEqual(rootAuthor.frame.minY, navigationBarBottom)
XCTAssertTrue(rootPost.isHittable)
XCTAssertGreaterThanOrEqual(rootPost.frame.minY, navigationBarBottom)
}
func testThreadAuthorStaysBelowTopBarWithImmediateResponse() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let timelinePost = app.buttons["quotedPostText-post-2"]
XCTAssertTrue(timelinePost.waitForExistence(timeout: 5))
timelinePost.tap()
let navigationBar = app.navigationBars["Post"]
XCTAssertTrue(navigationBar.waitForExistence(timeout: 5))
let selectedAuthor = app.buttons["profileLink-alex"]
XCTAssertTrue(selectedAuthor.waitForExistence(timeout: 5))
XCTAssertGreaterThanOrEqual(selectedAuthor.frame.minY, navigationBar.frame.maxY)
XCTAssertLessThan(selectedAuthor.frame.minY, navigationBar.frame.maxY + 40)
app.swipeDown()
let rootAuthor = app.buttons["profileLink-mae"]
XCTAssertTrue(rootAuthor.isHittable, app.debugDescription)
XCTAssertGreaterThanOrEqual(rootAuthor.frame.minY, navigationBar.frame.maxY)
XCTAssertTrue(app.buttons["postText-post-1"].isHittable)
}
func testProfileLoadsMorePostsOnlyAfterExplicitTap() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let avatar = app.buttons["profileLink-mae"].firstMatch
XCTAssertTrue(avatar.waitForExistence(timeout: 5))
avatar.tap()
XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5))
let nextPost = app.buttons["postText-profile-post-more"]
XCTAssertFalse(nextPost.exists)
let loadMore = app.buttons["loadMoreProfilePostsButton"]
XCTAssertTrue(loadMore.waitForExistence(timeout: 5))
XCTAssertTrue(loadMore.isHittable)
loadMore.tap()
XCTAssertTrue(nextPost.waitForExistence(timeout: 5))
XCTAssertFalse(loadMore.exists)
XCTAssertTrue(app.buttons["postText-post-1"].exists)
app.navigationBars["Profile"].buttons["Following"].tap()
XCTAssertTrue(app.navigationBars["Following"].waitForExistence(timeout: 5))
XCTAssertFalse(nextPost.exists)
}
}