import XCTest final class NeedsYouUITests: XCTestCase { @MainActor func testTodayShowsRunningAndFinishedWithoutAnInboxBadge() { let app = launch("today") XCTAssertTrue(app.staticTexts["Running now"].waitForExistence(timeout: 15)) XCTAssertTrue(app.staticTexts["Keep the task list up to date"].exists) for _ in 0..<3 { if app.staticTexts["Explain why the upload stopped"].isHittable { break } app.swipeUp() } XCTAssertTrue(app.staticTexts["Finished today"].isHittable) XCTAssertTrue(app.staticTexts["Explain why the upload stopped"].isHittable) XCTAssertTrue(app.staticTexts["Updating the list after a task finishes"].exists) let tab = app.tabBars.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", "Needs you")).firstMatch XCTAssertFalse((tab.value as? String ?? "").contains("2")) XCTAssertTrue(app.buttons["today-undo-finished"].waitForExistence(timeout: 10)) XCTAssertTrue(app.staticTexts["Merged into main at 00:20"].exists) capture("iphone-today") app.buttons["today-undo-finished"].tap() XCTAssertTrue(app.staticTexts["Undo this merge?"].waitForExistence(timeout: 5)) XCTAssertTrue(app.staticTexts["Equipo will start a task to revert this merge. From now on, it will ask before every merge in this project."].exists) } @MainActor func testEmptyUsesReviewedWords() { let app = launch("empty") XCTAssertTrue(app.staticTexts["Nothing needs you right now."].waitForExistence(timeout: 15)) XCTAssertFalse(app.staticTexts["Running now"].exists) XCTAssertFalse(app.staticTexts["Finished today"].exists) capture("iphone-empty") } @MainActor func testRowsShowThreeActionsAndMergeConfirms() { let app = launch("list") XCTAssertTrue(app.buttons["needs-action-retry"].waitForExistence(timeout: 15)) XCTAssertEqual(app.buttons["needs-action-retry"].label, "Try again") XCTAssertEqual(app.buttons["needs-action-merge"].label, "Merge") XCTAssertTrue(app.buttons["Yes, name the team"].waitForExistence(timeout: 15)) XCTAssertTrue(app.buttons["Keep it short"].exists) XCTAssertTrue(app.buttons["needs-question-header-question"].exists) XCTAssertFalse(app.staticTexts["NEEDS YOU"].exists) capture("iphone-needs-you") app.buttons["needs-action-merge"].tap() XCTAssertTrue(app.buttons["task-confirm"].waitForExistence(timeout: 5)) XCTAssertTrue(app.staticTexts["Keep the sign-in button visible"].exists) capture("iphone-needs-merge-confirmation") } @MainActor func testDecisionRowsKeepSetAsideAndUndo() { let app = launch("list") XCTAssertTrue(app.buttons["needs-action-merge"].waitForExistence(timeout: 15)) XCTAssertGreaterThanOrEqual(app.buttons.matching(identifier: "Set aside").count, 2) app.terminate() let aside = launch("aside") XCTAssertTrue(aside.buttons["Undo"].waitForExistence(timeout: 15)) XCTAssertFalse(aside.buttons["needs-action-merge"].exists) capture("iphone-needs-aside") } @MainActor func testTodayHidesUndoWithoutTheServerOffer() { let app = launch("today-no-undo") XCTAssertTrue(app.staticTexts["Finished today"].waitForExistence(timeout: 15)) XCTAssertFalse(app.buttons["today-undo-finished"].exists) } @MainActor private func launch(_ fixture: String) -> XCUIApplication { let app = XCUIApplication() app.launchEnvironment["EQUIPO_NEEDS_FIXTURE"] = fixture app.launch(); return app } @MainActor private func capture(_ name: String) { let attachment = XCTAttachment(screenshot: XCUIScreen.main.screenshot()) attachment.name = name; attachment.lifetime = .keepAlways; add(attachment) } }