-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reimplement waitForElementAndTap...
as a typed XCUIElement
method
#22322
Reimplement waitForElementAndTap...
as a typed XCUIElement
method
#22322
Conversation
"Typed" in that it expects an `enum` instead of a `String` to define the expected element state.
switch state { | ||
case .exists: return element.exists | ||
case .dismissed: return element.isHittable | ||
case .selected: return element.isSelected |
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.
Notice how thanks to the enum we no longer need to handle the case where the input is invalid:
default:
XCTFail("\(condition) is invalid! Please choose 'exists', 'dismissed' or 'selected'")
It became unused in the previous commit, b442842
🤦♂️ Now I regret cancelling the build because I could have used the video of what the Simulator was showing... |
To follow up via #22323
🤦♂️ I didn't notice the `!` at the start of the check when porting it over.
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 issue so nicely, @mokagio!
The tests are passing locally and in the CI.
guard condition.isMet() else { | ||
sleep(UInt32(retryInterval)) | ||
|
||
return tapUntil( |
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.
Nice alternative to a conventional loop. I'd never come up with it. =D
// FIXME: This needs to be addressed at the root but that requires more work than we have time for considering we want to support Xcode 15.1 ASAP. | ||
// Tracked in https://github.com/wordpress-mobile/WordPress-iOS/issues/22323 | ||
XCTExpectFailure("The date conversion may fail at times, likely due to an underlying time zone inconsistency") { | ||
XCTAssertEqual(dateComponents.month, expectedDateComponents.month) | ||
XCTAssertEqual(dateComponents.day, expectedDateComponents.day) | ||
} |
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 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.
Changes look good to me, too! Thanks for refactoring it to be clearer and simpler. I'll merge this into the branch to get rid of the unit test failure.
Follows up on @tiagomar suggestion from https://github.com/wordpress-mobile/WordPress-iOS/pull/22270/files#r1439672960.
My intent with this is primary to facilitate merging #22270 and therefore officially support Xcode 15.1. Secondary is the showcase of what I think are two useful design practices:
enum
over aString
to "make inconsistent state unrepresentable" which is one of the most powerful features of a strongly typed language.Testing
The UI tests passed for me locally:
And this is the CI build on the Apple Silicon test pipeline.
Regression Notes
PR submission checklist:
RELEASE-NOTES.txt
if necessary. N.A.UI changes testing checklist: Not a UI PR.