-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[UI Tests] Added a UI test for "Pages" dashboard card navigation. #18578
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -283,21 +283,22 @@ class MySitesPage { | |||||
| } | ||||||
|
|
||||||
| private fun scrollToCard(elementID: Int): MySitesPage { | ||||||
| WPSupportUtils.waitForElementToBeDisplayed(elementID) | ||||||
| Espresso.onView(ViewMatchers.withId(elementID)) | ||||||
| .perform(scrollTo()) | ||||||
|
|
||||||
| return this | ||||||
| } | ||||||
|
|
||||||
| fun scrollToDomainsCard(): MySitesPage { | ||||||
| return scrollToCard(R.id.dashboard_card_domain_cta) | ||||||
| } | ||||||
|
|
||||||
|
Comment on lines
-293
to
-296
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just moved it a few lines below, so that it belongs to the same card-related functions. |
||||||
| private fun tapCard(elementID: Int) { | ||||||
| WPSupportUtils.clickOn(elementID) | ||||||
| } | ||||||
|
|
||||||
| // "Domains" Dashboard Card | ||||||
|
|
||||||
| fun scrollToDomainsCard(): MySitesPage { | ||||||
| return scrollToCard(R.id.dashboard_card_domain_cta) | ||||||
| } | ||||||
|
|
||||||
| fun tapDomainsCard(): DomainsScreen { | ||||||
| tapCard(R.id.dashboard_card_domain_cta) | ||||||
| return DomainsScreen() | ||||||
|
|
@@ -313,7 +314,6 @@ class MySitesPage { | |||||
|
|
||||||
| ViewMatchers.hasDescendant( | ||||||
| Matchers.allOf( | ||||||
|
|
||||||
| ViewMatchers.withText(R.string.dashboard_card_domain_title), | ||||||
| ViewMatchers.withId(R.id.dashboard_card_domain_title), | ||||||
| ) | ||||||
|
|
@@ -324,8 +324,64 @@ class MySitesPage { | |||||
| ViewMatchers.withText(R.string.dashboard_card_domain_sub_title), | ||||||
| ViewMatchers.withId(R.id.dashboard_card_domain_sub_title), | ||||||
| ) | ||||||
| ) | ||||||
| ) | ||||||
| ) | ||||||
| .check(ViewAssertions.matches(ViewMatchers.isCompletelyDisplayed())) | ||||||
|
|
||||||
| return this | ||||||
| } | ||||||
|
|
||||||
| // "Pages" Dashboard Card | ||||||
|
|
||||||
| fun scrollToPagesCard(): MySitesPage { | ||||||
| return scrollToCard(R.id.dashboard_card_pages) | ||||||
| } | ||||||
|
|
||||||
| fun tapPagesCard(): PagesScreen { | ||||||
| tapCard(R.id.dashboard_card_pages) | ||||||
| return PagesScreen() | ||||||
| } | ||||||
|
|
||||||
| fun assertPagesCard(): MySitesPage { | ||||||
| Espresso.onView( | ||||||
| Matchers.allOf( | ||||||
| ViewMatchers.withId(R.id.dashboard_card_pages), | ||||||
| ViewMatchers.isDescendantOfA(ViewMatchers.withId(R.id.dashboard_cards)), | ||||||
|
|
||||||
| ViewMatchers.hasDescendant( | ||||||
| Matchers.allOf( | ||||||
| ViewMatchers.withText(R.string.dashboard_pages_card_title), | ||||||
| ViewMatchers.withId(R.id.my_site_card_toolbar_title), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
i noticed that for multiple matches, the last matcher ends with a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this particular case, this is most probably a result of me moving things around. Such a comma in the end, even if it's not followed by another line, is not considered a code style violation. I saw cases when people deliberately kept commas at the end of a line, to avoid extra noise in the future PRs when they add a next line (I left once a nitpick about this here in a PR of yours). |
||||||
| ) | ||||||
| ), | ||||||
|
|
||||||
| ViewMatchers.hasDescendant(ViewMatchers.withId(R.id.my_site_card_toolbar_more)), | ||||||
|
|
||||||
| ViewMatchers.hasDescendant( | ||||||
| Matchers.allOf( | ||||||
| ViewMatchers.withText(R.string.dashboard_pages_card_create_another_page_button), | ||||||
| ViewMatchers.withId(R.id.link_label), | ||||||
| ) | ||||||
| ) | ||||||
| ) | ||||||
| ) | ||||||
| .check(ViewAssertions.matches(ViewMatchers.isCompletelyDisplayed())) | ||||||
|
|
||||||
| return this | ||||||
| } | ||||||
|
|
||||||
| fun assertPagesCardHasPage(pageTitle: String): MySitesPage { | ||||||
| Espresso.onView( | ||||||
| Matchers.allOf( | ||||||
| ViewMatchers.withId(R.id.dashboard_card_pages), | ||||||
|
|
||||||
| ViewMatchers.hasDescendant( | ||||||
| Matchers.allOf( | ||||||
| ViewMatchers.withText(pageTitle), | ||||||
| ViewMatchers.withId(R.id.title), | ||||||
| ) | ||||||
| ) | ||||||
| ) | ||||||
| ) | ||||||
| .check(ViewAssertions.matches(ViewMatchers.isCompletelyDisplayed())) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package org.wordpress.android.e2e.pages | ||
|
|
||
| import androidx.test.espresso.Espresso | ||
| import androidx.test.espresso.ViewInteraction | ||
| import androidx.test.espresso.assertion.ViewAssertions | ||
| import androidx.test.espresso.matcher.ViewMatchers | ||
| import org.hamcrest.Matchers | ||
| import org.wordpress.android.R | ||
| import org.wordpress.android.support.WPSupportUtils | ||
|
|
||
| class PagesScreen { | ||
| fun assertPagesScreenLoaded(): PagesScreen { | ||
| WPSupportUtils.waitForElementToBeDisplayed(pagesListScreenNavbar) | ||
| return this | ||
| } | ||
|
|
||
| fun assertPagesScreenHasPage(pageTitle: String): PagesScreen { | ||
| Espresso.onView( | ||
| Matchers.allOf( | ||
| ViewMatchers.withId(R.id.page_list_layout), | ||
|
|
||
| ViewMatchers.hasDescendant( | ||
| Matchers.allOf( | ||
| ViewMatchers.withText(pageTitle), | ||
| ViewMatchers.withId(R.id.page_title), | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
| .check(ViewAssertions.matches(ViewMatchers.isCompletelyDisplayed())) | ||
|
|
||
| return this | ||
| } | ||
|
|
||
| companion object { | ||
| var pagesListScreenNavbar: ViewInteraction = Espresso.onView( | ||
| Matchers.allOf( | ||
| ViewMatchers.withId(R.id.toolbar), | ||
| ViewMatchers.hasDescendant(ViewMatchers.withText(R.string.pages)), | ||
| ) | ||
| ) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| { | ||
| "request": { | ||
| "method": "GET", | ||
| "urlPattern": "/wpcom/v2/sites/106707880/dashboard/cards-data(/)?($|\\?.*)" | ||
| }, | ||
| "response": { | ||
| "status": 200, | ||
| "jsonBody": { | ||
|
|
||
| "todays_stats": { | ||
| "views": 56, | ||
| "visitors": 44, | ||
| "likes": 19, | ||
| "comments": 0 | ||
| }, | ||
| "posts": { | ||
| "has_published": true, | ||
| "draft": [], | ||
| "scheduled": [] | ||
| }, | ||
| "pages": [ | ||
| { | ||
| "id": 51, | ||
| "title": "Blog", | ||
| "content": "Introduce yourself and your blog My Latest Posts • • • • • •", | ||
| "status": "publish", | ||
| "modified": "2023-05-18 10:33:38", | ||
| "date": "2023-05-18 10:33:38" | ||
| }, | ||
| { | ||
| "id": 30, | ||
| "title": "Cart", | ||
| "content": "", | ||
| "status": "publish", | ||
| "modified": "2023-02-03 09:46:32", | ||
| "date": "2023-02-03 09:46:32" | ||
| }, | ||
| { | ||
| "id": 31, | ||
| "title": "Shop", | ||
| "content": "", | ||
| "status": "publish", | ||
| "modified": "2023-02-03 09:46:32", | ||
| "date": "2023-02-03 09:46:32" | ||
| } | ||
| ], | ||
|
|
||
| "activity": { | ||
| "@context": "https://www.w3.org/ns/activitystreams", | ||
| "summary": "Activity log", | ||
| "type": "OrderedCollection", | ||
| "totalItems": 3, | ||
| "page": 1, | ||
| "totalPages": 1, | ||
| "itemsPerPage": 5, | ||
| "id": "https://public-api.wordpress.com/wpcom/v2/sites/106707880/activity", | ||
| "oldestItemTs": 1654043700542, | ||
| "first": "https://public-api.wordpress.com/wpcom/v2/sites/106707880/activity?page=1", | ||
| "last": "https://public-api.wordpress.com/wpcom/v2/sites/106707880/activity?page=1", | ||
| "current": { | ||
| "type": "OrderedCollectionPage", | ||
| "id": "https://public-api.wordpress.com/wpcom/v2/sites/106707880/activity", | ||
| "totalItems": 1, | ||
| "orderedItems": [ | ||
| { | ||
| "summary": "Setting changed", | ||
| "content": { | ||
| "text": "Enabled Jetpack Social for automatic social sharing" | ||
| }, | ||
| "name": "setting__changed_jetpack_module_publicize", | ||
| "actor": { | ||
| "type": "Person", | ||
| "name": "demo", | ||
| "external_user_id": 1, | ||
| "wpcom_user_id": 195654479, | ||
| "icon": { | ||
| "type": "Image", | ||
| "url": "https://secure.gravatar.com/avatar/eea057209f5e29d6ca4103bc165d645b?s=96&d=mm&r=g", | ||
| "width": 96, | ||
| "height": 96 | ||
| }, | ||
| "role": "administrator" | ||
| }, | ||
| "type": "Announce", | ||
| "published": "2023-04-04T10:33:09.300+00:00", | ||
| "generator": { | ||
| "jetpack_version": 0, | ||
| "blog_id": 106707880 | ||
| }, | ||
| "is_rewindable": false, | ||
| "rewind_id": "1680604388.4567", | ||
| "gridicon": "cog", | ||
| "status": null, | ||
| "activity_id": "6gjTS4cBfytF4jpL6MFT", | ||
| "is_discarded": false | ||
| }, | ||
| { | ||
| "summary": "Site owner connected", | ||
| "content": { | ||
| "text": "The Jetpack connection is now complete. Welcome!" | ||
| }, | ||
| "name": "jetpack__site_owner_connected", | ||
| "actor": { | ||
| "type": "Person", | ||
| "name": "Kevin Jorge", | ||
| "external_user_id": 1, | ||
| "wpcom_user_id": 11111111, | ||
| "icon": { | ||
| "type": "Image", | ||
| "url": "https://secure.gravatar.com/avatar/eea057209f5e29d6ca4103bc165d645b?s=96&d=mm&r=g", | ||
| "width": 96, | ||
| "height": 96 | ||
| }, | ||
| "role": "administrator" | ||
| }, | ||
| "type": "Announce", | ||
| "published": "2023-04-04T10:33:05.614+00:00", | ||
| "generator": { | ||
| "jetpack_version": 0, | ||
| "blog_id": 106707880 | ||
| }, | ||
| "is_rewindable": false, | ||
| "rewind_id": "1680604385.6144", | ||
| "gridicon": "plans", | ||
| "status": "success", | ||
| "activity_id": "avfTS4cB98Gh8vy65ZU4", | ||
| "is_discarded": false | ||
| }, | ||
| { | ||
| "summary": "Site connected", | ||
| "content": { | ||
| "text": "This site is connected to Jetpack." | ||
| }, | ||
| "name": "jetpack__site_connected", | ||
| "actor": { | ||
| "type": "Application", | ||
| "name": "Jetpack" | ||
| }, | ||
| "type": "Announce", | ||
| "published": "2023-04-04T10:32:54.647+00:00", | ||
| "generator": { | ||
| "jetpack_version": 0, | ||
| "blog_id": 106707880 | ||
| }, | ||
| "is_rewindable": false, | ||
| "rewind_id": "1680604374.6466", | ||
| "gridicon": "plans", | ||
| "status": "success", | ||
| "activity_id": "XvfTS4cB98Gh8vy6sI2-", | ||
| "is_discarded": false | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
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 this function with #18345, this I have no idea why this line was here, it makes no sense 😕. This worked only because the Domains card was already on-screen, and did not require scrolling.