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
import XCTest
final class FeedInitialLoadingTests: XCTestCase {
func testInitialLoadKeepsTitleStableAndFirstPostVisible() throws {
try assertInitialLoad(font: "system")
}
func testInitialLoadWithCustomFontKeepsTitleStableAndFirstPostVisible() throws {
try assertInitialLoad(font: "iosevka")
}
private func assertInitialLoad(font: String) throws {
try XCTSkipIf(UIDevice.current.userInterfaceIdiom == .pad, "Requires the iPhone feed layout")
let app = XCUIApplication()
app.launchArguments = [
"-ui-testing", "-ui-testing-signed-in", "-ui-testing-feed-delay", "-ui-testing-pull-refresh-delay",
"-ui-testing-rich-scroll",
"-appFont", font
]
app.launch()
let navigation = app.navigationBars["Following"]
XCTAssertTrue(navigation.waitForExistence(timeout: 5))
let titleHeight = navigation.frame.height
let spinner = app.descendants(matching: .any)["initialFeedRefreshControl"].firstMatch
XCTAssertTrue(spinner.waitForExistence(timeout: 5))
let firstPost = app.buttons["postText-at://mae.example/app.bsky.feed.post/scroll-0-main"]
XCTAssertTrue(firstPost.waitForExistence(timeout: 20))
XCTAssertTrue(spinner.waitForNonExistence(timeout: 5))
let loaded = XCTAttachment(screenshot: app.screenshot())
loaded.name = "Initial feed loaded"
loaded.lifetime = .keepAlways
add(loaded)
XCTAssertEqual(navigation.frame.height, titleHeight, accuracy: 1)
XCTAssertTrue(firstPost.isHittable)
let firstCell = app.collectionViews.cells.containing(
.button, identifier: "postText-at://mae.example/app.bsky.feed.post/scroll-0-main"
).firstMatch
XCTAssertGreaterThanOrEqual(firstCell.frame.minY, navigation.frame.maxY - 1)
}
}