1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.fenix.ui
7 import androidx.compose.ui.test.junit4.AndroidComposeTestRule
8 import org.junit.Ignore
11 import org.mozilla.fenix.customannotations.SmokeTest
12 import org.mozilla.fenix.helpers.HomeActivityTestRule
13 import org.mozilla.fenix.helpers.RetryTestRule
14 import org.mozilla.fenix.helpers.TestAssetHelper
15 import org.mozilla.fenix.helpers.TestSetup
16 import org.mozilla.fenix.ui.robots.homeScreen
17 import org.mozilla.fenix.ui.robots.navigationToolbar
20 * Tests for verifying the presence of home screen and first-run homescreen elements
22 * Note: For private browsing, navigation bar and tabs see separate test class
26 class ComposeHomeScreenTest : TestSetup() {
28 val activityTestRule =
29 AndroidComposeTestRule(
30 HomeActivityTestRule.withDefaultSettingsOverrides(
31 tabsTrayRewriteEnabled = true,
37 val retryTestRule = RetryTestRule(3)
39 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/235396
40 @Ignore("Failing, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1844580")
42 fun homeScreenItemsTest() {
45 verifyHomePrivateBrowsingButton()
46 verifyExistingTopSitesTabs("Wikipedia")
47 verifyExistingTopSitesTabs("Top Articles")
48 verifyExistingTopSitesTabs("Google")
49 verifyCollectionsHeader()
50 verifyNoCollectionsText()
51 scrollToPocketProvokingStories()
52 verifyThoughtProvokingStories(true)
53 verifyStoriesByTopicItems()
54 verifyCustomizeHomepageButton(true)
55 verifyNavigationToolbar()
56 verifyHomeMenuButton()
62 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/244199
64 fun privateBrowsingHomeScreenItemsTest() {
65 homeScreen { }.togglePrivateBrowsingMode()
68 verifyPrivateBrowsingHomeScreenItems()
69 }.openCommonMythsLink {
70 verifyUrl("common-myths-about-private-browsing")
74 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1364362
77 fun verifyJumpBackInSectionTest() {
78 activityTestRule.activityRule.applySettingsExceptions {
79 it.isRecentlyVisitedFeatureEnabled = false
80 it.isPocketEnabled = false
83 val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 4)
84 val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
87 }.enterURLAndEnterToBrowser(firstWebPage.url) {
88 verifyPageContent(firstWebPage.content)
89 verifyUrl(firstWebPage.url.toString())
91 verifyJumpBackInSectionIsDisplayed()
92 verifyJumpBackInItemTitle(activityTestRule, firstWebPage.title)
93 verifyJumpBackInItemWithUrl(activityTestRule, firstWebPage.url.toString())
94 verifyJumpBackInShowAllButton()
95 }.clickJumpBackInShowAllButton(activityTestRule) {
96 verifyExistingOpenTabs(firstWebPage.title)
101 }.enterURLAndEnterToBrowser(secondWebPage.url) {
102 verifyPageContent(secondWebPage.content)
103 verifyUrl(secondWebPage.url.toString())
105 verifyJumpBackInSectionIsDisplayed()
106 verifyJumpBackInItemTitle(activityTestRule, secondWebPage.title)
107 verifyJumpBackInItemWithUrl(activityTestRule, secondWebPage.url.toString())
108 }.openComposeTabDrawer(activityTestRule) {
109 closeTabWithTitle(secondWebPage.title)
114 verifyJumpBackInSectionIsDisplayed()
115 verifyJumpBackInItemTitle(activityTestRule, firstWebPage.title)
116 verifyJumpBackInItemWithUrl(activityTestRule, firstWebPage.url.toString())
117 }.openComposeTabDrawer(activityTestRule) {
122 verifyJumpBackInSectionIsNotDisplayed()
126 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1569839
128 fun verifyCustomizeHomepageButtonTest() {
129 val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
132 }.enterURLAndEnterToBrowser(defaultWebPage.url) {
134 }.openCustomizeHomepage {
135 clickShortcutsButton()
136 clickJumpBackInButton()
137 clickRecentBookmarksButton()
138 clickRecentSearchesButton()
140 }.goBackToHomeScreen {
141 verifyCustomizeHomepageButton(false)
143 }.openCustomizeHome {
144 clickShortcutsButton()
145 }.goBackToHomeScreen {
146 verifyCustomizeHomepageButton(true)