From 23bbffe22bbed70429f3b4c2299e09c191bec913 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Tue, 11 Apr 2023 15:44:21 +0300 Subject: [PATCH] Bug 1827406 - New connection error message UI test --- .../fenix/ui/BrowsingErrorPagesTest.kt | 38 +++++++++++++++++++ .../mozilla/fenix/ui/robots/BrowserRobot.kt | 9 +++++ 2 files changed, 47 insertions(+) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/BrowsingErrorPagesTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/BrowsingErrorPagesTest.kt index 2dde0c8f87..bdfa281d2d 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/BrowsingErrorPagesTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/BrowsingErrorPagesTest.kt @@ -5,6 +5,7 @@ package org.mozilla.fenix.ui import androidx.core.net.toUri +import org.junit.After import org.junit.Rule import org.junit.Test import org.mozilla.fenix.R @@ -12,6 +13,8 @@ import org.mozilla.fenix.customannotations.SmokeTest import org.mozilla.fenix.helpers.HomeActivityTestRule import org.mozilla.fenix.helpers.RetryTestRule import org.mozilla.fenix.helpers.TestHelper.getStringResource +import org.mozilla.fenix.helpers.TestHelper.setNetworkEnabled +import org.mozilla.fenix.ui.robots.browserScreen import org.mozilla.fenix.ui.robots.navigationToolbar /** @@ -31,6 +34,12 @@ class BrowsingErrorPagesTest { @JvmField val retryTestRule = RetryTestRule(3) + @After + fun tearDown() { + // Restoring network connection + setNetworkEnabled(true) + } + @SmokeTest @Test fun blockMalwarePageTest() { @@ -74,4 +83,33 @@ class BrowsingErrorPagesTest { verifyPageContent(harmfulSiteWarning) } } + + @Test + fun connectionFailureErrorMessageTest() { + val url = "example.com" + + navigationToolbar { + }.enterURLAndEnterToBrowser(url.toUri()) { + waitForPageToLoad() + verifyPageContent("Example Domain") + } + + setNetworkEnabled(false) + + browserScreen { + }.openThreeDotMenu { + }.refreshPage { + waitForPageToLoad() + verifyConnectionErrorMessage() + } + + setNetworkEnabled(true) + + browserScreen { + }.openThreeDotMenu { + }.refreshPage { + waitForPageToLoad() + verifyPageContent("Example Domain") + } + } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt index 9d565e6bf7..bf3a6d3e08 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -1080,6 +1080,15 @@ class BrowserRobot { exists = exists, ) + fun verifyConnectionErrorMessage() { + assertItemContainingTextExists( + itemContainingText(getStringResource(R.string.mozac_browser_errorpages_connection_failure_title)), + itemContainingText("The site could be temporarily unavailable or too busy. Try again in a few moments."), + itemContainingText("If you are unable to load any pages, check your device’s data or Wi-Fi connection."), + ) + assertItemWithResIdExists(itemWithResId("errorTryAgain")) + } + class Transition { private fun threeDotButton() = onView( allOf(