mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/27522 new search codes UI tests
This commit is contained in:
parent
74c551336e
commit
ff2f457832
@ -21,4 +21,10 @@ object Constants {
|
|||||||
const val LONG_CLICK_DURATION: Long = 5000
|
const val LONG_CLICK_DURATION: Long = 5000
|
||||||
const val LISTS_MAXSWIPES: Int = 3
|
const val LISTS_MAXSWIPES: Int = 3
|
||||||
const val RETRY_COUNT = 3
|
const val RETRY_COUNT = 3
|
||||||
|
|
||||||
|
val searchEngineCodes = mapOf(
|
||||||
|
"Google" to "client=firefox-b-m",
|
||||||
|
"Bing" to "firefox&pc=MOZB&form=MOZMBA",
|
||||||
|
"DuckDuckGo" to "t=fpas",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import org.junit.Rule
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mozilla.fenix.customannotations.SmokeTest
|
import org.mozilla.fenix.customannotations.SmokeTest
|
||||||
import org.mozilla.fenix.helpers.Constants.PackageName.ANDROID_SETTINGS
|
import org.mozilla.fenix.helpers.Constants.PackageName.ANDROID_SETTINGS
|
||||||
|
import org.mozilla.fenix.helpers.Constants.searchEngineCodes
|
||||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||||
import org.mozilla.fenix.helpers.SearchDispatcher
|
import org.mozilla.fenix.helpers.SearchDispatcher
|
||||||
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
||||||
@ -45,6 +46,7 @@ import org.mozilla.fenix.ui.robots.multipleSelectionToolbar
|
|||||||
|
|
||||||
class SearchTest {
|
class SearchTest {
|
||||||
lateinit var searchMockServer: MockWebServer
|
lateinit var searchMockServer: MockWebServer
|
||||||
|
lateinit var queryString: String
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityTestRule = AndroidComposeTestRule(
|
val activityTestRule = AndroidComposeTestRule(
|
||||||
@ -117,6 +119,8 @@ class SearchTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun setDefaultSearchEngineFromShortcutsTest() {
|
fun setDefaultSearchEngineFromShortcutsTest() {
|
||||||
|
queryString = "firefox"
|
||||||
|
|
||||||
homeScreen {
|
homeScreen {
|
||||||
}.openThreeDotMenu {
|
}.openThreeDotMenu {
|
||||||
}.openSettings {
|
}.openSettings {
|
||||||
@ -134,16 +138,18 @@ class SearchTest {
|
|||||||
|
|
||||||
homeScreen {
|
homeScreen {
|
||||||
}.openSearch {
|
}.openSearch {
|
||||||
}.submitQuery("firefox") {
|
}.submitQuery(queryString) {
|
||||||
verifyUrl("duckduckgo.com/?q=firefox")
|
verifyUrl("duckduckgo.com/?q=firefox")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun clearSearchTest() {
|
fun clearSearchTest() {
|
||||||
|
queryString = "test"
|
||||||
|
|
||||||
homeScreen {
|
homeScreen {
|
||||||
}.openSearch {
|
}.openSearch {
|
||||||
typeSearch("test")
|
typeSearch(queryString)
|
||||||
clickClearButton()
|
clickClearButton()
|
||||||
verifySearchBarEmpty()
|
verifySearchBarEmpty()
|
||||||
}
|
}
|
||||||
@ -153,6 +159,7 @@ class SearchTest {
|
|||||||
@SmokeTest
|
@SmokeTest
|
||||||
@Test
|
@Test
|
||||||
fun searchGroupShowsInRecentlyVisitedTest() {
|
fun searchGroupShowsInRecentlyVisitedTest() {
|
||||||
|
queryString = "test search"
|
||||||
val firstPage = getGenericAsset(searchMockServer, 1)
|
val firstPage = getGenericAsset(searchMockServer, 1)
|
||||||
val secondPage = getGenericAsset(searchMockServer, 2)
|
val secondPage = getGenericAsset(searchMockServer, 2)
|
||||||
// setting our custom mockWebServer search URL
|
// setting our custom mockWebServer search URL
|
||||||
@ -168,7 +175,7 @@ class SearchTest {
|
|||||||
// Performs a search and opens 2 dummy search results links to create a search group
|
// Performs a search and opens 2 dummy search results links to create a search group
|
||||||
homeScreen {
|
homeScreen {
|
||||||
}.openSearch {
|
}.openSearch {
|
||||||
}.submitQuery("test search") {
|
}.submitQuery(queryString) {
|
||||||
longClickLink("Link 1")
|
longClickLink("Link 1")
|
||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
longClickLink("Link 2")
|
longClickLink("Link 2")
|
||||||
@ -180,13 +187,14 @@ class SearchTest {
|
|||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTabsListThreeDotMenu {
|
}.openTabsListThreeDotMenu {
|
||||||
}.closeAllTabs {
|
}.closeAllTabs {
|
||||||
verifyRecentlyVisitedSearchGroupDisplayed(true, "test search", 3)
|
verifyRecentlyVisitedSearchGroupDisplayed(true, queryString, 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SmokeTest
|
@SmokeTest
|
||||||
@Test
|
@Test
|
||||||
fun noSearchGroupFromPrivateBrowsingTest() {
|
fun noSearchGroupFromPrivateBrowsingTest() {
|
||||||
|
queryString = "test search"
|
||||||
// setting our custom mockWebServer search URL
|
// setting our custom mockWebServer search URL
|
||||||
val searchString = "http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
|
val searchString = "http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
|
||||||
val customSearchEngine = createSearchEngine(
|
val customSearchEngine = createSearchEngine(
|
||||||
@ -199,7 +207,7 @@ class SearchTest {
|
|||||||
// Performs a search and opens 2 dummy search results links to create a search group
|
// Performs a search and opens 2 dummy search results links to create a search group
|
||||||
homeScreen {
|
homeScreen {
|
||||||
}.openSearch {
|
}.openSearch {
|
||||||
}.submitQuery("test search") {
|
}.submitQuery(queryString) {
|
||||||
longClickLink("Link 1")
|
longClickLink("Link 1")
|
||||||
clickContextOpenLinkInPrivateTab()
|
clickContextOpenLinkInPrivateTab()
|
||||||
longClickLink("Link 2")
|
longClickLink("Link 2")
|
||||||
@ -213,7 +221,7 @@ class SearchTest {
|
|||||||
}.openTabsListThreeDotMenu {
|
}.openTabsListThreeDotMenu {
|
||||||
}.closeAllTabs {
|
}.closeAllTabs {
|
||||||
togglePrivateBrowsingModeOnOff()
|
togglePrivateBrowsingModeOnOff()
|
||||||
verifyCurrentSearchGroupIsDisplayed(false, "test search", 3)
|
verifyCurrentSearchGroupIsDisplayed(false, queryString, 3)
|
||||||
}.openThreeDotMenu {
|
}.openThreeDotMenu {
|
||||||
}.openHistory {
|
}.openHistory {
|
||||||
verifyHistoryItemExists(false, "3 sites")
|
verifyHistoryItemExists(false, "3 sites")
|
||||||
@ -224,6 +232,7 @@ class SearchTest {
|
|||||||
@SmokeTest
|
@SmokeTest
|
||||||
@Test
|
@Test
|
||||||
fun deleteItemsFromSearchGroupsHistoryTest() {
|
fun deleteItemsFromSearchGroupsHistoryTest() {
|
||||||
|
queryString = "test search"
|
||||||
val firstPage = getGenericAsset(searchMockServer, 1)
|
val firstPage = getGenericAsset(searchMockServer, 1)
|
||||||
val secondPage = getGenericAsset(searchMockServer, 2)
|
val secondPage = getGenericAsset(searchMockServer, 2)
|
||||||
// setting our custom mockWebServer search URL
|
// setting our custom mockWebServer search URL
|
||||||
@ -238,7 +247,7 @@ class SearchTest {
|
|||||||
// Performs a search and opens 2 dummy search results links to create a search group
|
// Performs a search and opens 2 dummy search results links to create a search group
|
||||||
homeScreen {
|
homeScreen {
|
||||||
}.openSearch {
|
}.openSearch {
|
||||||
}.submitQuery("test search") {
|
}.submitQuery(queryString) {
|
||||||
longClickLink("Link 1")
|
longClickLink("Link 1")
|
||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
longClickLink("Link 2")
|
longClickLink("Link 2")
|
||||||
@ -250,8 +259,8 @@ class SearchTest {
|
|||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTabsListThreeDotMenu {
|
}.openTabsListThreeDotMenu {
|
||||||
}.closeAllTabs {
|
}.closeAllTabs {
|
||||||
verifyRecentlyVisitedSearchGroupDisplayed(true, "test search", 3)
|
verifyRecentlyVisitedSearchGroupDisplayed(true, queryString, 3)
|
||||||
}.openRecentlyVisitedSearchGroupHistoryList("test search") {
|
}.openRecentlyVisitedSearchGroupHistoryList(queryString) {
|
||||||
clickDeleteHistoryButton(firstPage.url.toString())
|
clickDeleteHistoryButton(firstPage.url.toString())
|
||||||
longTapSelectItem(secondPage.url)
|
longTapSelectItem(secondPage.url)
|
||||||
multipleSelectionToolbar {
|
multipleSelectionToolbar {
|
||||||
@ -262,7 +271,61 @@ class SearchTest {
|
|||||||
}
|
}
|
||||||
homeScreen {
|
homeScreen {
|
||||||
// checking that the group is removed when only 1 item is left
|
// checking that the group is removed when only 1 item is left
|
||||||
verifyRecentlyVisitedSearchGroupDisplayed(false, "test search", 1)
|
verifyRecentlyVisitedSearchGroupDisplayed(false, queryString, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default search code for Google-US
|
||||||
|
@Test
|
||||||
|
fun defaultSearchCodeGoogleUS() {
|
||||||
|
queryString = "firefox"
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
}.openSearch {
|
||||||
|
}.submitQuery(queryString) {
|
||||||
|
verifyUrl(searchEngineCodes["Google"]!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default search code for Bing-US
|
||||||
|
@Test
|
||||||
|
fun defaultSearchCodeBingUS() {
|
||||||
|
queryString = "firefox"
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSettings {
|
||||||
|
}.openSearchSubMenu {
|
||||||
|
changeDefaultSearchEngine("Bing")
|
||||||
|
}
|
||||||
|
|
||||||
|
exitMenu()
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
}.openSearch {
|
||||||
|
}.submitQuery(queryString) {
|
||||||
|
verifyUrl(searchEngineCodes["Bing"]!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default search code for DuckDuckGo-US
|
||||||
|
@Test
|
||||||
|
fun defaultSearchCodeDuckDuckGoUS() {
|
||||||
|
queryString = "firefox"
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSettings {
|
||||||
|
}.openSearchSubMenu {
|
||||||
|
changeDefaultSearchEngine("DuckDuckGo")
|
||||||
|
}
|
||||||
|
|
||||||
|
exitMenu()
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
}.openSearch {
|
||||||
|
}.submitQuery(queryString) {
|
||||||
|
verifyUrl(searchEngineCodes["DuckDuckGo"]!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user