Skip to content

Commit acfa465

Browse files
Merge pull request #2616 from CruGlobal/GT-fix-ui-tests
GT Update UITests to use waitForExistence on all screen checks
2 parents 3d61b5a + ea8f032 commit acfa465

File tree

8 files changed

+48
-79
lines changed

8 files changed

+48
-79
lines changed

godtools.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,6 @@
13051305
45DE9ACE287865DB004E3AE0 /* OptInOnboardingBannerEnabledCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DE9ACD287865DB004E3AE0 /* OptInOnboardingBannerEnabledCache.swift */; };
13061306
45DEF22E2576A6A20007AC64 /* learn_to_share_tool_with_anyone.json in Resources */ = {isa = PBXBuildFile; fileRef = 45DEF22D2576A6A20007AC64 /* learn_to_share_tool_with_anyone.json */; };
13071307
45DEF4DC2AE95237000C8F4B /* UIViewController+AccessibilityScreenId.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DEF4DB2AE95237000C8F4B /* UIViewController+AccessibilityScreenId.swift */; };
1308-
45DEF4DE2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DEF4DD2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift */; };
13091308
45DF34522A28D41600BB717E /* AppBuild.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DF34512A28D41500BB717E /* AppBuild.swift */; };
13101309
45DF34542A28D41E00BB717E /* AppEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DF34532A28D41E00BB717E /* AppEnvironment.swift */; };
13111310
45DF96492D386C1C00C6AE68 /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = 45DF96482D386C1C00C6AE68 /* FirebaseAnalytics */; };
@@ -3065,7 +3064,6 @@
30653064
45DEF4BB24DEF6E700996695 /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = "<group>"; };
30663065
45DEF4BC24DEF6FA00996695 /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = "<group>"; };
30673066
45DEF4DB2AE95237000C8F4B /* UIViewController+AccessibilityScreenId.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+AccessibilityScreenId.swift"; sourceTree = "<group>"; };
3068-
45DEF4DD2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+AssertScreenDoesNotExist.swift"; sourceTree = "<group>"; };
30693067
45DF34512A28D41500BB717E /* AppBuild.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppBuild.swift; sourceTree = "<group>"; };
30703068
45DF34532A28D41E00BB717E /* AppEnvironment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppEnvironment.swift; sourceTree = "<group>"; };
30713069
45E066C32AE16796004393CD /* OnboardingTutorialViewedUserDefaultsCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingTutorialViewedUserDefaultsCache.swift; sourceTree = "<group>"; };
@@ -8279,7 +8277,6 @@
82798277
45A415F12A99429B0030E2C7 /* Extensions */ = {
82808278
isa = PBXGroup;
82818279
children = (
8282-
45DEF4DD2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift */,
82838280
45A415F22A99429B0030E2C7 /* XCUIApplication+Query.swift */,
82848281
);
82858282
path = Extensions;
@@ -13191,7 +13188,6 @@
1319113188
451F1EE42CD3B38B006CCF4E /* LaunchEnvironmentReader.swift in Sources */,
1319213189
45FBE5722AB8A33200BFBE92 /* AccessibilityStrings.swift in Sources */,
1319313190
45D318F12AE6F9D300D74A87 /* LanguageCodeDomainModel.swift in Sources */,
13194-
45DEF4DE2AE9538C000C8F4B /* XCTestCase+AssertScreenDoesNotExist.swift in Sources */,
1319513191
4585E4B82B05895200223A9B /* BCP47LanguageIdentifier.swift in Sources */,
1319613192
45DC19152BB5B33F007542A5 /* ChooseAppLanguageFlowTests.swift in Sources */,
1319713193
451CF5952C4AAC5500CD65C4 /* AppFlowTests.swift in Sources */,

godtoolsUITests/App/Flows/App/AppFlowTests.swift

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import XCTest
1111
@testable import godtools
1212

1313
class AppFlowTests: BaseFlowTests {
14-
15-
static let defaultWaitForScreenExistence: TimeInterval = 2
16-
14+
1715
private func launchAppToDashboardFavorites() {
1816

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

3836
menuButton.tap()
3937

40-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .menu)
38+
assertIfScreenDoesNotExist(screenAccessibility: .menu)
4139
}
4240
}
4341

@@ -53,7 +51,7 @@ extension AppFlowTests {
5351

5452
tab.tap()
5553

56-
assertIfScreenDoesNotExist(app: app, screenAccessibility: dashboardScreenAccessibility, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
54+
assertIfScreenDoesNotExist(screenAccessibility: dashboardScreenAccessibility)
5755
}
5856

5957
private func tabToLessons() {
@@ -118,7 +116,7 @@ extension AppFlowTests {
118116

119117
toolDetails.tap()
120118

121-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolDetails, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
119+
assertIfScreenDoesNotExist(screenAccessibility: .toolDetails)
122120
}
123121

124122
func testToolDetailsNavigatesBackToFavoritesWhenOpenedFromFavorites() {
@@ -133,15 +131,15 @@ extension AppFlowTests {
133131

134132
toolDetails.tap()
135133

136-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolDetails)
134+
assertIfScreenDoesNotExist(screenAccessibility: .toolDetails)
137135

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

140138
XCTAssertTrue(toolDetailsNavBack.exists)
141139

142140
toolDetailsNavBack.tap()
143141

144-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .dashboardFavorites, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
142+
assertIfScreenDoesNotExist(screenAccessibility: .dashboardFavorites)
145143
}
146144
}
147145

@@ -161,7 +159,7 @@ extension AppFlowTests {
161159

162160
toolsCategoryFilter.tap()
163161

164-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolsCategoryFilters)
162+
assertIfScreenDoesNotExist(screenAccessibility: .toolsCategoryFilters)
165163
}
166164

167165
func testTappingToolsLanguageFilterOpensToolsLanguageFiltersList() {
@@ -176,7 +174,7 @@ extension AppFlowTests {
176174

177175
toolsLanguageFilter.tap()
178176

179-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolsLanguageFilters)
177+
assertIfScreenDoesNotExist(screenAccessibility: .toolsLanguageFilters)
180178
}
181179

182180
func testTappingSpotlightToolFromToolsOpensToolDetails() {
@@ -196,7 +194,7 @@ extension AppFlowTests {
196194

197195
spotlightTool.tap()
198196

199-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolDetails)
197+
assertIfScreenDoesNotExist(screenAccessibility: .toolDetails)
200198
}
201199

202200
func testTappingToolFromToolsOpensToolDetails() {
@@ -216,6 +214,6 @@ extension AppFlowTests {
216214

217215
tool.tap()
218216

219-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .toolDetails)
217+
assertIfScreenDoesNotExist(screenAccessibility: .toolDetails)
220218
}
221219
}

godtoolsUITests/App/Flows/BaseFlowTests.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import XCTest
1212

1313
class BaseFlowTests: XCTestCase {
1414

15+
private static let defaultWaitForScreenExistence: TimeInterval = 2
16+
1517
private(set) var app: XCUIApplication = XCUIApplication()
1618
private(set) var flowDeepLinkUrl: String = ""
1719
private(set) var initialScreen: AccessibilityStrings.Screen?
@@ -45,18 +47,23 @@ class BaseFlowTests: XCTestCase {
4547

4648
app.launch()
4749

48-
assertIfInitialScreenDoesntExist(app: app)
50+
assertIfInitialScreenDoesntExist()
4951
}
5052

51-
func assertIfInitialScreenDoesntExist(app: XCUIApplication) {
53+
func assertIfInitialScreenDoesntExist() {
5254

5355
if let initialScreen = initialScreen {
5456

55-
assertIfScreenDoesNotExist(app: app, screenAccessibility: initialScreen, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
57+
assertIfScreenDoesNotExist(screenAccessibility: initialScreen)
5658
}
5759
else {
5860

5961
XCTAssertNotNil(initialScreen)
6062
}
6163
}
64+
65+
func assertIfScreenDoesNotExist(screenAccessibility: AccessibilityStrings.Screen) {
66+
67+
XCTAssertTrue(app.staticTexts[screenAccessibility.id].waitForExistence(timeout: Self.defaultWaitForScreenExistence))
68+
}
6269
}

godtoolsUITests/App/Flows/ChooseAppLanguage/ChooseAppLanguageFlowTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ class ChooseAppLanguageFlowTests: BaseFlowTests {
3535

3636
firstAppLanguageListItem.tap()
3737

38-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .confirmAppLanguage)
38+
assertIfScreenDoesNotExist(screenAccessibility: .confirmAppLanguage)
3939
}
4040
}

godtoolsUITests/App/Flows/LanguageSettings/LanguageSettingsFlowTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class LanguageSettingsFlowTests: BaseFlowTests {
3434

3535
launchApp()
3636

37-
super.assertIfInitialScreenDoesntExist(app: app)
37+
super.assertIfInitialScreenDoesntExist()
3838
}
3939

4040
func testNavigationToAppLanguagesList() {
@@ -47,7 +47,7 @@ class LanguageSettingsFlowTests: BaseFlowTests {
4747

4848
chooseAppLanguageButton.tap()
4949

50-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .appLanguages)
50+
assertIfScreenDoesNotExist(screenAccessibility: .appLanguages)
5151
}
5252

5353
func testNavigationToDownloadableLanguagesList() {
@@ -60,6 +60,6 @@ class LanguageSettingsFlowTests: BaseFlowTests {
6060

6161
editDownloadedLanguagesButton.tap()
6262

63-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .downloadableLanguages)
63+
assertIfScreenDoesNotExist(screenAccessibility: .downloadableLanguages)
6464
}
6565
}

godtoolsUITests/App/Flows/Menu/MenuFlowTests.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class MenuFlowTests: BaseFlowTests {
2424

2525
launchApp()
2626

27-
super.assertIfInitialScreenDoesntExist(app: app)
27+
super.assertIfInitialScreenDoesntExist()
2828
}
2929

3030
func testNavigationToMenu() {
@@ -42,7 +42,7 @@ class MenuFlowTests: BaseFlowTests {
4242

4343
menuButton.tap()
4444

45-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .menu, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
45+
assertIfScreenDoesNotExist(screenAccessibility: .menu)
4646
}
4747

4848
func testNavigationToTutorial() {
@@ -57,7 +57,7 @@ class MenuFlowTests: BaseFlowTests {
5757

5858
tutorialButton.tap()
5959

60-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .tutorial)
60+
assertIfScreenDoesNotExist(screenAccessibility: .tutorial)
6161
}
6262

6363
func testNavigationToLanguageSettings() {
@@ -72,7 +72,7 @@ class MenuFlowTests: BaseFlowTests {
7272

7373
languageSettingsButton.tap()
7474

75-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .languageSettings)
75+
assertIfScreenDoesNotExist(screenAccessibility: .languageSettings)
7676
}
7777

7878
func testNavigationToCreateAccount() {
@@ -87,7 +87,7 @@ class MenuFlowTests: BaseFlowTests {
8787

8888
createAccountButton.tap()
8989

90-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .createAccount)
90+
assertIfScreenDoesNotExist(screenAccessibility: .createAccount)
9191
}
9292

9393
func testNavigationToLogin() {
@@ -102,7 +102,7 @@ class MenuFlowTests: BaseFlowTests {
102102

103103
loginButton.tap()
104104

105-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .login)
105+
assertIfScreenDoesNotExist(screenAccessibility: .login)
106106
}
107107

108108
func testNavigationToSendFeedback() {
@@ -117,7 +117,7 @@ class MenuFlowTests: BaseFlowTests {
117117

118118
sendFeedbackButton.tap()
119119

120-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .sendFeedback, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
120+
assertIfScreenDoesNotExist(screenAccessibility: .sendFeedback)
121121
}
122122

123123
func testNavigationToReportABug() {
@@ -132,7 +132,7 @@ class MenuFlowTests: BaseFlowTests {
132132

133133
reportABugButton.tap()
134134

135-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .reportABug)
135+
assertIfScreenDoesNotExist(screenAccessibility: .reportABug)
136136
}
137137

138138
func testNavigationToAskAQuestion() {
@@ -147,7 +147,7 @@ class MenuFlowTests: BaseFlowTests {
147147

148148
askAQuestionButton.tap()
149149

150-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .askAQuestion)
150+
assertIfScreenDoesNotExist(screenAccessibility: .askAQuestion)
151151
}
152152

153153
// func testNavigationToLeaveAReview() {
@@ -162,7 +162,7 @@ class MenuFlowTests: BaseFlowTests {
162162
//
163163
// leaveAReviewButton.tap()
164164
//
165-
// assertIfScreenDoesNotExist(app: app, screenAccessibility: .leaveAReview)
165+
// assertIfScreenDoesNotExist(screenAccessibility: .leaveAReview)
166166
// }
167167

168168
func testNavigationToShareAStoryWithUs() {
@@ -177,7 +177,7 @@ class MenuFlowTests: BaseFlowTests {
177177

178178
askAQuestionButton.tap()
179179

180-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .shareAStoryWithUs)
180+
assertIfScreenDoesNotExist(screenAccessibility: .shareAStoryWithUs)
181181
}
182182

183183
// func testNavigationToShareGodTools() {
@@ -192,7 +192,7 @@ class MenuFlowTests: BaseFlowTests {
192192
//
193193
// shareGodToolsButton.tap()
194194
//
195-
// assertIfScreenDoesNotExist(app: app, screenAccessibility: .shareGodTools, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
195+
// assertIfScreenDoesNotExist(screenAccessibility: .shareGodTools)
196196
// }
197197

198198
func testNavigationToTermsOfUse() {
@@ -207,7 +207,7 @@ class MenuFlowTests: BaseFlowTests {
207207

208208
termsOfUseButton.tap()
209209

210-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .termsOfUse)
210+
assertIfScreenDoesNotExist(screenAccessibility: .termsOfUse)
211211
}
212212

213213
func testNavigationToPrivacyPolicy() {
@@ -222,7 +222,7 @@ class MenuFlowTests: BaseFlowTests {
222222

223223
privacyPolicyButton.tap()
224224

225-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .privacyPolicy)
225+
assertIfScreenDoesNotExist(screenAccessibility: .privacyPolicy)
226226
}
227227

228228
func testNavigationToCopyrightInfo() {
@@ -237,6 +237,6 @@ class MenuFlowTests: BaseFlowTests {
237237

238238
copyrightInfoButton.tap()
239239

240-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .copyrightInfo)
240+
assertIfScreenDoesNotExist(screenAccessibility: .copyrightInfo)
241241
}
242242
}

godtoolsUITests/App/Flows/Onboarding/OnboardingFlowTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class OnboardingFlowTests: BaseFlowTests {
4242

4343
chooseAppLanguageButton.tap()
4444

45-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .appLanguages)
45+
assertIfScreenDoesNotExist(screenAccessibility: .appLanguages)
4646
}
4747

4848
func testNavigationToWatchOnboardingVideoTutorialAndNavigationBackToOnboardingTutorial() {
@@ -63,7 +63,7 @@ class OnboardingFlowTests: BaseFlowTests {
6363
watchVideoButton.tap()
6464

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

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

7575
closeVideoButton.tap()
7676

77-
super.assertIfInitialScreenDoesntExist(app: app)
77+
super.assertIfInitialScreenDoesntExist()
7878
}
7979

8080
func testNavigationThroughTutorialPagesUsingNextTutorialPageButton() {
@@ -85,19 +85,19 @@ class OnboardingFlowTests: BaseFlowTests {
8585

8686
XCTAssertTrue(nextTutorialPageButton.exists)
8787

88-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage1, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
88+
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage1)
8989

9090
nextTutorialPageButton.tap()
9191

92-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage2, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
92+
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage2)
9393

9494
nextTutorialPageButton.tap()
9595

96-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage3, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
96+
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage3)
9797

9898
nextTutorialPageButton.tap()
9999

100-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage4, waitForExistence: AppFlowTests.defaultWaitForScreenExistence)
100+
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage4)
101101
}
102102

103103
func testSkippingOnboardingNavigatesToDashboardFavorites() {
@@ -108,7 +108,7 @@ class OnboardingFlowTests: BaseFlowTests {
108108

109109
XCTAssertTrue(nextTutorialPageButton.exists)
110110

111-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .onboardingTutorialPage1)
111+
assertIfScreenDoesNotExist(screenAccessibility: .onboardingTutorialPage1)
112112

113113
nextTutorialPageButton.tap()
114114

@@ -118,6 +118,6 @@ class OnboardingFlowTests: BaseFlowTests {
118118

119119
skipTutorialButton.tap()
120120

121-
assertIfScreenDoesNotExist(app: app, screenAccessibility: .dashboardFavorites)
121+
assertIfScreenDoesNotExist(screenAccessibility: .dashboardFavorites)
122122
}
123123
}

0 commit comments

Comments
 (0)