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
10 import org.mozilla.fenix.customannotations.SmokeTest
11 import org.mozilla.fenix.helpers.HomeActivityTestRule
12 import org.mozilla.fenix.helpers.RetryTestRule
13 import org.mozilla.fenix.helpers.TestAssetHelper
14 import org.mozilla.fenix.helpers.TestHelper
15 import org.mozilla.fenix.helpers.TestSetup
16 import org.mozilla.fenix.ui.robots.homeScreen
17 import org.mozilla.fenix.ui.robots.navigationToolbar
18 import org.mozilla.fenix.ui.robots.searchScreen
21 * Tests for verifying the presence of home screen and first-run homescreen elements
23 * Note: For private browsing, navigation bar and tabs see separate test class
27 class HomeScreenTest : TestSetup() {
29 val activityTestRule =
30 AndroidComposeTestRule(HomeActivityTestRule.withDefaultSettingsOverrides()) { it.activity }
34 val retryTestRule = RetryTestRule(3)
36 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/235396
38 fun homeScreenItemsTest() {
39 // Workaround to make sure the Pocket articles are populated before starting the test.
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 {
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())
109 closeTabWithTitle(secondWebPage.title)
114 verifyJumpBackInSectionIsDisplayed()
115 verifyJumpBackInItemTitle(activityTestRule, firstWebPage.title)
116 verifyJumpBackInItemWithUrl(activityTestRule, firstWebPage.url.toString())
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)
150 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/414970
153 fun addPrivateBrowsingShortcutFromHomeScreenCFRTest() {
155 }.triggerPrivateBrowsingShortcutPrompt {
156 verifyNoThanksPrivateBrowsingShortcutButton(activityTestRule)
157 verifyAddPrivateBrowsingShortcutButton(activityTestRule)
158 clickAddPrivateBrowsingShortcutButton(activityTestRule)
159 clickAddAutomaticallyButton()
160 }.openHomeScreenShortcut("Private ${TestHelper.appName}") {}
164 verifyCommonMythsLink()
168 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1569867
170 fun verifyJumpBackInContextualHintTest() {
171 activityTestRule.activityRule.applySettingsExceptions {
172 it.isJumpBackInCFREnabled = true
175 val genericPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
178 }.enterURLAndEnterToBrowser(genericPage.url) {
180 verifyJumpBackInMessage(activityTestRule)