-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[UI Tests] Added a UI Test for "Pages" dashboard card navigation. #20788
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
|
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr20788-b440c3d | |
| Version | 22.4 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | b440c3d | |
| App Center Build | jetpack-installable-builds #4898 |
|
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr20788-b440c3d | |
| Version | 22.4 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | b440c3d | |
| App Center Build | WPiOS - One-Offs #5868 |
b1cadd9 to
5e176b8
Compare
5e176b8 to
d3a0fff
Compare
| func scrollToCard(withId id: String) { | ||
| let collectionView = app.collectionViews.firstMatch | ||
| let cardCell = collectionView.cells.containing(.any, identifier: id).firstMatch | ||
| app.scrollDownToElement(element: cardCell) | ||
| } |
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.
Since there are two cards now - "Domains" and "Pages" (and more coming) - that need scrolling, I extracted the scrolling part to a separate method. The major change here is that I'm not using scrollIntoView extension any longer, because it appeared unstable for the case when more than one swipe is needed to scroll to the element. Instead, I'm using newly added scrollDownToElement.
testPagesCardHeaderNavigation MK1
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 adding the tests @pachlava! i left out reviewing the scrolling bit a part of this PR as i saw that it is updated again the other PR.
i added a couple of nitpicks but the reason i have not approved is that i noticed that we might end up in a false positive in the case where pages are listed on the dashboard card but not listed on the pages screen.
i'm not sure if the test is going to be extended or not (i.e there will be a separate pages test to validate the value on pages screen), if it is then this can be ✅ if not, then we should update the assertions to include checking the pages.
| "modified": "2023-05-18 10:33:38", | ||
| "date": "2023-05-18 10:33:38" |
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've seen in some mocks where the date value is set to today's date. would having this (and other dates in this response) hardcoded cause any issues in the future? (e.g. page not appearing because it's an old page or something like that)
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.
As long as this is not something time sensitive (not stats / messages / reviews / posts), the pages should be still shown in the card regardless of creation time 🤔. I haven't heard of any requirements for this card not to show the pages of a certain age. So if the card stops showing them, this would be an issue.
| XCTAssertTrue(pagesCardHeaderButton.waitForIsHittable(), "Pages card: header not displayed.") | ||
| XCTAssertTrue(pagesCard.buttons["More"].waitForIsHittable(), "Pages card: context menu not displayed.") |
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.
super nit:
| XCTAssertTrue(pagesCardHeaderButton.waitForIsHittable(), "Pages card: header not displayed.") | |
| XCTAssertTrue(pagesCard.buttons["More"].waitForIsHittable(), "Pages card: context menu not displayed.") | |
| XCTAssertTrue(pagesCardHeaderButton.waitForIsHittable(), "Pages card: Header not displayed.") | |
| XCTAssertTrue(pagesCard.buttons["More"].waitForIsHittable(), "Pages card: Context menu not displayed.") |
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! I updated this, and another neighbouring message in 865dd41.
| XCTAssertTrue(pagesCardHeaderButton.waitForIsHittable(), "Pages card: header not displayed.") | ||
| XCTAssertTrue(pagesCard.buttons["More"].waitForIsHittable(), "Pages card: context menu not displayed.") |
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.
just curious to know if there are any reasons why the More button is not made a property like the rest of the buttons?
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.
Firstly, I wanted to reply with:
This is because "More" button is not used anywhere else besides this assertion (e.g. not tapped). Creating a getter for it in this case would not be justified, IMO (however, it's a matter of preference, too).
However, I then noticed that Create Page button is also used only in assertion once, but still has a getter.
To make it consistent, I created a getter for More button too in 865dd41.
| .verifyPlanSelectionScreenLoaded() | ||
| } | ||
|
|
||
| func testPagesCardHeaderNavigation() throws { |
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.
is this test also only for Jetpack? i see that the first test in this test class has a comment on it // This test is JP only. what do you think about adding a comment for the whole test class instead of per test so it's clearer that it's Jetpack only?
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 point! Done in 865dd41.
| .verifyPagesCard(hasPage: "Blog") | ||
| .verifyPagesCard(hasPage: "Shop") | ||
| .verifyPagesCard(hasPage: "Cart") |
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 wonder if we need to have three pages cards for this test. would be fine to test with just 2? (to test single vs multiple cases, that way it's less time for test validation and fewer files to maintain)
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.
Just to be sure that we're talking about the same thing: this function checks that the card contains a link to the page. It's not testing a separate card. According to project specs, the card should display three pages (if the website has three pages).
that way it's less time for test validation
Since it's a check for a single static text presence, the assertion takes does not take that long. In fact, the execution time of this test as is, and with all three pages checks disabled, one time was the same, and one time it was 1 second longer 🙃.
and fewer files to maintain
All the pages that should be listed in the Pages card are defined in a single file: dashboard.json, so the maintenance effort does not change depending on the number of pages we check in a card.
|
|
||
| @discardableResult | ||
| public func verifyPagesScreenLoaded() -> Self { | ||
| XCTAssertTrue(PagesScreen.isLoaded(), "\"Pages\" screen isn't loaded.") |
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.
depending if this test will be extended again or not, i think we could end up with a false positive if we're only checking for the PagesTable table value, i tested with an empty table and saw that this returned
Table, 0x7ff76e80c5c0, {{0.0, 137.0}, {390.0, 624.0}}, identifier: 'PagesTable', label: 'Empty list'
if we're expecting the existing pages to also be listed, we should add additional assertions to validate them so we don't get a passing test when an empty page view is returned.
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.
Since I was adding this test as a part of "Pages and Activity Log cards" project, I did not test the "Pages List" screen content, because the test is about card content and working navigation to the Pages List screen. The Pages List screen itself exists for a long time, so automating the check for it would be out of scope.
The same approach is used in testFreeToPaidCardNavigation, where the test checks that the Domains screen is loaded, but does not check for actual domains suggestions. Let me know if this makes sense, though.
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.
However 😆, the time it took to add the assertions for Pages being present in Pages Screen was around 2 minutes, and the test execution time did not suffer anyhow. I've added this with a9e2df1.
Generated by 🚫 dangerJS |
|
Thank you for your review and questions @jostnes 🙇 I answered all the comments from you, and made a few changes. Could you have a look please?
This test checks the card navigation by tapping the card header (as in all the other tests for cards). There potentially can be more tests:
However, I don't think we should add them within the current infra and run on every commit. There are more valuable flows that are not automated, IMO, and spending both writing and execution time of fully testing each card (please remember that there will be at least 4 cards) is not justified. We might want to have them, for the case of daily execution, but we're not there yet. UPD: I've added checking that pages are shown on Pages Screen with a9e2df1. |
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.
This test checks the card navigation by tapping the card header (as in all the other tests for cards). There potentially can be more tests:
Test context menu
Test tapping individual page
Test "Create Page" buttonHowever, I don't think we should add them within the current infra and run on every commit. There are more valuable flows that are not automated, IMO, and spending both writing and execution time of fully testing each card (please remember that there will be at least 4 cards) is not justified. We might want to have them, for the case of daily execution, but we're not there yet.
Yup agree with this, the reason I asked if the test was going to be extended was more related to the potential false positive (which has been updated 🙇 ) the rest of the tests from the list above I agree we shouldn't run on every commit.
And thank you for the responses and the updates! The test works well locally and is 🟢 in CI ![]()
| } | ||
|
|
||
| // This test is JP only. | ||
|
|
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.
super nit - we can remove this extra line now the comment is moved
…ard-ui-test [UI Tests] Added a UI Test for "Activity Log" dashboard card navigation.


Description
This PR adds a UI test for the "Pages" dashboard card:
What it does:
Create Pagebutton is available atHomescreen.Pagesscreen takes placeI hope the code is pretty self-explanatory, so I'm not providing a lot of notes on it. There are 12 changed files, however most of them are mocks, accessibility identifiers addition, and extensions for scrolling to an element.
To test
testPagesCardHeaderNavigationRegression Notes
I'm not filling the regression notes since the PR adds a UI test, it does not change the app behaviour in any way.