From 9490fea9e949dd473e203a60e851806b87f7d6b4 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Wed, 4 May 2022 14:27:21 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/23816 fix disabled verifyMultipleLoginsSelectionsTest UI test --- .../mozilla/fenix/ui/SettingsPrivacyTest.kt | 12 ++++-------- .../mozilla/fenix/ui/robots/BrowserRobot.kt | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt index 3025d107b1..446a420004 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt @@ -18,8 +18,8 @@ import org.junit.Test import org.mozilla.fenix.customannotations.SmokeTest import org.mozilla.fenix.ext.settings import org.mozilla.fenix.helpers.AndroidAssetDispatcher +import org.mozilla.fenix.helpers.FeatureSettingsHelper import org.mozilla.fenix.helpers.HomeActivityIntentTestRule -import org.mozilla.fenix.helpers.RetryTestRule import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestHelper import org.mozilla.fenix.helpers.TestHelper.appContext @@ -42,14 +42,11 @@ class SettingsPrivacyTest { private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) private lateinit var mockWebServer: MockWebServer private val pageShortcutName = "TestShortcut" + private val featureSettingsHelper = FeatureSettingsHelper() @get:Rule val activityTestRule = HomeActivityIntentTestRule() - @Rule - @JvmField - val retryTestRule = RetryTestRule(3) - @Before fun setUp() { mockWebServer = MockWebServer().apply { @@ -57,8 +54,8 @@ class SettingsPrivacyTest { start() } - val settings = activityTestRule.activity.applicationContext.settings() - settings.shouldShowJumpBackInCFR = false + featureSettingsHelper.setJumpBackCFREnabled(false) + featureSettingsHelper.disablePwaCFR(true) if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) { val autofillManager: AutofillManager = @@ -301,7 +298,6 @@ class SettingsPrivacyTest { } } - @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/23816") @SmokeTest @Test fun verifyMultipleLoginsSelectionsTest() { 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 67f0e04aa6..719960806a 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 @@ -631,6 +631,25 @@ class BrowserRobot { } fun verifyPrefilledLoginCredentials(userName: String) { + var currentTries = 0 + // Sometimes the assertion of the pre-filled logins fails so we are re-trying after refreshing the page + while (currentTries++ < 3) { + try { + mDevice.waitForObjects(userNameTextBox) + assertTrue(userNameTextBox.text.equals(userName)) + + break + } catch (e: AssertionError) { + browserScreen { + }.openThreeDotMenu { + }.refreshPage { + clearUserNameLoginCredential() + clickSuggestedLoginsButton() + verifySuggestedUserName(userName) + clickLoginSuggestion(userName) + } + } + } mDevice.waitForObjects(userNameTextBox) assertTrue(userNameTextBox.text.equals(userName)) }