Convert UI tests screens to be a ScreenObject subclasses – 5 of many#17361
Convert UI tests screens to be a ScreenObject subclasses – 5 of many#17361
Conversation
|
You can trigger an installable build for these changes by visiting CircleCI here. |
|
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
a7206d0 to
2608300
Compare
f50f89d to
9c31649
Compare
| expectedElementGetters: [defaultAlertButtonGetter, cancelAlertButtonGetter], | ||
| app: app | ||
| app: app, | ||
| waitTimeout: 3 |
There was a problem hiding this comment.
The default timeout for ScreenObject is 20s (which might not be a good idea)... This view is one we check for often: we don't want to wait 20s for it every time.
| // TODO: Move this to XCUITestHelpers or ScreenObject | ||
| extension XCUIElement { | ||
|
|
||
| func waitFor( | ||
| predicateString: String, | ||
| timeout: TimeInterval = 10 | ||
| ) -> XCTWaiter.Result { | ||
| XCTWaiter.wait( | ||
| for: [ | ||
| XCTNSPredicateExpectation( | ||
| predicate: NSPredicate(format: predicateString), | ||
| object: self | ||
| ) | ||
| ], | ||
| timeout: timeout | ||
| ) | ||
| } |
There was a problem hiding this comment.
Extracting this is something I'll do in a followup PR (which might occur later on, or the next time I'll touch this file)
| removeSiteButton = app.cells[ElementStringIDs.removeSiteButton] | ||
| removeSiteSheet = app.sheets.buttons.element(boundBy: 0) | ||
| removeSiteAlert = app.alerts.buttons.element(boundBy: 1) | ||
| activityLogButton = app.cells[ElementStringIDs.activityLogButton] | ||
| jetpackScanButton = app.cells[ElementStringIDs.jetpackScanButton] | ||
| jetpackBackupButton = app.cells[ElementStringIDs.jetpackBackupButton] | ||
| postsButton = app.cells[ElementStringIDs.postsButton] | ||
| mediaButton = app.cells[ElementStringIDs.mediaButton] | ||
| statsButton = app.cells[ElementStringIDs.statsButton] | ||
| siteSettingsButton = app.cells[ElementStringIDs.settingsButton] | ||
| createButton = app.buttons[ElementStringIDs.createButton] | ||
| readerButton = app.buttons[ElementStringIDs.ReaderButton] | ||
| switchSiteButton = app.buttons[ElementStringIDs.switchSiteButton] | ||
| navBar = app.navigationBars[ElementStringIDs.navBarTitle] | ||
|
|
||
| super.init(element: navBar) | ||
| try super.init( | ||
| expectedElementGetters: [ | ||
| switchSiteButtonGetter, | ||
| statsButtonGetter, | ||
| postsButtonGetter, | ||
| mediaButtonGetter, | ||
| createButtonGetter |
There was a problem hiding this comment.
Only kept a subset of the elements that were instantiated in the previous version to avoid spending too much time verifying whether the screen is loaded (reminder: this is something ScreenObject does automatically at init time).
| // The block editor has _many_ elements but most are loaded on-demand. To verify the screen | ||
| // is loaded, we rely only on the button to add a new block and on the navigation bar we | ||
| // expect to encase the screen. |
There was a problem hiding this comment.
This is also the reason for all the red lines above. Instead of instantiating the elements at init time, I've updated the code to use ScreenObject's app property and query it at runtime when a method that needs an element is called.
Also, a few of the elements were unused 🧹 🧹 🧹
2608300 to
a3a3c03
Compare
Namely the prologue and the tab-nav component. That's because if we need to wait for them for 20 seconds on every check in flows when they're not loaded, the tests drag along for too long.
How was it working before?!
9c31649 to
1c4fb5c
Compare
pachlava
left a comment
There was a problem hiding this comment.
I ran all the tests locally on iPhone 12 (iOS 14.5) and they passed. As for the changes in files: everything looks legit to me, I have no additional comments or questions 👍 Thank you for doing this thorough but quite repetitive work @mokagio!
|
Thank you for the reviews @pachlava 🙇♂️ |
See #17221, #17348, #17359, and #17360
I made this on top of #17360 for ease of review.
Regression Notes
Potential unintended areas of impact
N.A.
What I did to test those areas of impact (or what existing automated tests I relied on)
N.A.
What automated tests I added (or what prevented me from doing so)
N.A.
RELEASE-NOTES.txtif necessary. N.A.