import XCTest final class PublishedReplyUITests: XCTestCase { func testSentReplyShowsThreadRootAndParentWithoutRefresh() 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 parent = app.cells.containing(.button, identifier: "postText-post-gap").firstMatch XCTAssertTrue(parent.waitForExistence(timeout: 10)) let replyButton = parent.buttons["replyButton"] if !replyButton.isHittable { app.collectionViews.firstMatch.swipeUp() } replyButton.tap() let editor = app.textViews["composeTextField"] XCTAssertTrue(editor.waitForExistence(timeout: 5)) editor.tap() let text = "A new reply in the longer conversation" editor.typeText(text) app.buttons["publishButton"].tap() XCTAssertTrue(editor.waitForNonExistence(timeout: 5)) let reply = app.buttons.matching( NSPredicate(format: "identifier BEGINSWITH %@ AND label CONTAINS %@", "postText-", text) ).firstMatch XCTAssertTrue(reply.waitForExistence(timeout: 5), app.debugDescription) let row = app.cells.containing(.button, identifier: reply.identifier).firstMatch let rootContext = row.buttons["replyContext-post-1"] let parentContext = row.buttons["replyContext-post-gap"] XCTAssertTrue(rootContext.exists) XCTAssertTrue(parentContext.exists) XCTAssertTrue(row.buttons["missingReplyContext"].exists) XCTAssertLessThan(rootContext.frame.minY, parentContext.frame.minY) XCTAssertLessThan(parentContext.frame.minY, reply.frame.minY) } }