Skip to content

GT Update UITests to use waitForExistence on all screen checks #2616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions godtools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,6 @@
45DE9ACE287865DB004E3AE0 /* OptInOnboardingBannerEnabledCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DE9ACD287865DB004E3AE0 /* OptInOnboardingBannerEnabledCache.swift */; };
45DEF22E2576A6A20007AC64 /* learn_to_share_tool_with_anyone.json in Resources */ = {isa = PBXBuildFile; fileRef = 45DEF22D2576A6A20007AC64 /* learn_to_share_tool_with_anyone.json */; };
45DEF4DC2AE95237000C8F4B /* UIViewController+AccessibilityScreenId.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DEF4DB2AE95237000C8F4B /* UIViewController+AccessibilityScreenId.swift */; };
45DEF4DE2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DEF4DD2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift */; };
45DF34522A28D41600BB717E /* AppBuild.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DF34512A28D41500BB717E /* AppBuild.swift */; };
45DF34542A28D41E00BB717E /* AppEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DF34532A28D41E00BB717E /* AppEnvironment.swift */; };
45DF96492D386C1C00C6AE68 /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = 45DF96482D386C1C00C6AE68 /* FirebaseAnalytics */; };
Expand Down Expand Up @@ -3065,7 +3064,6 @@
45DEF4BB24DEF6E700996695 /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = "<group>"; };
45DEF4BC24DEF6FA00996695 /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = "<group>"; };
45DEF4DB2AE95237000C8F4B /* UIViewController+AccessibilityScreenId.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+AccessibilityScreenId.swift"; sourceTree = "<group>"; };
45DEF4DD2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+AssertScreenDoesNotExist.swift"; sourceTree = "<group>"; };
45DF34512A28D41500BB717E /* AppBuild.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppBuild.swift; sourceTree = "<group>"; };
45DF34532A28D41E00BB717E /* AppEnvironment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppEnvironment.swift; sourceTree = "<group>"; };
45E066C32AE16796004393CD /* OnboardingTutorialViewedUserDefaultsCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingTutorialViewedUserDefaultsCache.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -8279,7 +8277,6 @@
45A415F12A99429B0030E2C7 /* Extensions */ = {
isa = PBXGroup;
children = (
45DEF4DD2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift */,
45A415F22A99429B0030E2C7 /* XCUIApplication+Query.swift */,
);
path = Extensions;
Expand Down Expand Up @@ -13191,7 +13188,6 @@
451F1EE42CD3B38B006CCF4E /* LaunchEnvironmentReader.swift in Sources */,
45FBE5722AB8A33200BFBE92 /* AccessibilityStrings.swift in Sources */,
45D318F12AE6F9D300D74A87 /* LanguageCodeDomainModel.swift in Sources */,
45DEF4DE2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift in Sources */,
4585E4B82B05895200223A9B /* BCP47LanguageIdentifier.swift in Sources */,
45DC19152BB5B33F007542A5 /* ChooseAppLanguageFlowTests.swift in Sources */,
451CF5952C4AAC5500CD65C4 /* AppFlowTests.swift in Sources */,
Expand Down
22 changes: 10 additions & 12 deletions godtoolsUITests/App/Flows/App/AppFlowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import XCTest
@testable import godtools

class AppFlowTests: BaseFlowTests {

static let defaultWaitForScreenExistence: TimeInterval = 2


private func launchAppToDashboardFavorites() {

super.launchApp(
Expand All @@ -37,7 +35,7 @@ class AppFlowTests: BaseFlowTests {

menuButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .menu)
assertIfScreenDoesNotExist(screenAccessibility: .menu)
}
}

Expand All @@ -53,7 +51,7 @@ extension AppFlowTests {

tab.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: dashboardScreenAccessibility, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: dashboardScreenAccessibility)
}

private func tabToLessons() {
Expand Down Expand Up @@ -118,7 +116,7 @@ extension AppFlowTests {

toolDetails.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolDetails, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: .toolDetails)
}

func testToolDetailsNavigatesBackToFavoritesWhenOpenedFromFavorites() {
Expand All @@ -133,15 +131,15 @@ extension AppFlowTests {

toolDetails.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolDetails)
assertIfScreenDoesNotExist(screenAccessibility: .toolDetails)

let toolDetailsNavBack = app.queryButton(buttonAccessibility: .toolDetailsNavBack)

XCTAssertTrue(toolDetailsNavBack.exists)

toolDetailsNavBack.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .dashboardFavorites, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: .dashboardFavorites)
}
}

Expand All @@ -161,7 +159,7 @@ extension AppFlowTests {

toolsCategoryFilter.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolsCategoryFilters)
assertIfScreenDoesNotExist(screenAccessibility: .toolsCategoryFilters)
}

func testTappingToolsLanguageFilterOpensToolsLanguageFiltersList() {
Expand All @@ -176,7 +174,7 @@ extension AppFlowTests {

toolsLanguageFilter.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolsLanguageFilters)
assertIfScreenDoesNotExist(screenAccessibility: .toolsLanguageFilters)
}

func testTappingSpotlightToolFromToolsOpensToolDetails() {
Expand All @@ -196,7 +194,7 @@ extension AppFlowTests {

spotlightTool.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolDetails)
assertIfScreenDoesNotExist(screenAccessibility: .toolDetails)
}

func testTappingToolFromToolsOpensToolDetails() {
Expand All @@ -216,6 +214,6 @@ extension AppFlowTests {

tool.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolDetails)
assertIfScreenDoesNotExist(screenAccessibility: .toolDetails)
}
}
13 changes: 10 additions & 3 deletions godtoolsUITests/App/Flows/BaseFlowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import XCTest

class BaseFlowTests: XCTestCase {

private static let defaultWaitForScreenExistence: TimeInterval = 2

private(set) var app: XCUIApplication = XCUIApplication()
private(set) var flowDeepLinkUrl: String = ""
private(set) var initialScreen: AccessibilityStrings.Screen?
Expand Down Expand Up @@ -45,18 +47,23 @@ class BaseFlowTests: XCTestCase {

app.launch()

assertIfInitialScreenDoesntExist(app: app)
assertIfInitialScreenDoesntExist()
}

func assertIfInitialScreenDoesntExist(app: XCUIApplication) {
func assertIfInitialScreenDoesntExist() {

if let initialScreen = initialScreen {

assertIfScreenDoesNotExist(app: app, screenAccessibility: initialScreen, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: initialScreen)
}
else {

XCTAssertNotNil(initialScreen)
}
}

func assertIfScreenDoesNotExist(screenAccessibility: AccessibilityStrings.Screen) {

XCTAssertTrue(app.staticTexts[screenAccessibility.id].waitForExistence(timeout: Self.defaultWaitForScreenExistence))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ class ChooseAppLanguageFlowTests: BaseFlowTests {

firstAppLanguageListItem.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .confirmAppLanguage)
assertIfScreenDoesNotExist(screenAccessibility: .confirmAppLanguage)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LanguageSettingsFlowTests: BaseFlowTests {

launchApp()

super.assertIfInitialScreenDoesntExist(app: app)
super.assertIfInitialScreenDoesntExist()
}

func testNavigationToAppLanguagesList() {
Expand All @@ -47,7 +47,7 @@ class LanguageSettingsFlowTests: BaseFlowTests {

chooseAppLanguageButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .appLanguages)
assertIfScreenDoesNotExist(screenAccessibility: .appLanguages)
}

func testNavigationToDownloadableLanguagesList() {
Expand All @@ -60,6 +60,6 @@ class LanguageSettingsFlowTests: BaseFlowTests {

editDownloadedLanguagesButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .downloadableLanguages)
assertIfScreenDoesNotExist(screenAccessibility: .downloadableLanguages)
}
}
30 changes: 15 additions & 15 deletions godtoolsUITests/App/Flows/Menu/MenuFlowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MenuFlowTests: BaseFlowTests {

launchApp()

super.assertIfInitialScreenDoesntExist(app: app)
super.assertIfInitialScreenDoesntExist()
}

func testNavigationToMenu() {
Expand All @@ -42,7 +42,7 @@ class MenuFlowTests: BaseFlowTests {

menuButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .menu, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: .menu)
}

func testNavigationToTutorial() {
Expand All @@ -57,7 +57,7 @@ class MenuFlowTests: BaseFlowTests {

tutorialButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .tutorial)
assertIfScreenDoesNotExist(screenAccessibility: .tutorial)
}

func testNavigationToLanguageSettings() {
Expand All @@ -72,7 +72,7 @@ class MenuFlowTests: BaseFlowTests {

languageSettingsButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .languageSettings)
assertIfScreenDoesNotExist(screenAccessibility: .languageSettings)
}

func testNavigationToCreateAccount() {
Expand All @@ -87,7 +87,7 @@ class MenuFlowTests: BaseFlowTests {

createAccountButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .createAccount)
assertIfScreenDoesNotExist(screenAccessibility: .createAccount)
}

func testNavigationToLogin() {
Expand All @@ -102,7 +102,7 @@ class MenuFlowTests: BaseFlowTests {

loginButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .login)
assertIfScreenDoesNotExist(screenAccessibility: .login)
}

func testNavigationToSendFeedback() {
Expand All @@ -117,7 +117,7 @@ class MenuFlowTests: BaseFlowTests {

sendFeedbackButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .sendFeedback, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: .sendFeedback)
}

func testNavigationToReportABug() {
Expand All @@ -132,7 +132,7 @@ class MenuFlowTests: BaseFlowTests {

reportABugButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .reportABug)
assertIfScreenDoesNotExist(screenAccessibility: .reportABug)
}

func testNavigationToAskAQuestion() {
Expand All @@ -147,7 +147,7 @@ class MenuFlowTests: BaseFlowTests {

askAQuestionButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .askAQuestion)
assertIfScreenDoesNotExist(screenAccessibility: .askAQuestion)
}

// func testNavigationToLeaveAReview() {
Expand All @@ -162,7 +162,7 @@ class MenuFlowTests: BaseFlowTests {
//
// leaveAReviewButton.tap()
//
// assertIfScreenDoesNotExist(app: app, screenAccessibility: .leaveAReview)
// assertIfScreenDoesNotExist(screenAccessibility: .leaveAReview)
// }

func testNavigationToShareAStoryWithUs() {
Expand All @@ -177,7 +177,7 @@ class MenuFlowTests: BaseFlowTests {

askAQuestionButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .shareAStoryWithUs)
assertIfScreenDoesNotExist(screenAccessibility: .shareAStoryWithUs)
}

// func testNavigationToShareGodTools() {
Expand All @@ -192,7 +192,7 @@ class MenuFlowTests: BaseFlowTests {
//
// shareGodToolsButton.tap()
//
// assertIfScreenDoesNotExist(app: app, screenAccessibility: .shareGodTools, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
// assertIfScreenDoesNotExist(screenAccessibility: .shareGodTools)
// }

func testNavigationToTermsOfUse() {
Expand All @@ -207,7 +207,7 @@ class MenuFlowTests: BaseFlowTests {

termsOfUseButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .termsOfUse)
assertIfScreenDoesNotExist(screenAccessibility: .termsOfUse)
}

func testNavigationToPrivacyPolicy() {
Expand All @@ -222,7 +222,7 @@ class MenuFlowTests: BaseFlowTests {

privacyPolicyButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .privacyPolicy)
assertIfScreenDoesNotExist(screenAccessibility: .privacyPolicy)
}

func testNavigationToCopyrightInfo() {
Expand All @@ -237,6 +237,6 @@ class MenuFlowTests: BaseFlowTests {

copyrightInfoButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .copyrightInfo)
assertIfScreenDoesNotExist(screenAccessibility: .copyrightInfo)
}
}
18 changes: 9 additions & 9 deletions godtoolsUITests/App/Flows/Onboarding/OnboardingFlowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class OnboardingFlowTests: BaseFlowTests {

chooseAppLanguageButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .appLanguages)
assertIfScreenDoesNotExist(screenAccessibility: .appLanguages)
}

func testNavigationToWatchOnboardingVideoTutorialAndNavigationBackToOnboardingTutorial() {
Expand All @@ -63,7 +63,7 @@ class OnboardingFlowTests: BaseFlowTests {
watchVideoButton.tap()

// Adding waitForExistence I believe helped with the fact this view is presented with an animation. ~Levi
assertIfScreenDoesNotExist(app: app, screenAccessibility: .watchOnboardingTutorialVideo, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: .watchOnboardingTutorialVideo)
}

private func navigateBackToOnboardingTutorialFromWatchOnboardingTutorialVideo(app: XCUIApplication) {
Expand All @@ -74,7 +74,7 @@ class OnboardingFlowTests: BaseFlowTests {

closeVideoButton.tap()

super.assertIfInitialScreenDoesntExist(app: app)
super.assertIfInitialScreenDoesntExist()
}

func testNavigationThroughTutorialPagesUsingNextTutorialPageButton() {
Expand All @@ -85,19 +85,19 @@ class OnboardingFlowTests: BaseFlowTests {

XCTAssertTrue(nextTutorialPageButton.exists)

assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage1, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage1)

nextTutorialPageButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage2, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage2)

nextTutorialPageButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage3, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage3)

nextTutorialPageButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage4, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage4)
}

func testSkippingOnboardingNavigatesToDashboardFavorites() {
Expand All @@ -108,7 +108,7 @@ class OnboardingFlowTests: BaseFlowTests {

XCTAssertTrue(nextTutorialPageButton.exists)

assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage1)
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage1)

nextTutorialPageButton.tap()

Expand All @@ -118,6 +118,6 @@ class OnboardingFlowTests: BaseFlowTests {

skipTutorialButton.tap()

assertIfScreenDoesNotExist(app: app, screenAccessibility: .dashboardFavorites)
assertIfScreenDoesNotExist(screenAccessibility: .dashboardFavorites)
}
}
Loading
Loading