~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/old-fella

Old people's social media app

0
1
main
40 lines · 1.9 KB Raw History
import XCTest

final class ThreadGapNavigationTests: XCTestCase {
    func testThreadGapAndExternalLinkHaveSeparateTapTargets() throws {
        try XCTSkipIf(UIDevice.current.userInterfaceIdiom == .pad, "Requires the iPhone tab layout")
        continueAfterFailure = false
        let app = XCUIApplication()
        app.launchArguments = [
            "-ui-testing", "-ui-testing-signed-in", "-ui-testing-reply-branches", "-ui-testing-thread-gap-link"
        ]
        app.launch()

        let row = app.cells.containing(.button, identifier: "postText-post-gap").firstMatch
        let gap = row.buttons["missingReplyContext"].firstMatch
        XCTAssertTrue(gap.waitForExistence(timeout: 10), app.debugDescription)
        let link = row.links["externalTextLink"].firstMatch
        XCTAssertTrue(link.exists)

        row.coordinate(withNormalizedOffset: CGVector(dx: 0.98, dy: 0.01)).tap()
        XCTAssertFalse(app.buttons["Close"].firstMatch.exists)
        XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
        XCTAssertTrue(app.buttons["postText-post-gap"].firstMatch.exists)
        XCTAssertTrue(app.navigationBars.buttons["Following"].exists)
        app.navigationBars.buttons["Following"].tap()

        gap.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap()
        XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5))
        XCTAssertTrue(app.buttons["postText-post-gap-parent"].firstMatch.waitForExistence(timeout: 5))
        XCTAssertFalse(app.buttons["Close"].firstMatch.exists)

        app.navigationBars.buttons["Following"].tap()
        XCTAssertTrue(link.waitForExistence(timeout: 5))
        link.tap()
        let close = app.buttons["Close"].firstMatch
        XCTAssertTrue(close.waitForExistence(timeout: 10))
        close.tap()
        XCTAssertTrue(close.waitForNonExistence(timeout: 5))
        XCTAssertTrue(gap.exists)
    }
}