From e75166ebdc30503056611ac6db7d1085f2094689 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Mon, 31 Jul 2023 13:19:11 +0300 Subject: [PATCH] Bug 1842560 - Fix verifyRecentlyClosedTabsListTest UI test --- .../ui/robots/RecentlyClosedTabsRobot.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/RecentlyClosedTabsRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/RecentlyClosedTabsRobot.kt index 318f2dc89..a2cd5d234 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/RecentlyClosedTabsRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/RecentlyClosedTabsRobot.kt @@ -18,7 +18,10 @@ import org.hamcrest.Matchers import org.hamcrest.Matchers.allOf import org.mozilla.fenix.R import org.mozilla.fenix.helpers.HomeActivityComposeTestRule +import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndTextExists +import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdContainingText import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime +import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort import org.mozilla.fenix.helpers.TestHelper.mDevice import org.mozilla.fenix.helpers.TestHelper.packageName import org.mozilla.fenix.helpers.click @@ -54,8 +57,9 @@ class RecentlyClosedTabsRobot { } fun verifyRecentlyClosedTabsPageTitle(title: String) = - recentlyClosedTabsPageTitle(title) - .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) + assertItemWithResIdAndTextExists( + recentlyClosedTabsPageTitle(title), + ) fun verifyRecentlyClosedTabsUrl(expectedUrl: Uri) { onView( @@ -72,7 +76,10 @@ class RecentlyClosedTabsRobot { class Transition { fun clickRecentlyClosedItem(title: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { - recentlyClosedTabsPageTitle(title).click() + recentlyClosedTabsPageTitle(title).also { + it.waitForExists(waitingTimeShort) + it.click() + } mDevice.waitForIdle() BrowserRobot().interact() @@ -109,12 +116,11 @@ class RecentlyClosedTabsRobot { } } -private fun recentlyClosedTabsPageTitle(title: String) = onView( - allOf( - withId(R.id.title), - withText(title), - ), -) +private fun recentlyClosedTabsPageTitle(title: String) = + itemWithResIdContainingText( + resourceId = "$packageName:id/title", + text = title, + ) private fun recentlyClosedTabDeleteButton() = onView(