Skip to content

Commit eca05e6

Browse files
committed
Cover more user paths where UI tests ask to save password
1 parent 4312736 commit eca05e6

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public class LoginUsernamePasswordScreen: ScreenObject {
8787
passwordTextField.typeText(password)
8888
}
8989
nextButton.tap()
90+
91+
app.dismissSavePasswordPrompt()
9092
}
9193

9294
private func dismissQuickStartPromptIfNeeded() throws {

WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class PasswordScreen: ScreenObject {
1515
public func proceedWithValidPassword() throws -> LoginEpilogueScreen {
1616
try tryProceed(password: "pw")
1717

18+
app.dismissSavePasswordPrompt()
19+
1820
return try LoginEpilogueScreen()
1921
}
2022

@@ -48,12 +50,7 @@ public class PasswordScreen: ScreenObject {
4850
let continueButton = app.buttons["Continue Button"]
4951
continueButton.tap()
5052

51-
// The Simulator might ask to save the password which, of course, we don't want to do
52-
if app.buttons["Save Password"].waitForExistence(timeout: 5) {
53-
// There should be no need to wait for this button to exist since it's part of the same
54-
// alert where "Save Password" is.
55-
app.buttons["Not Now"].tap()
56-
}
53+
app.dismissSavePasswordPrompt()
5754
}
5855

5956
public func verifyLoginError() -> PasswordScreen {

WordPress/UITestsFoundation/Screens/Login/Unified/PrologueScreen.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class PrologueScreen: ScreenObject {
2525
public func selectContinue() throws -> GetStartedScreen {
2626
continueButton.tap()
2727

28+
app.dismissSavePasswordPrompt()
29+
2830
return try GetStartedScreen()
2931
}
3032

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import XCTest
2+
3+
extension XCUIApplication {
4+
5+
// Starting with iOS 16.4, the Simulator might ask to save the password with a modal sheet.
6+
// This method encapsulates the logic to dimiss the prompt.
7+
func dismissSavePasswordPrompt() {
8+
XCTContext.runActivity(named: "Dismiss save password prompt if needed.") { _ in
9+
guard buttons["Save Password"].waitForExistence(timeout: 5) else { return }
10+
11+
// There should be no need to wait for this button to exist since it's part of the same
12+
// alert where "Save Password" is.
13+
buttons["Not Now"].tap()
14+
}
15+
}
16+
}

WordPress/WordPress.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@
813813
3F685B6A26D431FA001C6808 /* DomainSuggestionViewControllerWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FAF9CC426D03C7400268EA2 /* DomainSuggestionViewControllerWrapper.swift */; };
814814
3F6975FF242D941E001F1807 /* ReaderTabViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F6975FE242D941E001F1807 /* ReaderTabViewModel.swift */; };
815815
3F6A7E92251BC1DC005B6A61 /* RootViewCoordinator+WhatIsNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F6A7E91251BC1DC005B6A61 /* RootViewCoordinator+WhatIsNew.swift */; };
816+
3F6A8CE02A246357009DBC2B /* XCUIApplication+SavePassword.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F6A8CDF2A246357009DBC2B /* XCUIApplication+SavePassword.swift */; };
816817
3F6AD0562502A91400080F3B /* AnnouncementsCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F6AD0552502A91400080F3B /* AnnouncementsCache.swift */; };
817818
3F6BC04B25B2474C007369D3 /* FeatureFlag.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1D690151F828FF000200E30 /* FeatureFlag.swift */; };
818819
3F6BC05C25B24773007369D3 /* FeatureFlagOverrideStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17A09B98238FE13B0022AE0D /* FeatureFlagOverrideStore.swift */; };
@@ -6498,6 +6499,7 @@
64986499
3F662C4924DC9FAC00CAEA95 /* WhatIsNewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhatIsNewViewController.swift; sourceTree = "<group>"; };
64996500
3F6975FE242D941E001F1807 /* ReaderTabViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReaderTabViewModel.swift; sourceTree = "<group>"; };
65006501
3F6A7E91251BC1DC005B6A61 /* RootViewCoordinator+WhatIsNew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RootViewCoordinator+WhatIsNew.swift"; sourceTree = "<group>"; };
6502+
3F6A8CDF2A246357009DBC2B /* XCUIApplication+SavePassword.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCUIApplication+SavePassword.swift"; sourceTree = "<group>"; };
65016503
3F6AD0552502A91400080F3B /* AnnouncementsCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnnouncementsCache.swift; sourceTree = "<group>"; };
65026504
3F6DA04025646F96002AB88F /* HomeWidgetData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeWidgetData.swift; sourceTree = "<group>"; };
65036505
3F720C2028899DD900519938 /* JetpackBrandingVisibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackBrandingVisibility.swift; sourceTree = "<group>"; };
@@ -11504,6 +11506,7 @@
1150411506
3FA640592670CCD40064401E /* UITestsFoundation.h */,
1150511507
3F762E9426784B540088CD45 /* WireMock.swift */,
1150611508
3F107B1829B6F7E0009B3658 /* XCTestCase+Utils.swift */,
11509+
3F6A8CDF2A246357009DBC2B /* XCUIApplication+SavePassword.swift */,
1150711510
3FB5C2B227059AC8007D0ECE /* XCUIElement+Scroll.swift */,
1150811511
3F762E9A26784D2A0088CD45 /* XCUIElement+Utils.swift */,
1150911512
3F762E9826784CC90088CD45 /* XCUIElementQuery+Utils.swift */,
@@ -22779,6 +22782,7 @@
2277922782
3F2F855D26FAF227000FCDA5 /* LoginCheckMagicLinkScreen.swift in Sources */,
2278022783
EA78189427596B2F00554DFA /* ContactUsScreen.swift in Sources */,
2278122784
D82E087829EEB7AF0098F500 /* DomainsScreen.swift in Sources */,
22785+
3F6A8CE02A246357009DBC2B /* XCUIApplication+SavePassword.swift in Sources */,
2278222786
3F2F855626FAF227000FCDA5 /* LoginEmailScreen.swift in Sources */,
2278322787
FA9276AF2888557500C323BB /* SiteIntentScreen.swift in Sources */,
2278422788
3FE39A3926F837E1006E2B3A /* ActivityLogScreen.swift in Sources */,

0 commit comments

Comments
 (0)