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) } }