145 lines
7.1 KiB
Swift
145 lines
7.1 KiB
Swift
import XCTest
|
|
import XCUIAutomation
|
|
|
|
final class MikeMailUITests: XCTestCase {
|
|
@MainActor
|
|
func testMailWindowAndCompose() throws {
|
|
continueAfterFailure = false
|
|
let app = XCUIApplication()
|
|
app.launchArguments = ["-ApplePersistenceIgnoreState", "YES", "-checkOnLaunch", "NO", "-idleEnabled", "NO", "-selectedFolder", "", "-selectedMessage", ""]
|
|
app.launch()
|
|
app.activate()
|
|
XCTAssertTrue(app.buttons["Neue Nachricht"].waitForExistence(timeout: 5), app.debugDescription)
|
|
XCTAssertTrue(app.staticTexts["Nachricht auswählen"].waitForExistence(timeout: 5), app.debugDescription)
|
|
app.buttons["Neue Nachricht"].click()
|
|
XCTAssertTrue(app.buttons["Anhang hinzufügen"].waitForExistence(timeout: 5))
|
|
XCTAssertFalse(app.buttons["Senden"].isEnabled)
|
|
XCTAssertTrue(app.buttons["Adressbuch"].exists)
|
|
XCTAssertTrue(app.textFields["recipientField"].exists)
|
|
XCTAssertTrue(app.textFields["composeCC"].exists)
|
|
XCTAssertTrue(app.textFields["composeBCC"].exists)
|
|
app.buttons["Abbrechen"].click()
|
|
app.buttons["Konten"].click()
|
|
XCTAssertTrue(app.secureTextFields.firstMatch.waitForExistence(timeout: 5))
|
|
XCTAssertTrue(app.buttons["Speichern"].exists)
|
|
XCTAssertTrue(app.buttons["Neues Konto hinzufügen"].exists)
|
|
XCTAssertTrue(app.buttons["Konto löschen"].exists)
|
|
app.buttons["clearLocalMessages"].click()
|
|
XCTAssertTrue(app.buttons["Lokale Mails endgültig löschen"].waitForExistence(timeout: 5))
|
|
app.buttons["Abbrechen"].click()
|
|
XCTAssertTrue(app.buttons["clearLocalMessages"].exists)
|
|
app.buttons["Neues Konto hinzufügen"].click()
|
|
XCTAssertTrue(app.textFields["accountEmail"].waitForExistence(timeout: 5))
|
|
XCTAssertFalse(app.buttons["Speichern"].isEnabled)
|
|
XCTAssertTrue(app.buttons["Verbindung testen"].exists)
|
|
app.buttons["Schließen"].click()
|
|
XCTAssertTrue(app.descendants(matching: .any)["Abrufen"].firstMatch.waitForExistence(timeout: 5), app.debugDescription)
|
|
}
|
|
|
|
@MainActor
|
|
func testMessageWindowAndActions() throws {
|
|
continueAfterFailure = false
|
|
let app = XCUIApplication()
|
|
app.launchArguments = ["-ApplePersistenceIgnoreState", "YES", "-checkOnLaunch", "NO", "-idleEnabled", "NO",
|
|
"--ui-fixture", "-pollMinutes", "0", "-selectedFolder", "unified:inbox", "-selectedMessage", "", "-mailSearch", ""]
|
|
app.launch()
|
|
app.activate()
|
|
if app.windows.count == 0 {
|
|
app.menuBars.menuBarItems["File"].click()
|
|
app.menuItems["New"].hover()
|
|
app.menuItems["New Window"].click()
|
|
}
|
|
let table = app.outlines.firstMatch
|
|
XCTAssertTrue(table.waitForExistence(timeout: 5), app.debugDescription)
|
|
let row = table.descendants(matching: .outlineRow).firstMatch
|
|
XCTAssertTrue(row.waitForExistence(timeout: 5), app.debugDescription)
|
|
app.activate()
|
|
table.staticTexts["UI-Nachricht 1"].firstMatch.doubleClick()
|
|
let detail = app.windows["UI-Nachricht 1"]
|
|
XCTAssertTrue(detail.waitForExistence(timeout: 5))
|
|
let reply = detail.buttons["Antworten…"].firstMatch
|
|
XCTAssertTrue(reply.waitForExistence(timeout: 5), app.debugDescription)
|
|
XCTAssertGreaterThanOrEqual(app.windows.count, 2, app.debugDescription)
|
|
reply.click()
|
|
XCTAssertTrue(app.textFields["composeCC"].waitForExistence(timeout: 5))
|
|
let compose = app.windows["Neue Nachricht"].firstMatch
|
|
XCTAssertTrue(compose.waitForExistence(timeout: 5))
|
|
XCTAssertGreaterThanOrEqual(app.windows.count, 3)
|
|
let body = compose.textViews["composeBody"]
|
|
XCTAssertTrue(body.waitForExistence(timeout: 5))
|
|
app.typeText("Antwort am Anfang ")
|
|
XCTAssertTrue((body.value as? String ?? "").hasPrefix("Antwort am Anfang "))
|
|
let oldFrame = compose.frame
|
|
resizeWindow(compose, app: app)
|
|
XCTAssertNotEqual(compose.frame.size, oldFrame.size)
|
|
compose.buttons["Abbrechen"].click()
|
|
let oldDetail = detail.frame
|
|
detail.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.01)).click()
|
|
resizeWindow(detail, app: app)
|
|
XCTAssertNotEqual(detail.frame.size, oldDetail.size)
|
|
}
|
|
|
|
@MainActor
|
|
func testDeleteConfirmation() {
|
|
let app = XCUIApplication()
|
|
app.launchArguments = ["-ApplePersistenceIgnoreState", "YES", "--ui-fixture", "-checkOnLaunch", "NO",
|
|
"-idleEnabled", "NO", "-pollMinutes", "0", "-selectedFolder", "unified:inbox", "-mailSearch", "",
|
|
"-mailDeleteConfirmation", "always", "--ui-busy"]
|
|
app.launch()
|
|
app.activate()
|
|
if app.windows.count == 0 {
|
|
app.menuBars.menuBarItems["File"].click()
|
|
app.menuItems["New"].hover()
|
|
app.menuItems["New Window"].click()
|
|
}
|
|
let table = app.outlines.firstMatch
|
|
XCTAssertTrue(table.waitForExistence(timeout: 5))
|
|
table.staticTexts["UI-Nachricht 1"].firstMatch.click()
|
|
app.buttons["Löschen…"].firstMatch.click()
|
|
XCTAssertTrue(app.buttons["Abbrechen"].waitForExistence(timeout: 3), app.debugDescription)
|
|
if app.buttons["Abbrechen"].exists { app.buttons["Abbrechen"].click() }
|
|
}
|
|
|
|
@MainActor
|
|
func testAccountReorderingAndDisclosure() {
|
|
continueAfterFailure = false
|
|
let app = XCUIApplication()
|
|
app.launchArguments = ["-ApplePersistenceIgnoreState", "YES", "--ui-fixture", "-checkOnLaunch", "NO",
|
|
"-idleEnabled", "NO", "-pollMinutes", "0", "-selectedFolder", "unified:inbox", "-mailSearch", ""]
|
|
app.launch()
|
|
app.activate()
|
|
if app.windows.count == 0 {
|
|
app.menuBars.menuBarItems["File"].click()
|
|
app.menuItems["New"].hover()
|
|
app.menuItems["New Window"].click()
|
|
}
|
|
app.activate()
|
|
let sidebar = app.tables["accountSidebar"]
|
|
XCTAssertTrue(sidebar.waitForExistence(timeout: 5))
|
|
let rows = sidebar.tableRows
|
|
XCTAssertTrue(rows.element(boundBy: 4).waitForExistence(timeout: 5))
|
|
let source = rows.element(boundBy: 4)
|
|
let target = rows.element(boundBy: 2)
|
|
let disclosure = target.buttons.firstMatch
|
|
XCTAssertTrue(disclosure.exists)
|
|
XCTAssertEqual(disclosure.frame.midY, target.frame.midY, accuracy: 2)
|
|
source.staticTexts["Zweites Testkonto"].click(forDuration: 1, thenDragTo: target.staticTexts["UI-Prüfung"])
|
|
XCTAssertTrue(rows.element(boundBy: 2).debugDescription.contains("second@example.com"), sidebar.debugDescription)
|
|
}
|
|
|
|
@MainActor
|
|
private func resizeWindow(_ window: XCUIElement, app: XCUIApplication) {
|
|
let original = window.frame.size
|
|
app.menuBars.menuBarItems["Window"].click()
|
|
app.menuItems["Fill"].click()
|
|
if window.frame.size == original {
|
|
app.menuBars.menuBarItems["Window"].click()
|
|
app.menuItems["Move & Resize"].hover()
|
|
app.menuItems["Left"].click()
|
|
}
|
|
let changed = NSPredicate { _, _ in window.frame.size != original }
|
|
expectation(for: changed, evaluatedWith: window)
|
|
waitForExpectations(timeout: 3)
|
|
}
|
|
}
|