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
import XCTest
extension OldFellaUITests {
func testProfileReplyShowsCompactParentPostAndOpensProfile() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let profile = app.buttons["profileLink-alex"].firstMatch
XCTAssertTrue(profile.waitForExistence(timeout: 5))
profile.tap()
let parent = app.descendants(matching: .any)["replyPostContext-post-1"].firstMatch
XCTAssertTrue(parent.waitForExistence(timeout: 5))
XCTAssertTrue(app.buttons["replyContext-post-1"].label.contains("Morning walk along the water."))
XCTAssertFalse(app.buttons["replyContext-replyButton"].exists)
let author = app.buttons["replyContextAvatar-post-1"]
XCTAssertLessThanOrEqual(author.frame.height, 30)
XCTAssertTrue(author.isHittable)
author.tap()
XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Mae Rivers")
}
func testHideReplyContextSetting() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-context-quote"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
app.openSettings()
let filter = app.switches["filterReplies"]
XCTAssertTrue(filter.waitForExistence(timeout: 5))
filter.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
app.closeSettings()
let parent = app.descendants(matching: .any)["replyPostContext-post-1"].firstMatch
XCTAssertTrue(parent.waitForExistence(timeout: 5))
XCTAssertFalse(app.staticTexts["Content warning"].exists)
app.openSettings()
let setting = app.switches["showReplyContexts"]
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 link = app.buttons["replyContextLink-post-2"]
XCTAssertTrue(link.waitForExistence(timeout: 5))
XCTAssertTrue(link.label.contains("In reply to Mae Rivers"))
XCTAssertFalse(parent.exists)
XCTAssertFalse(app.staticTexts["Reply context hidden by content preferences"].exists)
link.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
XCTAssertTrue(app.buttons["postText-post-1"].exists)
app.openSettings()
setting.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
app.closeSettings()
XCTAssertTrue(parent.waitForExistence(timeout: 5))
}
func testFollowingReplyContextOpensRootPost() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let parent = app.descendants(matching: .any)["replyPostContext-post-1"].firstMatch
for _ in 0..<5 {
if parent.exists && parent.isHittable { break }
app.swipeUp()
}
XCTAssertTrue(parent.waitForExistence(timeout: 5))
let rootPost = app.buttons["replyContext-post-1"]
XCTAssertTrue(rootPost.label.contains("Morning walk along the water."))
XCTAssertFalse(app.buttons["replyContext-replyButton"].exists)
rootPost.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
}
func testReplyContextFacetsNavigateAndPlainTextOpensRootPost() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-facets"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let context = app.descendants(matching: .any)["replyContext-post-1"].firstMatch
for _ in 0..<5 {
if context.exists && context.isHittable { break }
app.swipeUp()
}
XCTAssertTrue(context.waitForExistence(timeout: 5))
XCTAssertTrue(context.label.contains("@alex.example"))
XCTAssertTrue(context.label.contains("https://example.com/reply"))
let mention = context.links.matching(NSPredicate(format: "label CONTAINS %@", "@alex.example")).firstMatch
XCTAssertTrue(mention.waitForExistence(timeout: 5))
mention.tap()
XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5))
XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Alex Kim")
app.navigationBars.buttons["Following"].tap()
let postLink = context.links.matching(
NSPredicate(format: "label CONTAINS %@", "https://oldsky.app/post?uri=post-2")
).firstMatch
XCTAssertTrue(postLink.waitForExistence(timeout: 5))
postLink.tap()
XCTAssertTrue(app.buttons["postText-post-2"].waitForExistence(timeout: 5))
app.navigationBars.buttons["Following"].tap()
let plainText = app.descendants(matching: .any)["replyContext-post-1"].firstMatch
XCTAssertTrue(plainText.waitForExistence(timeout: 5))
plainText.coordinate(withNormalizedOffset: CGVector(dx: 0.04, dy: 0.1)).tap()
XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 5))
}
func testQuotedPostFacetsNavigateAndPlainTextOpensQuotedPost() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-facets"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let quoteText = app.descendants(matching: .any)["quotedPostText-post-2"].firstMatch
for _ in 0..<6 {
if quoteText.exists && quoteText.isHittable { break }
app.swipeUp()
}
XCTAssertTrue(quoteText.waitForExistence(timeout: 5))
XCTAssertTrue(quoteText.label.contains("@mae.example"))
XCTAssertTrue(quoteText.label.contains("https://example.com/quote"))
let mention = quoteText.links.matching(NSPredicate(format: "label CONTAINS %@", "@mae.example")).firstMatch
XCTAssertTrue(mention.waitForExistence(timeout: 5))
mention.tap()
XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5))
XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Mae Rivers")
app.navigationBars.buttons["Following"].tap()
let postLink = quoteText.links.matching(
NSPredicate(format: "label CONTAINS %@", "https://oldsky.app/post?uri=post-1")
).firstMatch
XCTAssertTrue(postLink.waitForExistence(timeout: 5))
postLink.tap()
XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 5))
app.navigationBars.buttons["Following"].tap()
let plainText = app.descendants(matching: .any)["quotedPostText-post-2"].firstMatch
XCTAssertTrue(plainText.waitForExistence(timeout: 5))
plainText.coordinate(withNormalizedOffset: CGVector(dx: 0.04, dy: 0.1)).tap()
XCTAssertTrue(app.buttons["postText-post-2"].waitForExistence(timeout: 5))
}
func testFollowingReplyContextUsesMissingGapRow() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-reply-branches"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let gap = app.descendants(matching: .any)["missingReplyContext"].firstMatch
for _ in 0..<5 {
if gap.exists && gap.isHittable { break }
app.swipeUp()
}
XCTAssertTrue(gap.waitForExistence(timeout: 5))
XCTAssertTrue(gap.label.contains("More posts in this thread"))
XCTAssertFalse(app.staticTexts["Earlier reply not available"].exists)
}
func testProfileReplyUsesFeedGapRow() {
let app = XCUIApplication()
app.launchArguments = ["-ui-testing", "-ui-testing-reply-branches"]
app.launchArguments.append("-ui-testing-signed-in")
app.launch()
let profile = app.buttons["profileLink-alex"].firstMatch
XCTAssertTrue(profile.waitForExistence(timeout: 5))
profile.tap()
let gap = app.descendants(matching: .any)["missingReplyContext"].firstMatch
XCTAssertTrue(gap.waitForExistence(timeout: 5))
XCTAssertTrue(gap.label.contains("More posts in this thread"))
XCTAssertFalse(app.staticTexts["Earlier reply not available"].exists)
}
func testProfilePostsShareTimelineActionsAndNavigation() {
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 profileList = app.collectionViews["profilePostList"]
XCTAssertTrue(profileList.waitForExistence(timeout: 5))
let post = app.buttons["postText-post-1"]
XCTAssertTrue(post.isHittable)
app.buttons["Like"].firstMatch.tap()
XCTAssertTrue(app.buttons["Unlike"].firstMatch.waitForExistence(timeout: 5))
let reply = app.buttons["replyButton"].firstMatch
let quote = app.buttons["quoteButton"].firstMatch
XCTAssertEqual(reply.label, "Reply")
XCTAssertNotNil(reply.value as? String)
XCTAssertTrue(reply.staticTexts.firstMatch.exists)
XCTAssertEqual(quote.label, "Quote")
XCTAssertTrue(reply.isHittable)
XCTAssertTrue(quote.isHittable)
XCTAssertGreaterThanOrEqual(reply.frame.height, 44)
XCTAssertGreaterThanOrEqual(quote.frame.height, 44)
XCTAssertGreaterThanOrEqual(reply.frame.width, 43.9)
XCTAssertGreaterThanOrEqual(quote.frame.width, 43.9)
XCTAssertLessThanOrEqual(quote.frame.minX - reply.frame.maxX, 9)
let controls = app.buttons["postControls-post-1"].firstMatch
XCTAssertGreaterThanOrEqual(controls.frame.width, 44)
XCTAssertGreaterThanOrEqual(controls.frame.height, 44)
XCTAssertGreaterThan(controls.frame.minX, quote.frame.maxX)
reply.tap()
XCTAssertTrue(app.textViews["composeTextField"].waitForExistence(timeout: 5))
app.buttons["Cancel"].tap()
quote.tap()
XCTAssertTrue(app.textViews["composeTextField"].waitForExistence(timeout: 5))
app.buttons["Cancel"].tap()
XCTAssertTrue(post.waitForExistence(timeout: 5))
post.tap()
XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
XCTAssertTrue(app.buttons["postText-post-2"].waitForExistence(timeout: 5))
XCTAssertTrue(app.buttons["Unlike"].firstMatch.waitForExistence(timeout: 5))
app.navigationBars["Post"].buttons.element(boundBy: 0).tap()
XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5))
XCTAssertTrue(post.isHittable)
}
}