| 1 | import XCTest |
| 2 | |
| 3 | final class TaskViewUITests: XCTestCase { |
| 4 | @MainActor func testChangedFileDiffWrapsAndKeepsAmadan() { |
| 5 | for large in [false, true] { |
| 6 | let app = launch("changes-diff", large: large) |
| 7 | XCTAssertTrue(app.buttons["Open on Amadan"].waitForExistence(timeout: 15)) |
| 8 | XCTAssertTrue(app.textViews.firstMatch.waitForExistence(timeout: 10)) |
| 9 | XCTAssertTrue((app.textViews.firstMatch.value as? String ?? "").contains("reason: .signedOut)")) |
| 10 | XCTAssertLessThanOrEqual(app.textViews.firstMatch.frame.width, app.frame.width) |
| 11 | capture(large ? "iphone-diff-large" : "iphone-diff") |
| 12 | app.terminate() |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | @MainActor func testChangedFilesAndOldRunnerFallback() { |
| 17 | let app = launch("changes") |
| 18 | XCTAssertTrue(app.buttons["changed-file-Sources/Session/EquipoSession.swift"].waitForExistence(timeout: 15)) |
| 19 | XCTAssertTrue(app.staticTexts["6 files, 55 lines added, 10 removed"].exists) |
| 20 | XCTAssertTrue(app.staticTexts["Non-text file"].exists) |
| 21 | XCTAssertTrue(app.staticTexts["Renamed from docs/Badge notes.md"].exists) |
| 22 | capture("iphone-changed-files") |
| 23 | app.terminate() |
| 24 | let old = launch("changes-old") |
| 25 | XCTAssertTrue(old.buttons["Open on the web"].waitForExistence(timeout: 15)) |
| 26 | XCTAssertFalse(old.buttons["changed-file-Sources/Session/EquipoSession.swift"].exists) |
| 27 | capture("iphone-changed-files-old-runner") |
| 28 | } |
| 29 | @MainActor func testChangedFilesLargeText() { |
| 30 | let app = launch("changes", large: true) |
| 31 | XCTAssertTrue(app.buttons["changed-file-Sources/Session/EquipoSession.swift"].waitForExistence(timeout: 15)) |
| 32 | capture("iphone-changed-files-large") |
| 33 | } |
| 34 | @MainActor func testOverviewMenuAndMergeConfirmation() { |
| 35 | let app = launch("overview") |
| 36 | XCTAssertTrue(app.buttons["task-more"].waitForExistence(timeout: 15)) |
| 37 | capture("iphone-overview") |
| 38 | app.buttons["task-more"].tap() |
| 39 | XCTAssertTrue(app.buttons["Make it an exploration"].waitForExistence(timeout: 5)) |
| 40 | capture("iphone-menu") |
| 41 | app.buttons["Merge"].firstMatch.tap() |
| 42 | XCTAssertTrue(app.buttons["task-confirm"].waitForExistence(timeout: 5)) |
| 43 | capture("iphone-merge-confirmation") |
| 44 | } |
| 45 | @MainActor func testFailingSectionFirst() { |
| 46 | let app = launch("checks") |
| 47 | XCTAssertTrue(app.segmentedControls.buttons["Checks"].waitForExistence(timeout: 15)) |
| 48 | app.segmentedControls.buttons["Checks"].tap() |
| 49 | XCTAssertTrue(app.staticTexts["native-tests"].waitForExistence(timeout: 10)) |
| 50 | XCTAssertTrue(app.textViews.firstMatch.waitForExistence(timeout: 5)) |
| 51 | XCTAssertLessThan(app.staticTexts["native-tests"].frame.minY, app.staticTexts["formatting"].frame.minY) |
| 52 | XCTAssertTrue(app.staticTexts["Changes requested"].exists) |
| 53 | XCTAssertFalse(app.staticTexts["Approved"].exists) |
| 54 | capture("iphone-checks") |
| 55 | } |
| 56 | @MainActor func testHostedFailedSections() { |
| 57 | let app = launch("hosted") |
| 58 | XCTAssertTrue(app.segmentedControls.buttons["Checks"].waitForExistence(timeout: 15)) |
| 59 | app.segmentedControls.buttons["Checks"].tap() |
| 60 | XCTAssertTrue(app.staticTexts["check shard 5 of 23"].waitForExistence(timeout: 10)) |
| 61 | XCTAssertTrue(app.staticTexts["format"].exists) |
| 62 | let visibleLogs = app.textViews.allElementsBoundByIndex.compactMap { $0.value as? String }.joined(separator: "\n") |
| 63 | XCTAssertTrue(visibleLogs.contains("The changed Swift file needs formatting.")) |
| 64 | XCTAssertTrue(visibleLogs.contains("Test needsBadgeClearsAfterSignOut failed")) |
| 65 | capture("iphone-checks-hosted") |
| 66 | } |
| 67 | @MainActor func testCancelConfirmation() { |
| 68 | let app = launch("overview") |
| 69 | XCTAssertTrue(app.buttons["task-more"].waitForExistence(timeout: 15)) |
| 70 | app.buttons["task-more"].tap() |
| 71 | app.buttons["Cancel this task"].tap() |
| 72 | XCTAssertTrue(app.staticTexts["Cancel this task?"].waitForExistence(timeout: 5)) |
| 73 | XCTAssertTrue(app.buttons["task-confirm"].exists) |
| 74 | capture("iphone-cancel-confirmation") |
| 75 | } |
| 76 | @MainActor func testLargeTextTabs() { |
| 77 | let app = launch("overview", large: true) |
| 78 | XCTAssertTrue(app.buttons["task-more"].waitForExistence(timeout: 15)) |
| 79 | for label in ["Overview", "Changed files", "Checks", "Preview"] { |
| 80 | XCTAssertTrue(app.segmentedControls.buttons[label].exists) |
| 81 | } |
| 82 | capture("iphone-tabs-large") |
| 83 | } |
| 84 | @MainActor private func launch(_ fixture: String, large: Bool = false) -> XCUIApplication { |
| 85 | let app = XCUIApplication() |
| 86 | app.launchEnvironment["EQUIPO_TASK_FIXTURE"] = fixture |
| 87 | if large { app.launchArguments += ["-UIPreferredContentSizeCategoryName", "UICTContentSizeCategoryAccessibilityXL"] } |
| 88 | app.launch(); return app |
| 89 | } |
| 90 | @MainActor private func capture(_ name: String) { |
| 91 | let attachment = XCTAttachment(screenshot: XCUIScreen.main.screenshot()) |
| 92 | attachment.name = name; attachment.lifetime = .keepAlways; add(attachment) |
| 93 | } |
| 94 | } |
| 95 | |