For #16615: Collections UI smoke tests

upstream-sync
Oana Horvath 3 years ago
parent 093470a8b3
commit 58cefbbb94

@ -52,40 +52,6 @@
//
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
// @Test
// fun verifyCreateFirstCollectionFlowItems() {
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
// val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
//
// navigationToolbar {
// }.enterURLAndEnterToBrowser(firstWebPage.url) {
// }.openHomeScreen {
// }.openNavigationToolbar {
// }.enterURLAndEnterToBrowser(secondWebPage.url) {
// }.openTabDrawer {
// }.openTabsListThreeDotMenu {
// verifySaveCollection()
// }.clickOpenTabsMenuSaveCollection {
// clickSaveCollectionButton()
// verifySelectTabsView()
// selectAllTabsForCollection()
// verifyTabsSelectedCounterText(2)
// deselectAllTabsForCollection()
// verifyTabsSelectedCounterText(0)
// selectTabForCollection(firstWebPage.title)
// verifyTabsSelectedCounterText(1)
// selectAllTabsForCollection()
// saveTabsSelectedForCollection()
// verifyNameCollectionView()
// verifyDefaultCollectionName("Collection 1")
// typeCollectionName(firstCollectionName)
// verifySnackBarText("Tabs saved!")
//// verifyExistingOpenTabs(firstWebPage.title)
//// verifyExistingOpenTabs(secondWebPage.title)
// }
// }
//
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
// @Test
// // open a webpage, and add currently opened tab to existing collection
// fun addTabToExistingCollectionTest() {
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
@ -135,23 +101,6 @@
//
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
// @Test
// fun collectionMenuOpenAllTabsTest() {
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
//
// createCollection(firstCollectionName)
//
// homeScreen {
// closeTab()
// expandCollection(firstCollectionName)
// clickCollectionThreeDotButton()
// selectOpenTabs()
// }.openTabDrawer {
// verifyExistingOpenTabs(firstWebPage.title)
// }
// }
//
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
// @Test
// fun renameCollectionTest() {
// createCollection(firstCollectionName)
//
@ -167,20 +116,6 @@
//
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
// @Test
// fun deleteCollectionTest() {
// createCollection(firstCollectionName)
//
// homeScreen {
// expandCollection(firstCollectionName)
// clickCollectionThreeDotButton()
// selectDeleteCollection()
// confirmDeleteCollection()
// verifyNoCollectionsHeader()
// }
// }
//
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
// @Test
// fun createCollectionFromTabTest() {
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
//
@ -199,42 +134,6 @@
//
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
// @Test
// fun verifyExpandedCollectionItemsTest() {
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
//
// createCollection(firstCollectionName)
//
// homeScreen {
// verifyCollectionIsDisplayed(firstCollectionName)
// verifyCollectionIcon()
// expandCollection(firstCollectionName)
// verifyItemInCollectionExists(firstWebPage.title)
// verifyCollectionItemLogo()
// verifyCollectionItemUrl()
// verifyShareCollectionButtonIsVisible(true)
// verifyCollectionMenuIsVisible(true)
// verifyCollectionItemRemoveButtonIsVisible(firstWebPage.title, true)
// collapseCollection(firstCollectionName)
// verifyItemInCollectionExists(firstWebPage.title, false)
// verifyShareCollectionButtonIsVisible(false)
// verifyCollectionMenuIsVisible(false)
// verifyCollectionItemRemoveButtonIsVisible(firstWebPage.title, false)
// }
// }
//
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
// @Test
// fun shareCollectionTest() {
// createCollection(firstCollectionName)
// homeScreen {
// expandCollection(firstCollectionName)
// clickShareCollectionButton()
// verifyShareTabsOverlay()
// }
// }
//
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
// @Test
// fun removeTabFromCollectionTest() {
// val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
//

@ -30,6 +30,7 @@ import org.mozilla.fenix.ui.robots.downloadRobot
import org.mozilla.fenix.ui.robots.enhancedTrackingProtection
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
import org.mozilla.fenix.ui.robots.tabDrawer
/**
* Test Suite that contains tests defined as part of the Smoke and Sanity check defined in Test rail.
@ -48,6 +49,7 @@ class SmokeTest {
var title = "Ecosia"
var url = "https://www.ecosia.org/search?q=%s"
}
val collectionName = "First Collection"
// This finds the dialog fragment child of the homeFragment, otherwise the awesomeBar would return null
private fun getAwesomebarView(): View? {
@ -836,4 +838,117 @@ class SmokeTest {
verifyEmptyDownloadsList()
}
}
@Test
fun createFirstCollectionTest() {
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
navigationToolbar {
}.enterURLAndEnterToBrowser(firstWebPage.url) {
mDevice.waitForIdle()
}.openTabDrawer {
}.openNewTab {
}.submitQuery(secondWebPage.url.toString()) {
mDevice.waitForIdle()
}.goToHomescreen {
}.clickSaveTabsToCollectionButton {
selectTab(firstWebPage.title)
selectTab(secondWebPage.title)
clickSaveCollection()
typeCollectionName(collectionName)
verifySnackBarText("Collection saved!")
snackBarButtonClick("VIEW")
}
homeScreen {
verifyCollectionIsDisplayed(collectionName)
verifyCollectionIcon()
}
}
@Test
fun verifyExpandedCollectionItemsTest() {
val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(webPage.url) {
}.openTabDrawer {
createCollection(webPage.title, collectionName)
snackBarButtonClick("VIEW")
}
homeScreen {
verifyCollectionIsDisplayed(collectionName)
verifyCollectionIcon()
expandCollection(collectionName)
verifyTabSavedInCollection(webPage.title)
verifyCollectionTabLogo()
verifyCollectionTabUrl()
verifyShareCollectionButtonIsVisible(true)
verifyCollectionMenuIsVisible(true)
verifyCollectionItemRemoveButtonIsVisible(webPage.title, true)
collapseCollection(collectionName)
verifyTabSavedInCollection(webPage.title, false)
verifyShareCollectionButtonIsVisible(false)
verifyCollectionMenuIsVisible(false)
}
}
@Test
fun openAllTabsInCollectionTest() {
val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(webPage.url) {
}.openTabDrawer {
createCollection(webPage.title, collectionName)
closeTab()
}
browserScreen {
}.goToHomescreen {
expandCollection(collectionName)
clickCollectionThreeDotButton()
selectOpenTabs()
}
tabDrawer {
verifyExistingOpenTabs(webPage.title)
}
}
@Test
fun shareCollectionTest() {
val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(webPage.url) {
}.openTabDrawer {
createCollection(webPage.title, collectionName)
snackBarButtonClick("VIEW")
}
homeScreen {
expandCollection(collectionName)
clickShareCollectionButton()
verifyShareTabsOverlay()
}
}
@Test
fun deleteCollectionTest() {
val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(webPage.url) {
}.openTabDrawer {
createCollection(webPage.title, collectionName)
snackBarButtonClick("VIEW")
}
homeScreen {
expandCollection(collectionName)
clickCollectionThreeDotButton()
selectDeleteCollection()
confirmDeleteCollection()
verifyNoCollectionsText()
}
}
}

@ -445,6 +445,15 @@ class BrowserRobot {
NotificationRobot().interact()
return NotificationRobot.Transition()
}
fun goToHomescreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
openTabDrawer {
}.openNewTab {
}.dismissSearchBar {}
HomeScreenRobot().interact()
return HomeScreenRobot.Transition()
}
}
}

@ -14,7 +14,6 @@ import androidx.test.espresso.NoMatchingViewException
import androidx.test.espresso.ViewInteraction
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.longClick
import androidx.test.espresso.action.ViewActions.swipeLeft
import androidx.test.espresso.action.ViewActions.swipeRight
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
@ -74,7 +73,6 @@ class HomeScreenRobot {
fun verifyHomeMenu() = assertHomeMenu()
fun verifyTabButton() = assertTabButton()
fun verifyCollectionsHeader() = assertCollectionsHeader()
fun verifyNoCollectionsHeader() = assertNoCollectionsHeader()
fun verifyNoCollectionsText() = assertNoCollectionsText()
fun verifyHomeWordmark() = assertHomeWordmark()
fun verifyHomeToolbar() = assertHomeToolbar()
@ -152,25 +150,18 @@ class HomeScreenRobot {
fun confirmDeleteCollection() {
onView(allOf(withText("DELETE"))).click()
mDevice.waitNotNull(findObject(By.res("org.mozilla.fenix.debug:id/collections_header")), waitingTime)
}
fun typeCollectionName(name: String) {
mDevice.wait(findObject(By.res("org.mozilla.fenix.debug:id/name_collection_edittext")), waitingTime)
collectionNameTextField().perform(ViewActions.replaceText(name))
collectionNameTextField().perform(ViewActions.pressImeActionButton())
mDevice.waitNotNull(Until.gone(text("Name collection")))
mDevice.waitNotNull(
findObject(By.res("org.mozilla.fenix.debug:id/no_collections_header")),
waitingTime
)
}
fun saveTabsSelectedForCollection() = onView(withId(R.id.save_button)).click()
fun verifyCollectionIsDisplayed(title: String) {
mDevice.wait(findObject(text(title)), waitingTime)
mDevice.findObject(UiSelector().text(title)).waitForExists(waitingTime)
collectionTitle(title).check(matches(isDisplayed()))
}
fun verifyCollectionIcon() =
onView(withId(R.id.collection_icon)).check(matches(isDisplayed()))
fun verifyCollectionIcon() = onView(withId(R.id.collection_icon)).check(matches(isDisplayed()))
fun expandCollection(title: String) {
try {
@ -190,9 +181,7 @@ class HomeScreenRobot {
}
}
fun clickSaveCollectionButton() = saveCollectionButton().click()
fun verifyItemInCollectionExists(title: String, visible: Boolean = true) {
fun verifyTabSavedInCollection(title: String, visible: Boolean = true) {
try {
collectionItem(title)
.check(
@ -203,11 +192,11 @@ class HomeScreenRobot {
}
}
fun verifyCollectionItemLogo() =
onView(withId(R.id.list_item_favicon)).check(matches(isDisplayed()))
fun verifyCollectionTabLogo() =
onView(withId(R.id.favicon)).check(matches(isDisplayed()))
fun verifyCollectionItemUrl() =
onView(withId(R.id.list_item_url)).check(matches(isDisplayed()))
fun verifyCollectionTabUrl() =
onView(withId(R.id.caption)).check(matches(isDisplayed()))
fun verifyShareCollectionButtonIsVisible(visible: Boolean) {
shareCollectionButton()
@ -233,54 +222,6 @@ class HomeScreenRobot {
)
}
fun verifySelectTabsView(vararg tabTitles: String) {
onView(allOf(withId(R.id.back_button), withText("Select Tabs")))
.check(matches(isDisplayed()))
for (title in tabTitles)
onView(withId(R.id.tab_list)).check(matches(hasItem(withText(title))))
}
fun verifyTabsSelectedCounterText(tabsSelected: Int) {
when (tabsSelected) {
0 -> onView(withId(R.id.bottom_bar_text)).check(matches(withText("Select tabs to save")))
1 -> onView(withId(R.id.bottom_bar_text)).check(matches(withText("1 tab selected")))
else -> onView(withId(R.id.bottom_bar_text)).check(matches(withText("$tabsSelected tabs selected")))
}
}
fun selectAllTabsForCollection() {
onView(withId(R.id.select_all_button))
.check(matches(withText("Select All")))
.click()
}
fun deselectAllTabsForCollection() {
onView(withId(R.id.select_all_button))
.check(matches(withText("Deselect All")))
.click()
}
fun selectTabForCollection(title: String) {
tab(title).click()
}
fun clickAddNewCollection() =
onView(allOf(withText("Add new collection"))).click()
fun verifyNameCollectionView() {
onView(allOf(withId(R.id.back_button), withText("Name collection")))
.check(matches(isDisplayed()))
}
fun verifyDefaultCollectionName(name: String) =
onView(withId(R.id.name_collection_edittext)).check(matches(withText(name)))
fun verifySelectCollectionView() {
onView(allOf(withId(R.id.back_button), withText("Select collection")))
.check(matches(isDisplayed()))
}
fun verifyShareTabsOverlay() = assertShareTabsOverlay()
fun clickShareCollectionButton() = onView(withId(R.id.collection_share_button)).click()
@ -303,22 +244,12 @@ class HomeScreenRobot {
}
}
fun longTapSelectTab(title: String) {
tab(title).perform(longClick())
}
fun goBackCollectionFlow() = collectionFlowBackButton().click()
fun scrollToElementByText(text: String): UiScrollable {
val appView = UiScrollable(UiSelector().scrollable(true))
appView.scrollTextIntoView(text)
return appView
}
fun closeTab() {
closeTabButton().click()
}
fun togglePrivateBrowsingModeOnOff() {
onView(ViewMatchers.withResourceName("privateBrowsingButton"))
.perform(click())
@ -501,12 +432,11 @@ class HomeScreenRobot {
return BrowserRobot.Transition()
}
fun openTab(title: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.waitNotNull(findObject(text(title)))
tab(title).click()
fun clickSaveTabsToCollectionButton(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
saveTabsToCollectionButton().click()
BrowserRobot().interact()
return BrowserRobot.Transition()
TabDrawerRobot().interact()
return TabDrawerRobot.Transition()
}
}
}
@ -564,17 +494,14 @@ private fun assertCollectionsHeader() =
onView(allOf(withText("Collections")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertNoCollectionsHeader() =
onView(allOf(withText("Collect the things that matter to you")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertNoCollectionsText() =
onView(
allOf(
withText("Group together similar searches, sites, and tabs for quick access later.")
withText(
containsString("Collect the things that matter to you.\n" +
"Group together similar searches, sites, and tabs for quick access later."
)
)
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
).check(matches(isDisplayed()))
private fun assertHomeComponent() =
onView(ViewMatchers.withResourceName("sessionControlRecyclerView"))
@ -752,9 +679,6 @@ private fun assertPrivateSessionMessage() =
private fun collectionThreeDotButton() =
onView(allOf(withId(R.id.collection_overflow_button)))
private fun collectionNameTextField() =
onView(allOf(ViewMatchers.withResourceName("name_collection_edittext")))
private fun collectionTitle(title: String) =
onView(allOf(withId(R.id.collection_title), withText(title)))
@ -794,21 +718,20 @@ private fun assertShareTabsOverlay() {
private fun tabMediaControlButton() = onView(withId(R.id.play_pause_button))
private fun collectionItem(title: String) =
onView(allOf(withId(R.id.list_element_title), withText(title)))
onView(allOf(withId(R.id.label), withText(title)))
private fun saveCollectionButton() = onView(withId(R.id.save_tab_group_button))
private fun saveTabsToCollectionButton() = onView(withId(R.id.add_tabs_to_collections_button))
private fun shareCollectionButton() = onView(withId(R.id.collection_share_button))
private fun removeTabFromCollectionButton(title: String) =
onView(
allOf(
withId(R.id.list_item_action_button),
withId(R.id.secondary_button),
hasSibling(withText(title))
)
)
private fun collectionFlowBackButton() = onView(withId(R.id.back_button))
private fun tabsCounter() = onView(withId(R.id.tab_button))
private fun tab(title: String) =

@ -17,6 +17,7 @@ import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions
@ -67,6 +68,9 @@ class TabDrawerRobot {
fun verifyBehaviorState(expectedState: Int) = assertBehaviorState(expectedState)
fun closeTab() {
mDevice.findObject(
UiSelector().resourceId("org.mozilla.fenix.debug:id/mozac_browser_tabstray_close")
).waitForExists(waitingTime)
closeTabButton().click()
}
@ -92,6 +96,9 @@ class TabDrawerRobot {
}
fun snackBarButtonClick(expectedText: String) {
mDevice.findObject(
UiSelector().resourceId("org.mozilla.fenix.debug:id/snackbar_btn")
).waitForExists(waitingTime)
onView(allOf(withId(R.id.snackbar_btn), withText(expectedText))).check(
matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))
).perform(click())
@ -112,6 +119,32 @@ class TabDrawerRobot {
fun clickTabMediaControlButton() = tabMediaControlButton().click()
fun clickSelectTabs() = onView(withText("Select tabs")).click()
fun clickAddNewCollection() = addNewCollectionButton().click()
fun selectTab(title: String) = tab(title).click()
fun clickSaveCollection() = saveTabsToCollectionButton().click()
fun typeCollectionName(collectionName: String) {
collectionNameTextField().perform(replaceText(collectionName))
mDevice.findObject(UiSelector().textContains("OK")).click()
}
fun createCollection(
tabTitle: String,
collectionName: String,
firstCollection: Boolean = true
) {
clickSelectTabs()
selectTab(tabTitle)
clickSaveCollection()
if (!firstCollection)
clickAddNewCollection()
typeCollectionName(collectionName)
}
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
@ -236,8 +269,8 @@ class TabDrawerRobot {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.waitNotNull(
Until.findObject(text("Recently closed tabs")),
waitingTime
Until.findObject(text("Recently closed tabs")),
waitingTime
)
val menuRecentlyClosedTabs = mDevice.findObject(text("Recently closed tabs"))
@ -343,3 +376,9 @@ private fun tabsCounter() = onView(withId(R.id.tab_button))
private fun visibleOrGone(visibility: Boolean) =
if (visibility) ViewMatchers.Visibility.VISIBLE else ViewMatchers.Visibility.GONE
private fun addNewCollectionButton() = onView(withId(R.id.add_new_collection))
private fun saveTabsToCollectionButton() = onView(withId(R.id.collect_multi_select))
private fun collectionNameTextField() = onView(withId(R.id.collection_name))

@ -72,7 +72,7 @@ class ThreeDotMenuMainRobot {
fun verifySaveCollection() = assertSaveCollectionButton()
fun verifySelectTabs() = assertSelectTabsButton()
fun clickBrowserViewSaveCollectionButton() {
fun clickSaveCollectionButton() {
browserViewSaveCollectionButton().click()
}
@ -343,13 +343,6 @@ class ThreeDotMenuMainRobot {
return BrowserRobot.Transition()
}
fun clickOpenTabsMenuSaveCollection(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
saveCollectionButton().click()
HomeScreenRobot().interact()
return HomeScreenRobot.Transition()
}
fun openSaveToCollection(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
mDevice.waitNotNull(Until.findObject(By.text("Save to collection")), waitingTime)
saveCollectionButton().click()

Loading…
Cancel
Save