commit ff25d89ebff6dba597af2cd0c0c44c7d9f945876
parent 890c15b8464a25725c0cf72fbecbef9b4c28f9bd
Author: AndiAJ <andiaj@users.noreply.github.com>
Date: Tue, 4 Nov 2025 07:37:16 +0000
Bug 1893145 - Fix openSponsoredShortcutInPrivateTabTest UI test r=aaronmt
Several sponsored shortcuts related UI tests were flaky, the problem being caused by the fact that the [[ https://bugzilla.mozilla.org/show_bug.cgi?id=1893951 | top sites list is sometimes not loaded on cold run ]]
To overcome this issue I've added a workaround.
All sponsored shortcuts UI tests successfully passed 25x on Firebase ✅
Differential Revision: https://phabricator.services.mozilla.com/D271056
Diffstat:
1 file changed, 30 insertions(+), 0 deletions(-)
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SponsoredShortcutsTest.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SponsoredShortcutsTest.kt
@@ -4,15 +4,20 @@
package org.mozilla.fenix.ui
+import android.util.Log
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
+import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest
+import org.mozilla.fenix.helpers.Constants.RETRY_COUNT
+import org.mozilla.fenix.helpers.Constants.TAG
import org.mozilla.fenix.helpers.Constants.defaultTopSitesList
import org.mozilla.fenix.helpers.DataGenerationHelper.getSponsoredShortcutTitle
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.MockBrowserDataHelper
import org.mozilla.fenix.helpers.TestAssetHelper
+import org.mozilla.fenix.helpers.TestHelper.waitForAppWindowToBeUpdated
import org.mozilla.fenix.helpers.TestSetup
import org.mozilla.fenix.helpers.perf.DetectMemoryLeaksRule
import org.mozilla.fenix.ui.robots.homeScreen
@@ -33,6 +38,31 @@ class SponsoredShortcutsTest : TestSetup() {
@get:Rule
val memoryLeaksRule = DetectMemoryLeaksRule()
+ @Before
+ override fun setUp() {
+ super.setUp()
+ // Workaround to make sure the Top sites list displayed before starting the tests.
+ for (i in 1..RETRY_COUNT) {
+ Log.i(TAG, "setUp: Started try #$i")
+ try {
+ homeScreen {
+ }.openThreeDotMenu {
+ }.openSettings {
+ }.goBack {
+ verifyExistingTopSitesList(activityIntentTestRule)
+ }
+
+ break
+ } catch (e: Throwable) {
+ if (i == RETRY_COUNT) {
+ throw e
+ } else {
+ waitForAppWindowToBeUpdated()
+ }
+ }
+ }
+ }
+
// TestRail link: https://mozilla.testrail.io/index.php?/cases/view/1729331
// Expected for en-us defaults
@SmokeTest