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