import XCTest extension OldFellaUITests { func testAltTextUnavailableAndFailureKeepManualText() { for mode in ["-ui-testing-alt-unavailable", "-ui-testing-alt-failure"] { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-compose-images", mode] app.launch() XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 10)) app.tabBars.buttons["New post"].tap() let attachment = app.buttons["editAltText-0"] XCTAssertTrue(attachment.waitForExistence(timeout: 5)) attachment.tap() XCTAssertTrue(app.navigationBars["Alt text editor"].waitForExistence(timeout: 5)) let editor = app.textViews["altTextEditor"] XCTAssertTrue(editor.waitForExistence(timeout: 5)) if mode == "-ui-testing-alt-unavailable" { XCTAssertFalse(app.buttons["generateAltText-0"].exists) } else { let generate = app.buttons["generateAltText-0"] XCTAssertTrue(generate.waitForExistence(timeout: 5)) generate.tap() XCTAssertTrue(app.navigationBars["Alt text editor"].exists) let alert = app.alerts["Alt text unavailable"] XCTAssertTrue(alert.waitForExistence(timeout: 5)) alert.buttons["OK"].tap() XCTAssertTrue(app.navigationBars["Alt text editor"].exists) } XCTAssertEqual(editor.value as? String, "A photo") app.navigationBars["Alt text editor"].buttons["Cancel"].tap() app.buttons["publishButton"].tap() XCTAssertTrue(app.alerts["Add alt text?"].waitForExistence(timeout: 5)) app.terminate() } } func testMissingAltTextReminderAllowsEditingAndPosting() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-compose-images"] app.launch() XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 10)) app.tabBars.buttons["New post"].tap() XCTAssertTrue(app.scrollViews["imageAttachments"].waitForExistence(timeout: 5)) app.buttons["publishButton"].tap() let alert = app.alerts["Add alt text?"] XCTAssertTrue(alert.waitForExistence(timeout: 5)) alert.buttons["Keep editing"].tap() XCTAssertTrue(app.textViews["composeTextField"].exists) app.buttons["publishButton"].tap() XCTAssertTrue(alert.waitForExistence(timeout: 5)) alert.buttons["Post without alt text"].tap() XCTAssertTrue(app.navigationBars["Following"].waitForExistence(timeout: 10)) } func testDisabledMissingAltTextReminderPostsDirectly() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-compose-images"] app.launch() XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 10)) app.openSettings() let toggle = app.switches["remindMissingAltText"] XCTAssertTrue(toggle.waitForExistence(timeout: 5)) XCTAssertEqual(toggle.value as? String, "1") toggle.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap() XCTAssertEqual(toggle.value as? String, "0") app.closeSettings() app.tabBars.buttons["New post"].tap() XCTAssertTrue(app.scrollViews["imageAttachments"].waitForExistence(timeout: 5)) app.buttons["publishButton"].tap() XCTAssertTrue(app.navigationBars["Following"].waitForExistence(timeout: 10)) XCTAssertFalse(app.alerts["Add alt text?"].exists) } func testLinkOnlyPostOmitsEmptyTextAndMediaSpace() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-link-only"] app.launch() let link = app.links["externalTextLink"].firstMatch XCTAssertTrue(link.waitForExistence(timeout: 10)) XCTAssertFalse(app.buttons["postText-link-only"].exists) XCTAssertFalse(app.staticTexts["postText-link-only"].exists) let author = app.buttons["profileLink-mae"].firstMatch XCTAssertTrue(author.exists) XCTAssertGreaterThanOrEqual(link.frame.minY, author.frame.maxY) XCTAssertLessThanOrEqual(link.frame.minY - author.frame.maxY, 20) } func testReplyContextNamesItsAuthorAndOpensItsPost() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-reply-attribution"] app.launch() app.openSettings() let override = app.switches["filterReplies"] XCTAssertTrue(override.waitForExistence(timeout: 5)) override.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap() app.closeSettings() let reply = app.buttons.matching(NSPredicate(format: "label == %@", "Reply by Alex Kim")).firstMatch XCTAssertTrue(reply.waitForExistence(timeout: 5)) XCTAssertFalse( app.buttons.matching(NSPredicate(format: "label CONTAINS %@", "Replying to Mae Rivers")).firstMatch.exists) reply.tap() XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5)) XCTAssertTrue(app.buttons["postText-post-2"].exists) } func testThreadFilterSettingsPersistAndOverride() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() app.openSettings() let override = app.switches["filterReplies"] XCTAssertTrue(override.waitForExistence(timeout: 5)) XCTAssertFalse(app.switches["filterThreadsByFollowing"].exists) XCTAssertEqual(override.value as? String, "1") override.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap() app.terminate() app.launchArguments.append("-ui-testing-preserve-defaults") app.launch() app.openSettings() XCTAssertTrue(override.waitForExistence(timeout: 5)) XCTAssertEqual(override.value as? String, "0") XCTAssertFalse(app.switches["filterThreadsByFollowing"].exists) override.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap() XCTAssertEqual(override.value as? String, "1") } func testSettingsShowsOpenSourceLicensesAndRepository() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() app.openSettings() let licenses = app.buttons["openSourceLicenses"] XCTAssertTrue(licenses.waitForExistence(timeout: 5)) XCTAssertTrue(app.links["sourceRepository"].exists || app.buttons["sourceRepository"].exists) licenses.tap() XCTAssertTrue(app.navigationBars["Open Source Licenses"].waitForExistence(timeout: 5)) XCTAssertTrue(app.staticTexts["Old Fella"].exists) XCTAssertTrue(app.staticTexts["ATProtoKit"].exists) XCTAssertTrue(app.staticTexts["swift-log"].exists) XCTAssertTrue(app.staticTexts["Copyright (c) 2026 Christopher Jr Riley"].exists) } func testAdultMediaCanBeHiddenAndShown() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-adult-media"] app.launch() let hide = app.buttons["hideMedia-post-1"] let show = app.buttons["showMedia-post-1"] XCTAssertTrue(hide.waitForExistence(timeout: 5)) hide.tap() XCTAssertTrue(show.waitForExistence(timeout: 5)) show.tap() XCTAssertTrue(hide.waitForExistence(timeout: 5)) } func testQuotedAdultMediaWarningCanBeShownAndHidden() { let app = XCUIApplication() app.launchArguments = [ "-ui-testing", "-ui-testing-signed-in", "-ui-testing-adult-media", "-ui-testing-adult-warn" ] app.launch() app.tabBars.buttons["Notifications"].tap() let show = app.buttons["showMedia-quote-post-1"].firstMatch let hide = app.buttons["hideMedia-quote-post-1"].firstMatch XCTAssertTrue(show.waitForExistence(timeout: 5)) show.tap() XCTAssertTrue(hide.waitForExistence(timeout: 5)) hide.tap() XCTAssertTrue(show.waitForExistence(timeout: 5)) } func testAdultMediaProhibitedByPreferencesHasNoReveal() { for setting in ["-ui-testing-adult-disabled", "-ui-testing-adult-hide"] { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-adult-media", setting] app.launch() XCTAssertTrue(app.buttons["postText-post-2"].waitForExistence(timeout: 5)) XCTAssertFalse(app.buttons["postText-post-1"].exists) XCTAssertFalse(app.buttons["showMedia-post-1"].exists) app.terminate() } } func testMutedWordHidesMatchingPost() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-muted-word"] app.launch() app.buttons["demoSignInButton"].tap() XCTAssertTrue(app.buttons["postText-post-2"].waitForExistence(timeout: 5)) XCTAssertFalse(app.buttons["postText-post-1"].exists) } func testTimelineHidesPostWithQuotedContentWarning() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-content-warnings"] app.launch() app.buttons["demoSignInButton"].tap() XCTAssertTrue(app.buttons["postText-post-2"].waitForExistence(timeout: 5)) XCTAssertFalse(app.buttons["postText-post-1"].exists) XCTAssertFalse(app.buttons["revealQuotedPost-warning-quote"].exists) } func testNotificationPostWarningRevealsContent() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-content-warnings", "-ui-testing-notification-warning"] app.launch() app.buttons["demoSignInButton"].tap() app.tabBars.buttons["Notifications"].tap() let reveal = app.buttons["revealQuotedPost-post-1"].firstMatch XCTAssertTrue(reveal.waitForExistence(timeout: 5)) XCTAssertFalse(app.buttons["quotedPostText-post-1"].exists) reveal.tap() XCTAssertTrue(app.buttons["quotedPostText-post-1"].firstMatch.waitForExistence(timeout: 5)) } }