Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,19 @@ class DashboardTests : BaseTest() {
.tapDomainsCard()
.assertDomainsScreenLoaded()
}

@Test
fun e2ePagesCardNavigation() {
MySitesPage()
.scrollToPagesCard()
.assertPagesCard()
.assertPagesCardHasPage("Blog")
.assertPagesCardHasPage("Cart")
.assertPagesCardHasPage("Shop")
.tapPagesCard()
.assertPagesScreenLoaded()
.assertPagesScreenHasPage("Blog")
.assertPagesScreenHasPage("Cart")
.assertPagesScreenHasPage("Shop")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,21 +283,22 @@ class MySitesPage {
}

private fun scrollToCard(elementID: Int): MySitesPage {
WPSupportUtils.waitForElementToBeDisplayed(elementID)
Copy link
Contributor Author

@pachlava pachlava Jun 5, 2023

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.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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()
Expand All @@ -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),
)
Expand All @@ -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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ViewMatchers.withId(R.id.my_site_card_toolbar_title),
ViewMatchers.withId(R.id.my_site_card_toolbar_title)

i noticed that for multiple matches, the last matcher ends with a , which looks odd to me since it's the last one. is this intentional or is it a kotlin thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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()))
Expand Down
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
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/dashboard_card_pages"
style="@style/WordPress.CardView.Unelevated"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down
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
}
]
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"response": {
"status": 200,
"jsonBody": {
"dashboard_card_domain": true
"dashboard_card_domain": true,
"dashboard_card_pages": true
}
}
}
Loading