From f76dcc4da7190157fdc3b5cc4e4f556e08bb0cb3 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Thu, 24 Nov 2022 09:57:40 +0200 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/26286 new openPocketStoryItemTest UI test --- .../org/mozilla/fenix/ui/HomeScreenTest.kt | 20 +++++++++++++ .../fenix/ui/robots/HomeScreenRobot.kt | 30 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt index 9bbef33cad..a0cf8bce47 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt @@ -35,6 +35,7 @@ class HomeScreenTest { private lateinit var mDevice: UiDevice private lateinit var mockWebServer: MockWebServer + private lateinit var firstPocketStoryPublisher: String @get:Rule(order = 0) val activityTestRule = @@ -238,6 +239,25 @@ class HomeScreenTest { } } + @Test + fun openPocketStoryItemTest() { + activityTestRule.activityRule.applySettingsExceptions { + it.isRecentTabsFeatureEnabled = false + it.isRecentlyVisitedFeatureEnabled = false + } + + homeScreen { + }.dismissOnboarding() + + homeScreen { + verifyThoughtProvokingStories(true) + scrollToPocketProvokingStories() + firstPocketStoryPublisher = getProvokingStoryPublisher(1) + }.clickPocketStoryItem(firstPocketStoryPublisher, 1) { + verifyUrl(firstPocketStoryPublisher) + } + } + @Test fun verifyCustomizeHomepageTest() { val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) 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 954fdf71aa..9b27d19ba1 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 @@ -382,6 +382,20 @@ class HomeScreenRobot { ) } + fun getProvokingStoryPublisher(position: Int): String { + val publisher = mDevice.findObject( + UiSelector() + .className("android.view.View") + .index(position - 1), + ).getChild( + UiSelector() + .className("android.widget.TextView") + .index(1), + ).text + + return publisher + } + class Transition { fun openTabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition { @@ -653,6 +667,22 @@ class HomeScreenRobot { BrowserRobot().interact() return BrowserRobot.Transition() } + + fun clickPocketStoryItem(publisher: String, position: Int, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { + mDevice.findObject( + UiSelector() + .className("android.view.View") + .index(position - 1), + ).getChild( + UiSelector() + .className("android.widget.TextView") + .index(1) + .textContains(publisher), + ).clickAndWaitForNewWindow(waitingTime) + + BrowserRobot().interact() + return BrowserRobot.Transition() + } } }