-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[UI Tests] Run disableAutoFillPasswords once before all the UI Tests. #21148
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
Conversation
| func executeWithRetries(_ operation: () -> Bool) { | ||
| var retryCount = 3 | ||
|
|
||
| while !operation() && retryCount > 0 { | ||
| retryCount -= 1 | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retrying to be on the safer side as all the tests would fail in case this is not disabled. I have seen it happening a couple times in a week.
I tried to make it reusable as we might need to change other setting in the future.
| guard passwordsMenuItem.waitForIsHittable() else { | ||
| XCTFail("SetUp Failed: Passwords menu item was not hittable in Settings.") | ||
| return false | ||
| } | ||
| settings.staticTexts["Passwords"].tap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few guards like this which I'd like to DRY it but I couldn't use waitAndTap( _ element: XCUIElement, maxRetries: Int = 10, timeout: TimeInterval = 10) from Globals.swift. It worked when I added JetpackUITests Target Membership to Globals.swift, but It broke a dozen of other things. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe we can add it as a private func in the same class to call in this method, it won't be reusable elsewhere but at least it's reusable here. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I started doing it and then I noticed I was almost duplicating waitForIsHittable(), struggling with the Boolean returns to control the retry flow, and all of that because of the XCTFail(String) messages that would only help debugging locally. Since the local logs are enough to debug a possible issue, I decided to make it simple and rely on waitForIsHittable().
Changed in 798de02.
|
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr21148-fb8d77d | |
| Version | 22.8 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | fb8d77d | |
| App Center Build | jetpack-installable-builds #5505 |
|
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr21148-fb8d77d | |
| Version | 22.8 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | fb8d77d | |
| App Center Build | WPiOS - One-Offs #6475 |
|
|
||
| let passwordOptions = settings.staticTexts["Password Options"] | ||
| guard passwordOptions.waitForIsHittable() else { | ||
| XCTFail("SetUp Failed: Password Options was not hittable in Passwords.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these XCTFail(String) mostly for local debugging as it doesn't actually make the tests fail because it runs before the test bundle even start.
jostnes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 @tiagomar, thanks for improving the implementation! just looking at the bonus time savings is already satisfying 💯
i added some comments, nothing blocking. and also an additional question about removeTestObserver(_:) (also TIL about TestObserver) since it is added at the start of the test run, do we need to remove it at the end of the test run?
| EA85B7AB2A686C7A0096E097 /* TestObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA85B7A92A6860370096E097 /* TestObserver.swift */; }; | ||
| EA85B7AF2A688AB00096E097 /* TestObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA85B7A92A6860370096E097 /* TestObserver.swift */; }; | ||
| EA85B7B02A688B1C0096E097 /* TestObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA85B7A92A6860370096E097 /* TestObserver.swift */; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these expected, or are leftovers from adding/removing the file multiple times?
(if it's the latter, which always happens to me, i usually discard all changes in the ./project.pbxproj before submitting the changes and rebuild the project so the references will be added to the right place in the file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!! 👏
I did remove one of them in 937cae8, the other two are related to JetpackUI Tests and WordPressUITests build phase references.
|
|
||
| func disableAutoFillPasswords() -> Bool { | ||
| let settings = XCUIApplication(bundleIdentifier: "com.apple.Preferences") | ||
| settings.terminate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this .terminate() here? If this will be run once at the start of the test run, is this necessary? I'm thinking there's nothing to terminate at that point but I could be missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed in a retry case if something goes wrong in the first execution and also to make our lives easier when running multiple times locally. =]
I added a comment in 798de02.
| guard passwordsMenuItem.waitForIsHittable() else { | ||
| XCTFail("SetUp Failed: Passwords menu item was not hittable in Settings.") | ||
| return false | ||
| } | ||
| settings.staticTexts["Passwords"].tap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe we can add it as a private func in the same class to call in this method, it won't be reusable elsewhere but at least it's reusable here. wdyt?
jostnes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments, the changes look good! ![]()



Description
The objective of this PR is to make
disableAutoFillPasswords()run only once before all the whole suite as the change is persisted in the simulators and doesn't need to run before each test. It was done by adding a TestObserver and runningdisableAutoFillPasswords()within
testBundleWillStart(_:). h/t to @mokagio for the tip!I also added some waiting for the elements because, even though it will run only once per simulator, it's still navigating through UI and still can be impacted by eventual CI slowness.
Testing
Ci should be 🟢