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

geesawra.industries/old-fella

Old people's social media app

0
1
main
25 lines · 1.2 KB Raw History
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)
    }
}