From 06bef25f0b43db2fc8f9191e5e0c63c8d2229170 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Mon, 4 Apr 2022 14:23:06 +0300 Subject: [PATCH] For #24375 and #24384 fix and re-enable jumpBackInOptionTest and recentBookmarksOptionTest UI tests --- .../mozilla/fenix/ui/SettingsHomepageTest.kt | 10 ++++---- .../fenix/ui/robots/HomeScreenRobot.kt | 24 +++++-------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsHomepageTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsHomepageTest.kt index fd7e7e20870b..fa49824db222 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsHomepageTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsHomepageTest.kt @@ -7,13 +7,13 @@ package org.mozilla.fenix.ui import okhttp3.mockwebserver.MockWebServer import org.junit.After import org.junit.Before -import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.mozilla.fenix.customannotations.SmokeTest import org.mozilla.fenix.helpers.AndroidAssetDispatcher import org.mozilla.fenix.helpers.FeatureSettingsHelper import org.mozilla.fenix.helpers.HomeActivityIntentTestRule +import org.mozilla.fenix.helpers.RetryTestRule import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset import org.mozilla.fenix.helpers.TestHelper.restartApp import org.mozilla.fenix.ui.robots.browserScreen @@ -29,7 +29,11 @@ class SettingsHomepageTest { private val featureSettingsHelper = FeatureSettingsHelper() @get:Rule - val activityIntentTestRule = HomeActivityIntentTestRule() + val activityIntentTestRule = HomeActivityIntentTestRule(skipOnboarding = true) + + @Rule + @JvmField + val retryTestRule = RetryTestRule(3) @Before fun setUp() { @@ -48,7 +52,6 @@ class SettingsHomepageTest { featureSettingsHelper.resetAllFeatureFlags() } - @Ignore("Failing, see: https://github.com/mozilla-mobile/fenix/issues/24375") @SmokeTest @Test fun jumpBackInOptionTest() { @@ -66,7 +69,6 @@ class SettingsHomepageTest { } } - @Ignore("Failing, see: https://github.com/mozilla-mobile/fenix/issues/24384") @SmokeTest @Test fun recentBookmarksOptionTest() { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt index 5cc2861a5e5c..630ab1bcdf97 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt @@ -12,14 +12,12 @@ import androidx.recyclerview.widget.RecyclerView import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions import androidx.test.espresso.action.ViewActions.click -import androidx.test.espresso.assertion.ViewAssertions.doesNotExist import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItem import androidx.test.espresso.matcher.RootMatchers import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.hasDescendant -import androidx.test.espresso.matcher.ViewMatchers.hasSibling import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withHint @@ -674,15 +672,15 @@ private fun assertTopSiteContextMenuItems() { ) } -private fun assertJumpBackInSectionIsDisplayed() = jumpBackInSection().check(matches(isDisplayed())) +private fun assertJumpBackInSectionIsDisplayed() = assertTrue(jumpBackInSection().waitForExists(waitingTime)) -private fun assertJumpBackInSectionIsNotDisplayed() = jumpBackInSection().check(doesNotExist()) +private fun assertJumpBackInSectionIsNotDisplayed() = assertFalse(jumpBackInSection().waitForExists(waitingTimeShort)) private fun assertRecentBookmarksSectionIsDisplayed() = - recentBookmarksSection().check(matches(isDisplayed())) + assertTrue(recentBookmarksSection().waitForExists(waitingTime)) private fun assertRecentBookmarksSectionIsNotDisplayed() = - recentBookmarksSection().check(doesNotExist()) + assertFalse(recentBookmarksSection().waitForExists(waitingTimeShort)) private fun privateBrowsingButton() = onView(withId(R.id.privateBrowsingButton)) @@ -691,20 +689,10 @@ private fun saveTabsToCollectionButton() = onView(withId(R.id.add_tabs_to_collec private fun tabsCounter() = onView(withId(R.id.tab_button)) private fun jumpBackInSection() = - onView( - allOf( - withText(R.string.recent_tabs_header), - hasSibling(withText(R.string.recent_tabs_show_all)) - ) - ) + mDevice.findObject(UiSelector().textContains(getStringResource(R.string.recent_tabs_header))) private fun recentBookmarksSection() = - onView( - allOf( - withText(R.string.recent_bookmarks_title), - hasSibling(withText(R.string.recently_saved_show_all)) - ) - ) + mDevice.findObject(UiSelector().textContains(getStringResource(R.string.recent_bookmarks_title))) private fun startBrowsingButton(): UiObject { val startBrowsingButton = mDevice.findObject(UiSelector().resourceId("$packageName:id/finish_button"))