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
import XCTest
extension XCUIApplication {
func dismissComposer(savingDraft: Bool = false, file: StaticString = #filePath, line: UInt = #line) {
swipeComposerDown(file: file, line: line)
if buttons["Save draft"].waitForExistence(timeout: 1) {
buttons[savingDraft ? "Save draft" : "Discard"].tap()
}
XCTAssertTrue(textViews["composeTextField"].waitForNonExistence(timeout: 5), file: file, line: line)
}
func swipeComposerDown(file: StaticString = #filePath, line: UInt = #line) {
let editor = textViews["composeTextField"]
XCTAssertTrue(editor.waitForExistence(timeout: 5), file: file, line: line)
XCTAssertFalse(buttons["cancelComposeButton"].exists, file: file, line: line)
let bar = navigationBars.matching(
NSPredicate(format: "identifier IN %@", ["New post", "Reply", "Quote post"])
).firstMatch
let start = bar.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))
start.press(
forDuration: 0.05,
thenDragTo: start.withOffset(CGVector(dx: 0, dy: frame.height * 0.65)),
withVelocity: .fast, thenHoldForDuration: 0)
}
}