Skip to content

Commit

Permalink
For mozilla-mobile#16615: UI Smoke Tests for Bookmarks
Browse files Browse the repository at this point in the history
For mozilla-mobile#16615: UI Smoke Tests for Bookmarks
  • Loading branch information
AndiAJ authored and pkirakosyan committed Aug 4, 2021
1 parent f67733e commit 9b4bd15
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class BookmarksTest {
}

bookmarksMenu {
verifyEmptyBookmarksList()
verifyDeleteMultipleBookmarksSnackBar()
}
}

Expand Down
44 changes: 44 additions & 0 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class SmokeTest {
var url = "https://www.ecosia.org/search?q=%s"
}
val collectionName = "First Collection"
private var bookmarksListIdlingResource: RecyclerViewIdlingResource? = null

// This finds the dialog fragment child of the homeFragment, otherwise the awesomeBar would return null
private fun getAwesomebarView(): View? {
Expand Down Expand Up @@ -97,6 +98,10 @@ class SmokeTest {
}

deleteDownloadFromStorage(downloadFileName)

if (bookmarksListIdlingResource != null) {
IdlingRegistry.getInstance().unregister(bookmarksListIdlingResource!!)
}
}

// copied over from HomeScreenTest
Expand Down Expand Up @@ -951,4 +956,43 @@ class SmokeTest {
verifyNoCollectionsText()
}
}

@Test
// Verifies that deleting a Bookmarks folder also removes the item from inside it.
fun deleteNonEmptyBookmarkFolderTest() {
val website = TestAssetHelper.getGenericAsset(mockWebServer, 1)

browserScreen {
createBookmark(website.url)
}.openThreeDotMenu {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list), 1)
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
verifyBookmarkTitle("Test_Page_1")
createFolder("My Folder")
verifyFolderTitle("My Folder")
IdlingRegistry.getInstance().unregister(bookmarksListIdlingResource!!)
}.openThreeDotMenu("Test_Page_1") {
}.clickEdit {
clickParentFolderSelector()
selectFolder("My Folder")
navigateUp()
saveEditBookmark()
}.openThreeDotMenu("My Folder") {
}.clickDelete {
cancelFolderDeletion()
verifyFolderTitle("My Folder")
}.openThreeDotMenu("My Folder") {
}.clickDelete {
confirmFolderDeletion()
verifyDeleteSnackBarText()
navigateUp()
}

browserScreen {
}.openThreeDotMenu {
verifyBookmarksButton()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withParent
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.By.res
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.containsString
import org.junit.Assert.assertEquals
Expand All @@ -52,7 +52,7 @@ class BookmarksRobot {
assertBookmarksView()
}

fun verifyEmptyBookmarksList() = assertEmptyBookmarksList()
fun verifyDeleteMultipleBookmarksSnackBar() = assertSnackBarText("Bookmarks deleted")

fun verifyBookmarkFavicon(forUrl: Uri) = assertBookmarkFavicon(forUrl)

Expand Down Expand Up @@ -119,6 +119,13 @@ class BookmarksRobot {

fun verifyDeleteFolderConfirmationMessage() = assertDeleteFolderConfirmationMessage()

fun cancelFolderDeletion() {
onView(withText("CANCEL"))
.inRoot(RootMatchers.isDialog())
.check(matches(isDisplayed()))
.click()
}

fun createFolder(name: String) {
clickAddFolderButton()
addNewFolderName(name)
Expand Down

0 comments on commit 9b4bd15

Please sign in to comment.