@@ -10,21 +10,6 @@ final class OldskyUITests: XCTestCase { app.buttons["demoSignInButton"].tap() XCTAssertTrue(app.navigationBars["Following"].waitForExistence(timeout: 5)) XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 5)) app.buttons["postText-post-2"].tap() XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5)) XCTAssertTrue(app.buttons["postText-post-1"].exists) XCTAssertTrue(app.buttons["postText-post-2"].isHittable) XCTAssertTrue(app.descendants(matching: .any)["earlierPostsCue"].waitForExistence(timeout: 5)) app.navigationBars.buttons["Following"].tap() app.buttons["profileLink-mae"].tap() XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5)) XCTAssertTrue(app.staticTexts["Mae Rivers"].exists) app.buttons["followButton"].tap() XCTAssertTrue(app.buttons["Following"].exists) app.navigationBars.buttons["Following"].tap() app.buttons["yourProfileButton"].tap() XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5)) app.navigationBars.buttons["Following"].tap() app.tabBars.buttons["New post"].tap() let editor = app.textViews["composeTextField"] XCTAssertTrue(editor.waitForExistence(timeout: 5)) @@ -37,11 +22,45 @@ final class OldskyUITests: XCTestCase { XCTAssertTrue(createdPost.waitForExistence(timeout: 5)) } func testFollowFromProfile() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() let profile = app.buttons["profileLink-mae"].firstMatch XCTAssertTrue(profile.waitForExistence(timeout: 5)) profile.tap() XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5)) app.buttons["followButton"].tap() XCTAssertTrue(app.buttons["Following"].waitForExistence(timeout: 5)) } func testOwnProfileOpens() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() let profile = app.buttons["yourProfileButton"] XCTAssertTrue(profile.waitForExistence(timeout: 5)) profile.tap() XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5)) XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Demo Account") } func testEarlierPostsCueAppearsInThread() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() let post = app.buttons["postText-post-2"] XCTAssertTrue(post.waitForExistence(timeout: 5)) post.tap() XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5)) XCTAssertTrue(app.descendants(matching: .any)["earlierPostsCue"].waitForExistence(timeout: 5)) } func testFollowingBarRemainsVisibleWhenScrolling() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let profile = app.buttons["yourProfileButton"] XCTAssertTrue(profile.waitForExistence(timeout: 5)) app.swipeUp() @@ -52,8 +71,8 @@ final class OldskyUITests: XCTestCase { func testVideoViewerHasOneCloseButton() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-video"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let video = app.buttons["Tap here to play the video"].firstMatch XCTAssertTrue(video.waitForExistence(timeout: 5)) video.tap() @@ -68,8 +87,8 @@ final class OldskyUITests: XCTestCase { func testPostTimestampIsRelativeInFeedAndDetail() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let timestamp = app.staticTexts["postTimestamp-post-1"] XCTAssertTrue(timestamp.waitForExistence(timeout: 5)) XCTAssertLessThanOrEqual(timestamp.label.count, 4) @@ -86,8 +105,8 @@ final class OldskyUITests: XCTestCase { func testQuoteShowsOriginalAndOpensPost() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let quote = app.buttons["quotedPostLink"] for _ in 0..<5 { @@ -104,8 +123,8 @@ final class OldskyUITests: XCTestCase { func testHideQuotedPostsSetting() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() app.tabBars.buttons["Settings"].tap() let setting = app.switches["hideQuotedPosts"] XCTAssertTrue(setting.waitForExistence(timeout: 5)) @@ -130,14 +149,13 @@ final class OldskyUITests: XCTestCase { func testNotificationsAndSettingsTabs() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() XCTAssertTrue(app.tabBars.buttons["Following"].waitForExistence(timeout: 5)) app.tabBars.buttons["Notifications"].tap() XCTAssertTrue(app.navigationBars["Notifications"].waitForExistence(timeout: 5)) XCTAssertTrue(app.buttons["postText-reply-post-1"].waitForExistence(timeout: 5)) XCTAssertTrue(app.buttons.matching(NSPredicate(format: "identifier CONTAINS %@ AND label CONTAINS %@", "replyContext-post-1", "Your post Mae Rivers")).firstMatch.exists) XCTAssertTrue(app.buttons["postText-reply-post-1"].label.contains("Thanks for the thoughtful reply.")) XCTAssertFalse(app.staticTexts["Alex Kim replied to your post"].exists) let likedPost = app.buttons["notificationPost-notification-1"] @@ -145,27 +163,6 @@ final class OldskyUITests: XCTestCase { likedPost.tap() XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5)) app.navigationBars.buttons["Notifications"].tap() app.buttons["loadMoreNotificationsButton"].tap() XCTAssertTrue(app.buttons["notification-notification-4"].waitForExistence(timeout: 5)) XCTAssertTrue(app.staticTexts["Alex Kim reposted your post"].exists) XCTAssertTrue(app.buttons["notificationPost-notification-5"].exists) let quotedPostLink = app.buttons["quotedPostLink"] for _ in 0..<5 { if quotedPostLink.exists && quotedPostLink.isHittable { break } app.swipeUp() } XCTAssertTrue(quotedPostLink.exists) app.tabBars.buttons["Following"].tap() app.tabBars.buttons["Notifications"].tap() let replyPost = app.buttons["postText-reply-post-1"] for _ in 0..<5 { if replyPost.exists && replyPost.isHittable { break } app.swipeDown() } app.buttons["postText-reply-post-1"].tap() XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5)) app.navigationBars.buttons["Notifications"].tap() app.tabBars.buttons["Settings"].tap() XCTAssertTrue(app.navigationBars["Settings"].waitForExistence(timeout: 5)) XCTAssertTrue(app.staticTexts["settingsDisplayName"].exists) @@ -175,31 +172,106 @@ final class OldskyUITests: XCTestCase { XCTAssertTrue(app.staticTexts["Sign in to Bluesky"].waitForExistence(timeout: 5)) } func testNotificationAvatarsOpenProfiles() { func testNotificationReplyShowsContextAndOpensReply() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() app.buttons["demoSignInButton"].tap() app.tabBars.buttons["Notifications"].tap() let reply = app.buttons["postText-reply-post-1"] XCTAssertTrue(reply.waitForExistence(timeout: 5)) let context = app.descendants(matching: .any)["replyContext-post-1"].firstMatch XCTAssertTrue(context.waitForExistence(timeout: 5)) XCTAssertTrue(context.label.contains("Morning walk along the water.")) XCTAssertTrue(app.buttons.matching(NSPredicate(format: "label CONTAINS %@", "Thread started by Mae Rivers")).firstMatch.exists) reply.tap() XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5)) XCTAssertTrue(app.buttons["postText-reply-post-1"].waitForExistence(timeout: 5)) } let actorAvatar = app.buttons["notificationAvatar-notification-1"] XCTAssertTrue(actorAvatar.waitForExistence(timeout: 5)) actorAvatar.tap() XCTAssertTrue(app.navigationBars["Profile"].waitForExistence(timeout: 5)) func testNotificationReplyParentAvatarOpensProfile() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() app.tabBars.buttons["Notifications"].tap() let avatar = app.buttons["notificationReplyAvatar-post-1"] XCTAssertTrue(avatar.waitForExistence(timeout: 5)) avatar.tap() XCTAssertTrue(app.staticTexts["profileDisplayName"].waitForExistence(timeout: 5)) XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Mae Rivers") app.navigationBars.buttons["Notifications"].tap() } app.buttons["notificationPostAvatar-post-1"].tap() XCTAssertTrue(app.navigationBars["Profile"].waitForExistence(timeout: 5)) XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Mae Rivers") app.navigationBars.buttons["Notifications"].tap() func testNotificationReplyShowsOwnParentAuthor() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in", "-ui-testing-own-reply-parent"] app.launch() app.tabBars.buttons["Notifications"].tap() let context = app.descendants(matching: .any)["replyContext-own-parent"].firstMatch XCTAssertTrue(context.waitForExistence(timeout: 5)) XCTAssertTrue(context.label.contains("A post by the signed-in account.")) XCTAssertTrue(app.buttons.matching(NSPredicate(format: "label CONTAINS %@", "Thread started by Demo Account")).firstMatch.exists) } func testNotificationReplyRespectsHiddenContextSetting() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() app.tabBars.buttons["Settings"].tap() let setting = app.switches["hideReplyContexts"] XCTAssertTrue(setting.waitForExistence(timeout: 5)) setting.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.5)).tap() app.tabBars.buttons["Notifications"].tap() let link = app.buttons["replyContextLink-reply-post-1"] XCTAssertTrue(link.waitForExistence(timeout: 5)) XCTAssertTrue(link.label.contains("In reply to Mae Rivers")) XCTAssertFalse(app.descendants(matching: .any)["replyContext-post-1"].exists) link.tap() XCTAssertTrue(app.navigationBars["Post"].waitForExistence(timeout: 5)) XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 5)) } func testNotificationPaginationShowsRepostAndQuote() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() app.tabBars.buttons["Notifications"].tap() let more = app.buttons["loadMoreNotificationsButton"] XCTAssertTrue(more.waitForExistence(timeout: 5)) more.tap() let repost = app.buttons["notificationPost-notification-5"] for _ in 0..<5 { if repost.exists { break } app.swipeUp() } XCTAssertTrue(repost.waitForExistence(timeout: 5)) XCTAssertTrue(repost.label.hasPrefix("Your post")) let quote = app.buttons["quotedPostLink"] for _ in 0..<5 { if quote.exists && quote.isHittable { break } app.swipeUp() } XCTAssertTrue(quote.waitForExistence(timeout: 5)) } app.buttons["notificationReplyAvatar-post-1"].tap() func testLikeNotificationAvatarOpensProfile() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() app.tabBars.buttons["Notifications"].tap() let avatar = app.buttons["notificationAvatar-notification-1"] XCTAssertTrue(avatar.waitForExistence(timeout: 5)) avatar.tap() XCTAssertTrue(app.navigationBars["Profile"].waitForExistence(timeout: 5)) XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Mae Rivers") app.navigationBars.buttons["Notifications"].tap() } app.buttons["notificationAvatar-notification-3"].tap() func testFollowNotificationAvatarOpensProfile() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-signed-in"] app.launch() app.tabBars.buttons["Notifications"].tap() let avatar = app.buttons["notificationAvatar-notification-3"] XCTAssertTrue(avatar.waitForExistence(timeout: 5)) avatar.tap() XCTAssertTrue(app.navigationBars["Profile"].waitForExistence(timeout: 5)) XCTAssertEqual(app.staticTexts["profileDisplayName"].label, "Sam Lee") } @@ -207,8 +279,8 @@ final class OldskyUITests: XCTestCase { func testMentionShowsFullPostAndActions() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() XCTAssertTrue(app.tabBars.buttons["Notifications"].waitForExistence(timeout: 5)) app.tabBars.buttons["Notifications"].tap() let loadMore = app.buttons["loadMoreNotificationsButton"] @@ -253,8 +325,8 @@ final class OldskyUITests: XCTestCase { func testTappedPostKeepsScreenPositionWhenThreadLoads() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-thread-delay"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let timelinePost = app.buttons["postText-post-2"] XCTAssertTrue(timelinePost.waitForExistence(timeout: 5)) timelinePost.tap() @@ -286,8 +358,8 @@ final class OldskyUITests: XCTestCase { func testThreadAuthorStaysBelowTopBarWithImmediateResponse() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let timelinePost = app.buttons["postText-post-2"] XCTAssertTrue(timelinePost.waitForExistence(timeout: 5)) timelinePost.tap() @@ -309,8 +381,8 @@ final class OldskyUITests: XCTestCase { func testProfileLoadsMorePostsOnlyAfterExplicitTap() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let avatar = app.buttons["profileLink-mae"].firstMatch XCTAssertTrue(avatar.waitForExistence(timeout: 5)) avatar.tap() @@ -334,8 +406,8 @@ final class OldskyUITests: XCTestCase { func testProfileReplyShowsCompactParentPostAndOpensProfile() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let profile = app.buttons["profileLink-alex"].firstMatch XCTAssertTrue(profile.waitForExistence(timeout: 5)) profile.tap() @@ -353,8 +425,8 @@ final class OldskyUITests: XCTestCase { func testHideReplyContextSetting() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let parent = app.descendants(matching: .any)["replyPostContext-post-1"].firstMatch XCTAssertTrue(parent.waitForExistence(timeout: 5)) @@ -382,8 +454,8 @@ final class OldskyUITests: XCTestCase { func testFollowingReplyContextOpensRootPost() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let parent = app.descendants(matching: .any)["replyPostContext-post-1"].firstMatch for _ in 0..<5 { if parent.exists && parent.isHittable { break } @@ -400,8 +472,8 @@ final class OldskyUITests: XCTestCase { func testReplyContextFacetsNavigateAndPlainTextOpensRootPost() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-facets"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let context = app.descendants(matching: .any)["replyContext-post-1"].firstMatch for _ in 0..<5 { @@ -434,8 +506,8 @@ final class OldskyUITests: XCTestCase { func testQuotedPostFacetsNavigateAndPlainTextOpensQuotedPost() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-facets"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let quoteText = app.descendants(matching: .any)["quotedPostText-post-2"].firstMatch for _ in 0..<6 { @@ -468,8 +540,8 @@ final class OldskyUITests: XCTestCase { func testFollowingReplyContextUsesMissingGapRow() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-reply-branches"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let gap = app.descendants(matching: .any)["missingReplyContext"].firstMatch for _ in 0..<5 { if gap.exists && gap.isHittable { break } @@ -483,8 +555,8 @@ final class OldskyUITests: XCTestCase { func testProfileReplyUsesFeedGapRow() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-reply-branches"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let profile = app.buttons["profileLink-alex"].firstMatch XCTAssertTrue(profile.waitForExistence(timeout: 5)) profile.tap() @@ -497,8 +569,8 @@ final class OldskyUITests: XCTestCase { func testProfilePostsShareTimelineActionsAndNavigation() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let avatar = app.buttons["profileLink-mae"].firstMatch XCTAssertTrue(avatar.waitForExistence(timeout: 5)) avatar.tap() @@ -525,8 +597,8 @@ final class OldskyUITests: XCTestCase { func testReplyBranchesShowNestedRepliesAndOpenThem() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-reply-branches"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let rootPost = app.buttons["postText-post-1"] XCTAssertTrue(rootPost.waitForExistence(timeout: 5)) rootPost.tap() @@ -551,11 +623,15 @@ final class OldskyUITests: XCTestCase { func testFeedLoadsNextPageOnlyAfterExplicitTap() { let app = XCUIApplication() app.launchArguments = ["-ui-testing"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 5)) XCTAssertFalse(app.buttons["postText-post-4"].exists) let loadMoreButton = app.buttons["loadMorePostsButton"] for _ in 0..<5 { if loadMoreButton.exists && loadMoreButton.isHittable { break } app.swipeUp() } XCTAssertTrue(loadMoreButton.waitForExistence(timeout: 5)) loadMoreButton.tap() XCTAssertTrue(app.buttons["postText-post-4"].waitForExistence(timeout: 5)) @@ -565,10 +641,10 @@ final class OldskyUITests: XCTestCase { func testSingleImageTileFillsItsSpaceAndViewerImageFitsViewport() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "1"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let grid = app.descendants(matching: .any)["postImageGrid"] let grid = app.cells.containing(.button, identifier: "postText-post-1").firstMatch.descendants(matching: .any)["postImageGrid"] XCTAssertTrue(grid.waitForExistence(timeout: 5)) let gridImage = grid.images["Attached image"] XCTAssertTrue(gridImage.waitForExistence(timeout: 5)) @@ -599,8 +675,8 @@ final class OldskyUITests: XCTestCase { private func assertReplyImages(count: Int) { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "\(count)"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let context = app.descendants(matching: .any)["replyPostContext-post-1"].firstMatch XCTAssertTrue(context.waitForExistence(timeout: 5)) let grid = context.descendants(matching: .any)["postImageGrid"].firstMatch @@ -640,9 +716,9 @@ final class OldskyUITests: XCTestCase { func testPostImageShowMoreAndFewer() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "5"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let grid = app.descendants(matching: .any)["postImageGrid"].firstMatch let grid = app.cells.containing(.button, identifier: "postText-post-1").firstMatch.descendants(matching: .any)["postImageGrid"].firstMatch XCTAssertTrue(grid.waitForExistence(timeout: 5)) let button = grid.buttons["showMoreImagesButton"] XCTAssertTrue(button.waitForExistence(timeout: 5)) @@ -658,10 +734,10 @@ final class OldskyUITests: XCTestCase { func testImageViewerOpensSelectedImageZoomsAndDismisses() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "3"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let grid = app.descendants(matching: .any)["postImageGrid"] let grid = app.cells.containing(.button, identifier: "postText-post-1").firstMatch.descendants(matching: .any)["postImageGrid"] XCTAssertTrue(grid.waitForExistence(timeout: 5)) let selectedGridImage = grid.images["Attached image 2 of 3"].firstMatch XCTAssertTrue(selectedGridImage.waitForExistence(timeout: 5)) @@ -692,10 +768,10 @@ final class OldskyUITests: XCTestCase { func testImageViewerSwipesBetweenImages() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "3"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let grid = app.descendants(matching: .any)["postImageGrid"].firstMatch let grid = app.cells.containing(.button, identifier: "postText-post-1").firstMatch.descendants(matching: .any)["postImageGrid"].firstMatch XCTAssertTrue(grid.waitForExistence(timeout: 5)) grid.images["Attached image 2 of 3"].firstMatch.tap() @@ -719,9 +795,9 @@ final class OldskyUITests: XCTestCase { func testImageViewerShowsDescriptionWithButton() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "1"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let grid = app.descendants(matching: .any)["postImageGrid"].firstMatch let grid = app.cells.containing(.button, identifier: "postText-post-1").firstMatch.descendants(matching: .any)["postImageGrid"].firstMatch XCTAssertTrue(grid.waitForExistence(timeout: 5)) grid.images["Attached image"].firstMatch.tap() let image = app.descendants(matching: .any)["imageViewerImage"].firstMatch @@ -739,10 +815,10 @@ final class OldskyUITests: XCTestCase { func testImageViewerShortDownwardDragKeepsViewerOpen() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "1"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let grid = app.descendants(matching: .any)["postImageGrid"] let grid = app.cells.containing(.button, identifier: "postText-post-1").firstMatch.descendants(matching: .any)["postImageGrid"] XCTAssertTrue(grid.waitForExistence(timeout: 5)) grid.images["Attached image"].tap() @@ -762,10 +838,10 @@ final class OldskyUITests: XCTestCase { func testImageViewerZoomAndPanStayOpen() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "3"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let grid = app.descendants(matching: .any)["postImageGrid"] let grid = app.cells.containing(.button, identifier: "postText-post-1").firstMatch.descendants(matching: .any)["postImageGrid"] XCTAssertTrue(grid.waitForExistence(timeout: 5)) grid.images["Attached image 2 of 3"].firstMatch.tap() @@ -790,10 +866,10 @@ final class OldskyUITests: XCTestCase { func testImageViewerDownwardFlickDismisses() { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "1"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let grid = app.descendants(matching: .any)["postImageGrid"] let grid = app.cells.containing(.button, identifier: "postText-post-1").firstMatch.descendants(matching: .any)["postImageGrid"] XCTAssertTrue(grid.waitForExistence(timeout: 5)) grid.images["Attached image"].tap() @@ -832,12 +908,18 @@ final class OldskyUITests: XCTestCase { private func assertImageGrid(imageCount: Int, expectedColumnCount: Int) { let app = XCUIApplication() app.launchArguments = ["-ui-testing", "-ui-testing-image-grid", "\(imageCount)"] app.launchArguments.append("-ui-testing-signed-in") app.launch() app.buttons["demoSignInButton"].tap() let grid = app.descendants(matching: .any)["postImageGrid"] let grid = app.cells.containing(.button, identifier: "postText-post-1").firstMatch.descendants(matching: .any)["postImageGrid"] XCTAssertTrue(grid.waitForExistence(timeout: 5)) XCTAssertTrue(app.buttons["postText-post-1"].waitForExistence(timeout: 5)) if imageCount > 4 { let more = grid.buttons["showMoreImagesButton"] XCTAssertTrue(more.waitForExistence(timeout: 5)) more.tap() XCTAssertEqual(more.label, "Show fewer images") } let images = (1...imageCount).map { index in let imageLabel = imageCount == 1 ? "Attached image" : "Attached image \(index) of \(imageCount)" @@ -852,7 +934,8 @@ final class OldskyUITests: XCTestCase { XCTAssertLessThanOrEqual(image.frame.maxX, grid.frame.maxX + 1) XCTAssertLessThanOrEqual(image.frame.maxY, grid.frame.maxY + 1) } XCTAssertEqual(grid.images.count, imageCount) let attachedImages = grid.images.matching(NSPredicate(format: "label BEGINSWITH %@", "Attached image")) XCTAssertEqual(attachedImages.count, imageCount) let firstRowY = images[0].frame.minY let firstRowCount = images.filter { abs($0.frame.minY - firstRowY) < 2 }.count