Bug 1807283 - re-enable verifyJumpBackInSectionTest UI test

fenix/112.0
AndiAJ 1 year ago committed by mergify[bot]
parent 5315062482
commit 053eb11df3

@ -127,7 +127,6 @@ class HomeScreenTest {
}
}
@Ignore("Failing, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1807283")
@Test
fun verifyJumpBackInSectionTest() {
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 4)
@ -135,27 +134,39 @@ class HomeScreenTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(firstWebPage.url) {
verifyPageContent(firstWebPage.content)
verifyUrl(firstWebPage.url.toString())
}.goToHomescreen {
verifyJumpBackInSectionIsDisplayed()
verifyJumpBackInItemTitle(firstWebPage.title)
verifyJumpBackInItemWithUrl(firstWebPage.url.toString())
verifyJumpBackInItemTitle(activityTestRule, firstWebPage.title)
verifyJumpBackInItemWithUrl(activityTestRule, firstWebPage.url.toString())
verifyJumpBackInShowAllButton()
}.clickJumpBackInShowAllButton {
verifyExistingOpenTabs(firstWebPage.title)
}.closeTabDrawer {
}
homeScreen {
}.clickJumpBackInItemWithTitle(firstWebPage.title) {
verifyUrl(firstWebPage.url.toString())
clickLinkMatchingText("Link 1")
navigationToolbar {
}.enterURLAndEnterToBrowser(secondWebPage.url) {
verifyPageContent(secondWebPage.content)
verifyUrl(secondWebPage.url.toString())
}.goToHomescreen {
verifyJumpBackInSectionIsDisplayed()
verifyJumpBackInItemTitle(secondWebPage.title)
verifyJumpBackInItemWithUrl(secondWebPage.url.toString())
verifyJumpBackInItemTitle(activityTestRule, secondWebPage.title)
verifyJumpBackInItemWithUrl(activityTestRule, secondWebPage.url.toString())
}.openTabDrawer {
closeTabWithTitle(secondWebPage.title)
}.closeTabDrawer {
}
homeScreen {
verifyJumpBackInSectionIsDisplayed()
verifyJumpBackInItemTitle(activityTestRule, firstWebPage.title)
verifyJumpBackInItemWithUrl(activityTestRule, firstWebPage.url.toString())
}.openTabDrawer {
closeTab()
}
homeScreen {
verifyJumpBackInSectionIsNotDisplayed()
}

@ -295,8 +295,10 @@ class HomeScreenRobot {
assertTrue(jumpBackInSection().waitForExists(waitingTime))
}
fun verifyJumpBackInSectionIsNotDisplayed() = assertJumpBackInSectionIsNotDisplayed()
fun verifyJumpBackInItemTitle(itemTitle: String) = assertJumpBackInItemTitle(itemTitle)
fun verifyJumpBackInItemWithUrl(itemUrl: String) = assertJumpBackInItemWithUrl(itemUrl)
fun verifyJumpBackInItemTitle(testRule: ComposeTestRule, itemTitle: String) =
assertJumpBackInItemTitle(testRule, itemTitle)
fun verifyJumpBackInItemWithUrl(testRule: ComposeTestRule, itemUrl: String) =
assertJumpBackInItemWithUrl(testRule, itemUrl)
fun verifyJumpBackInShowAllButton() = assertJumpBackInShowAllButton()
fun verifyRecentlyVisitedSectionIsDisplayed() = assertRecentlyVisitedSectionIsDisplayed()
fun verifyRecentlyVisitedSectionIsNotDisplayed() = assertRecentlyVisitedSectionIsNotDisplayed()
@ -990,25 +992,11 @@ private fun assertTopSiteContextMenuItems() {
private fun assertJumpBackInSectionIsNotDisplayed() = assertFalse(jumpBackInSection().waitForExists(waitingTimeShort))
private fun assertJumpBackInItemTitle(itemTitle: String) =
assertTrue(
mDevice
.findObject(
UiSelector()
.resourceId("recent.tab.title")
.textContains(itemTitle),
).waitForExists(waitingTime),
)
private fun assertJumpBackInItemTitle(testRule: ComposeTestRule, itemTitle: String) =
testRule.onNodeWithTag("recent.tab.title", useUnmergedTree = true).assert(hasText(itemTitle))
private fun assertJumpBackInItemWithUrl(itemUrl: String) =
assertTrue(
mDevice
.findObject(
UiSelector()
.resourceId("recent.tab.url")
.textContains(itemUrl),
).waitForExists(waitingTime),
)
private fun assertJumpBackInItemWithUrl(testRule: ComposeTestRule, itemUrl: String) =
testRule.onNodeWithTag("recent.tab.url", useUnmergedTree = true).assert(hasText(itemUrl))
private fun assertJumpBackInShowAllButton() =
assertTrue(

@ -37,6 +37,7 @@ import org.hamcrest.CoreMatchers.anyOf
import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.Matcher
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndDescription
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeLong
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort
@ -108,6 +109,15 @@ class TabDrawerRobot {
} while (closeTabButton().exists() && retries < 3)
}
fun closeTabWithTitle(title: String) =
itemWithResIdAndDescription(
"$packageName:id/mozac_browser_tabstray_close",
"Close tab $title",
).also {
it.waitForExists(waitingTime)
it.click()
}
fun swipeTabRight(title: String) {
var retries = 0 // number of retries before failing, will stop at 2
while (!tabItem(title).waitUntilGone(waitingTimeShort) && retries < 3

Loading…
Cancel
Save