mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
Bug 1815276 - Fix selectors for Pocket stories
This commit is contained in:
parent
3fd1ebab66
commit
1ad8bb22be
@ -10,7 +10,6 @@ import androidx.test.uiautomator.UiDevice
|
||||
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.helpers.AndroidAssetDispatcher
|
||||
@ -58,11 +57,9 @@ class HomeScreenTest {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
@Ignore("Failing, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1815275")
|
||||
@Test
|
||||
fun homeScreenItemsTest() {
|
||||
homeScreen { }.dismissOnboarding()
|
||||
|
||||
homeScreen {}.dismissOnboarding()
|
||||
homeScreen {
|
||||
verifyHomeWordmark()
|
||||
verifyHomePrivateBrowsingButton()
|
||||
@ -72,12 +69,8 @@ class HomeScreenTest {
|
||||
verifyCollectionsHeader()
|
||||
verifyNoCollectionsText()
|
||||
scrollToPocketProvokingStories()
|
||||
swipePocketProvokingStories()
|
||||
verifyPocketRecommendedStoriesItems(activityTestRule, 1, 3, 4, 5, 6, 7)
|
||||
verifyPocketSponsoredStoriesItems(activityTestRule, 2, 8)
|
||||
verifyDiscoverMoreStoriesButton(activityTestRule, 9)
|
||||
verifyThoughtProvokingStories(true)
|
||||
verifyStoriesByTopicItems()
|
||||
verifyPoweredByPocket(activityTestRule)
|
||||
verifyCustomizeHomepageButton(true)
|
||||
verifyNavigationToolbar()
|
||||
verifyDefaultSearchEngine("Google")
|
||||
@ -149,7 +142,6 @@ class HomeScreenTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Failing, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1815276")
|
||||
@Test
|
||||
fun verifyPocketHomepageStoriesTest() {
|
||||
activityTestRule.activityRule.applySettingsExceptions {
|
||||
@ -163,11 +155,11 @@ class HomeScreenTest {
|
||||
homeScreen {
|
||||
verifyThoughtProvokingStories(true)
|
||||
scrollToPocketProvokingStories()
|
||||
swipePocketProvokingStories()
|
||||
verifyPocketRecommendedStoriesItems(activityTestRule, 1, 3, 4, 5, 6, 7)
|
||||
verifyPocketSponsoredStoriesItems(activityTestRule, 2, 8)
|
||||
verifyDiscoverMoreStoriesButton(activityTestRule, 9)
|
||||
verifyPocketRecommendedStoriesItems(1, 3, 4, 5, 6, 7)
|
||||
verifyPocketSponsoredStoriesItems(2, 8)
|
||||
verifyDiscoverMoreStoriesButton()
|
||||
verifyStoriesByTopic(true)
|
||||
verifyPoweredByPocket()
|
||||
}.openThreeDotMenu {
|
||||
}.openCustomizeHome {
|
||||
clickPocketButton()
|
||||
@ -177,7 +169,6 @@ class HomeScreenTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Failing, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1821016")
|
||||
@Test
|
||||
fun openPocketStoryItemTest() {
|
||||
activityTestRule.activityRule.applySettingsExceptions {
|
||||
@ -197,7 +188,6 @@ class HomeScreenTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Failed, see: https://github.com/mozilla-mobile/fenix/issues/28098")
|
||||
@Test
|
||||
fun openPocketDiscoverMoreTest() {
|
||||
activityTestRule.activityRule.applySettingsExceptions {
|
||||
@ -210,9 +200,8 @@ class HomeScreenTest {
|
||||
|
||||
homeScreen {
|
||||
scrollToPocketProvokingStories()
|
||||
swipePocketProvokingStories()
|
||||
verifyDiscoverMoreStoriesButton(activityTestRule, 9)
|
||||
}.clickPocketDiscoverMoreButton(activityTestRule, 9) {
|
||||
verifyDiscoverMoreStoriesButton()
|
||||
}.clickPocketDiscoverMoreButton {
|
||||
verifyUrl("getpocket.com/explore")
|
||||
}
|
||||
}
|
||||
@ -245,7 +234,7 @@ class HomeScreenTest {
|
||||
}.dismissOnboarding()
|
||||
|
||||
homeScreen {
|
||||
verifyPoweredByPocket(activityTestRule)
|
||||
verifyPoweredByPocket()
|
||||
}.clickPocketLearnMoreLink(activityTestRule) {
|
||||
verifyUrl("mozilla.org/en-US/firefox/pocket")
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import androidx.compose.ui.test.assert
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.assertIsNotSelected
|
||||
import androidx.compose.ui.test.assertIsSelected
|
||||
import androidx.compose.ui.test.hasTestTag
|
||||
import androidx.compose.ui.test.hasText
|
||||
import androidx.compose.ui.test.junit4.ComposeTestRule
|
||||
import androidx.compose.ui.test.onChildAt
|
||||
@ -204,7 +203,10 @@ class HomeScreenRobot {
|
||||
fun verifyTabButton() = assertTabButton()
|
||||
fun verifyCollectionsHeader() = assertCollectionsHeader()
|
||||
fun verifyNoCollectionsText() = assertNoCollectionsText()
|
||||
fun verifyHomeWordmark() = assertItemWithResIdExists(homepageWordmark)
|
||||
fun verifyHomeWordmark() {
|
||||
homeScreenList().scrollToBeginning(3)
|
||||
assertItemWithResIdExists(homepageWordmark)
|
||||
}
|
||||
fun verifyHomeComponent() = assertHomeComponent()
|
||||
fun verifyDefaultSearchEngine(searchEngine: String) = verifySearchEngineIcon(searchEngine)
|
||||
fun verifyTabCounter(numberOfOpenTabs: String) =
|
||||
@ -295,7 +297,10 @@ class HomeScreenRobot {
|
||||
).waitForExists(waitingTimeShort),
|
||||
)
|
||||
fun verifyNotExistingSponsoredTopSitesList() = assertSponsoredTopSitesNotDisplayed()
|
||||
fun verifyExistingTopSitesTabs(title: String) = assertExistingTopSitesTabs(title)
|
||||
fun verifyExistingTopSitesTabs(title: String) {
|
||||
homeScreenList().scrollIntoView(itemWithResId("$packageName:id/top_sites_list"))
|
||||
assertExistingTopSitesTabs(title)
|
||||
}
|
||||
fun verifySponsoredShortcutDetails(sponsoredShortcutTitle: String, position: Int) {
|
||||
assertSponsoredShortcutLogoIsDisplayed(position)
|
||||
assertSponsoredShortcutTitle(sponsoredShortcutTitle, position)
|
||||
@ -387,37 +392,45 @@ class HomeScreenRobot {
|
||||
}
|
||||
}
|
||||
|
||||
fun scrollToPocketProvokingStories() =
|
||||
scrollToElementByText(getStringResource(R.string.pocket_stories_categories_header))
|
||||
|
||||
fun swipePocketProvokingStories() {
|
||||
UiScrollable(UiSelector().resourceId("pocket.stories")).setAsHorizontalList()
|
||||
.swipeLeft(3)
|
||||
fun scrollToPocketProvokingStories() {
|
||||
homeScreenList().scrollIntoView(
|
||||
mDevice.findObject(UiSelector().resourceId("pocket.recommended.story").index(2)),
|
||||
)
|
||||
}
|
||||
|
||||
fun verifyPocketRecommendedStoriesItems(composeTestRule: ComposeTestRule, vararg positions: Int) {
|
||||
composeTestRule.onNodeWithTag("pocket.stories").assertIsDisplayed()
|
||||
fun verifyPocketRecommendedStoriesItems(vararg positions: Int) {
|
||||
positions.forEach {
|
||||
composeTestRule.onNodeWithTag("pocket.stories")
|
||||
.onChildAt(it - 1)
|
||||
.assert(hasTestTag("pocket.recommended.story"))
|
||||
pocketStoriesList
|
||||
.scrollIntoView(UiSelector().resourceId("pocket.recommended.story").index(it - 1))
|
||||
|
||||
assertTrue(
|
||||
"Pocket story item at position $it not found.",
|
||||
mDevice.findObject(UiSelector().index(it - 1).resourceId("pocket.recommended.story"))
|
||||
.waitForExists(waitingTimeShort),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun verifyPocketSponsoredStoriesItems(composeTestRule: ComposeTestRule, vararg positions: Int) {
|
||||
composeTestRule.onNodeWithTag("pocket.stories").assertIsDisplayed()
|
||||
fun verifyPocketSponsoredStoriesItems(vararg positions: Int) {
|
||||
positions.forEach {
|
||||
composeTestRule.onNodeWithTag("pocket.stories")
|
||||
.onChildAt(it - 1)
|
||||
.assert(hasTestTag("pocket.sponsored.story"))
|
||||
pocketStoriesList
|
||||
.scrollIntoView(UiSelector().resourceId("pocket.sponsored.story").index(it - 1))
|
||||
|
||||
assertTrue(
|
||||
"Pocket story item at position $it not found.",
|
||||
mDevice.findObject(UiSelector().index(it - 1).resourceId("pocket.sponsored.story"))
|
||||
.waitForExists(waitingTimeShort),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun verifyDiscoverMoreStoriesButton(composeTestRule: ComposeTestRule, position: Int) {
|
||||
composeTestRule.onNodeWithTag("pocket.stories")
|
||||
.assertIsDisplayed()
|
||||
.onChildAt(position - 1)
|
||||
.assert(hasTestTag("pocket.discover.more.story"))
|
||||
fun verifyDiscoverMoreStoriesButton() {
|
||||
pocketStoriesList
|
||||
.scrollIntoView(UiSelector().text("Discover more"))
|
||||
assertTrue(
|
||||
mDevice.findObject(UiSelector().text("Discover more"))
|
||||
.waitForExists(waitingTimeShort),
|
||||
)
|
||||
}
|
||||
|
||||
fun verifyStoriesByTopic(enabled: Boolean) {
|
||||
@ -444,8 +457,10 @@ class HomeScreenRobot {
|
||||
}
|
||||
}
|
||||
|
||||
fun verifyStoriesByTopicItems() =
|
||||
fun verifyStoriesByTopicItems() {
|
||||
homeScreenList().scrollIntoView(UiSelector().resourceId("pocket.categories"))
|
||||
assertTrue(mDevice.findObject(UiSelector().resourceId("pocket.categories")).childCount > 1)
|
||||
}
|
||||
|
||||
fun verifyStoriesByTopicItemState(composeTestRule: ComposeTestRule, isSelected: Boolean, position: Int) {
|
||||
homeScreenList().scrollIntoView(mDevice.findObject(UiSelector().resourceId("pocket.header")))
|
||||
@ -462,10 +477,9 @@ class HomeScreenRobot {
|
||||
fun clickStoriesByTopicItem(composeTestRule: ComposeTestRule, position: Int) =
|
||||
storyByTopicItem(composeTestRule, position).performClick()
|
||||
|
||||
fun verifyPoweredByPocket(rule: ComposeTestRule) {
|
||||
fun verifyPoweredByPocket() {
|
||||
homeScreenList().scrollIntoView(mDevice.findObject(UiSelector().resourceId("pocket.header")))
|
||||
rule.onNodeWithTag("pocket.header.title", true).assertIsDisplayed()
|
||||
rule.onNodeWithTag("pocket.header.subtitle", true).assertIsDisplayed()
|
||||
assertTrue(mDevice.findObject(UiSelector().resourceId("pocket.header.title")).exists())
|
||||
}
|
||||
|
||||
fun verifyCustomizeHomepageButton(enabled: Boolean) {
|
||||
@ -832,12 +846,14 @@ class HomeScreenRobot {
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
|
||||
fun clickPocketDiscoverMoreButton(composeTestRule: ComposeTestRule, position: Int, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
composeTestRule.onNodeWithTag("pocket.stories")
|
||||
.assertIsDisplayed()
|
||||
.onChildAt(position - 1)
|
||||
.assert(hasTestTag("pocket.discover.more.story"))
|
||||
.performClick()
|
||||
fun clickPocketDiscoverMoreButton(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
pocketStoriesList
|
||||
.scrollIntoView(UiSelector().text("Discover more"))
|
||||
|
||||
mDevice.findObject(UiSelector().text("Discover more")).also {
|
||||
it.waitForExists(waitingTimeShort)
|
||||
it.click()
|
||||
}
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
@ -1185,3 +1201,6 @@ private val sponsorsAndPrivacyButton =
|
||||
.textContains(getStringResource(R.string.top_sites_menu_sponsor_privacy))
|
||||
.resourceId("$packageName:id/simple_text"),
|
||||
)
|
||||
|
||||
private val pocketStoriesList =
|
||||
UiScrollable(UiSelector().resourceId("pocket.stories")).setAsHorizontalList()
|
||||
|
Loading…
Reference in New Issue
Block a user