Skip to content

Commit

Permalink
* Fixes : E2E test
Browse files Browse the repository at this point in the history
  • Loading branch information
AjeshRPai committed Sep 5, 2023
1 parent a4ac7d5 commit e7c58b6
Showing 1 changed file with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ class MySitesPage {

fun goToPosts() {
goToMenuTab()
clickQuickActionOrSiteMenuItem(
R.id.quick_action_posts_button,
R.string.my_site_btn_blog_posts
)
clickSiteMenuItem(R.string.my_site_btn_blog_posts)
}

fun goToActivityLog() {
Expand Down Expand Up @@ -152,19 +149,17 @@ class MySitesPage {
goToMenuTab()

// Using RecyclerViewActions.click doesn't work for some reason when quick actions are displayed.
if (WPSupportUtils.isElementDisplayed(R.id.quick_actions_card)) {
WPSupportUtils.clickOn(Espresso.onView(ViewMatchers.withText(R.string.backup)))
} else {
clickItemWithText(R.string.backup)
}
clickItemWithText(R.string.backup)
}

fun goToStats(): StatsPage {
goToMenuTab()
val statsButton = Espresso.onView(Matchers.allOf(
ViewMatchers.withText(R.string.stats),
ViewMatchers.withId(R.id.my_site_item_primary_text)
))
val statsButton = Espresso.onView(
Matchers.allOf(
ViewMatchers.withText(R.string.stats),
ViewMatchers.withId(R.id.my_site_item_primary_text)
)
)
WPSupportUtils.clickOn(statsButton)
WPSupportUtils.idleFor(4000)
WPSupportUtils.dismissJetpackAdIfPresent()
Expand All @@ -177,7 +172,7 @@ class MySitesPage {

fun goToMedia() {
goToMenuTab()
clickQuickActionOrSiteMenuItem(R.id.quick_action_media_button, R.string.media)
clickSiteMenuItem(R.string.media)
}

fun createPost() {
Expand Down Expand Up @@ -215,20 +210,13 @@ class MySitesPage {
}

/**
* Clicks on the "Quick Action" item or the Site menu item if the quick actions card is hidden.
* Needed because locating site menu items by text fails if the quick actions are available.
* @param quickActionItemId Id of the quick actions menu item.
* Clicks on the Site menu item
* @param siteMenuItemString String resource id of the site menu item.
*/
private fun clickQuickActionOrSiteMenuItem(
@IdRes quickActionItemId: Int,
private fun clickSiteMenuItem(
@StringRes siteMenuItemString: Int
) {
if (WPSupportUtils.isElementDisplayed(quickActionItemId)) {
WPSupportUtils.clickOn(quickActionItemId)
} else {
clickItemWithText(siteMenuItemString)
}
clickItemWithText(siteMenuItemString)
}

companion object {
Expand Down

0 comments on commit e7c58b6

Please sign in to comment.