diff --git a/app/src/androidTest/java/fr/free/nrw/commons/MainActivityTest.kt b/app/src/androidTest/java/fr/free/nrw/commons/MainActivityTest.kt index 3d2fc9e481..1243e3332a 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/MainActivityTest.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/MainActivityTest.kt @@ -66,6 +66,8 @@ class MainActivityTest { @Test fun testNearby() { + // Wait for the main activity to fully initialize + UITestHelper.sleep(1000) Espresso .onView( Matchers.allOf( @@ -104,6 +106,8 @@ class MainActivityTest { @Test fun testExplore() { + // Wait for the main activity to fully initialize + UITestHelper.sleep(1000) Espresso .onView( Matchers.allOf( @@ -125,6 +129,8 @@ class MainActivityTest { @Test fun testContributions() { + // Wait for the main activity to fully initialize + UITestHelper.sleep(1000) Espresso .onView( Matchers.allOf( @@ -175,6 +181,8 @@ class MainActivityTest { @Test fun testBookmarks() { + // Wait for the main activity to fully initialize + UITestHelper.sleep(1000) Espresso .onView( Matchers.allOf( @@ -193,6 +201,8 @@ class MainActivityTest { @Test fun testNotifications() { + // Wait for the main activity to fully initialize + UITestHelper.sleep(1000) Espresso .onView( Matchers.allOf( diff --git a/app/src/androidTest/java/fr/free/nrw/commons/UploadCancelledTest.kt b/app/src/androidTest/java/fr/free/nrw/commons/UploadCancelledTest.kt index ed57709fc2..1ad7638d83 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/UploadCancelledTest.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/UploadCancelledTest.kt @@ -40,6 +40,7 @@ class UploadCancelledTest { var mGrantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant( "android.permission.WRITE_EXTERNAL_STORAGE", + "android.permission.ACCESS_FINE_LOCATION", ) private val device: UiDevice = @@ -104,6 +105,9 @@ class UploadCancelledTest { ) actionMenuItemView.perform(click()) + // Wait for the nearby list to load + UITestHelper.sleep(2000) + val recyclerView = onView( allOf( @@ -117,6 +121,9 @@ class UploadCancelledTest { ), ) + // Wait for the button layout to expand + UITestHelper.sleep(1000) + val linearLayout3 = onView( allOf( @@ -132,6 +139,24 @@ class UploadCancelledTest { ) linearLayout3.perform(click()) + // Wait for the upload screen to load and handle any permission dialogs + UITestHelper.sleep(2000) + + // Try to handle permission dialog if it appears (for location or camera) + try { + val allowButton = device.findObject( + androidx.test.uiautomator.UiSelector() + .textMatches("(?i)(allow|permit|ok)") + .className("android.widget.Button") + ) + if (allowButton.exists()) { + allowButton.click() + UITestHelper.sleep(1000) + } + } catch (e: Exception) { + // No permission dialog, continue + } + val pasteSensitiveTextInputEditText = onView( allOf( diff --git a/app/src/androidTest/java/fr/free/nrw/commons/WelcomeActivityTest.kt b/app/src/androidTest/java/fr/free/nrw/commons/WelcomeActivityTest.kt index 5956b3c02a..6a4de7da38 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/WelcomeActivityTest.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/WelcomeActivityTest.kt @@ -39,6 +39,8 @@ class WelcomeActivityTest { if (ConfigUtils.isBetaFlavour) { onView(withId(R.id.button_ok)) .perform(ViewActions.click()) + // Wait for the tutorial pager to load + UITestHelper.sleep(1000) onView(withId(R.id.finishTutorialButton)) .check(matches(isDisplayed())) } @@ -49,6 +51,8 @@ class WelcomeActivityTest { if (!ConfigUtils.isBetaFlavour) { onView(withId(R.id.button_ok)) .perform(ViewActions.click()) + // Wait for the tutorial pager to load + UITestHelper.sleep(1000) onView(withId(R.id.finishTutorialButton)) .check(matches(not(isDisplayed()))) } @@ -59,6 +63,8 @@ class WelcomeActivityTest { if (ConfigUtils.isBetaFlavour) { onView(withId(R.id.button_ok)) .perform(ViewActions.click()) + // Wait for the tutorial pager to load + UITestHelper.sleep(1000) onView(withId(R.id.finishTutorialButton)) .perform(ViewActions.click()) assertThat(activityRule.activity.isDestroyed, equalTo(true)) @@ -119,6 +125,8 @@ class WelcomeActivityTest { if (viewPager.currentItem == 3) { onView(withId(R.id.button_ok)) .perform(ViewActions.click()) + // Wait for the tutorial pager to load + UITestHelper.sleep(1000) onView(withId(R.id.finishTutorialButton)) .perform(ViewActions.click()) assertThat(activityRule.activity.isDestroyed, equalTo(true)) diff --git a/app/src/androidTest/java/fr/free/nrw/commons/contributions/ContributionsListFragmentUnitTests.kt b/app/src/test/kotlin/fr/free/nrw/commons/contributions/ContributionsListFragmentUnitTests.kt similarity index 100% rename from app/src/androidTest/java/fr/free/nrw/commons/contributions/ContributionsListFragmentUnitTests.kt rename to app/src/test/kotlin/fr/free/nrw/commons/contributions/ContributionsListFragmentUnitTests.kt diff --git a/app/src/androidTest/java/fr/free/nrw/commons/navtab/MoreBottomSheetLoggedOutFragmentUnitTests.kt b/app/src/test/kotlin/fr/free/nrw/commons/navtab/MoreBottomSheetLoggedOutFragmentUnitTests.kt similarity index 100% rename from app/src/androidTest/java/fr/free/nrw/commons/navtab/MoreBottomSheetLoggedOutFragmentUnitTests.kt rename to app/src/test/kotlin/fr/free/nrw/commons/navtab/MoreBottomSheetLoggedOutFragmentUnitTests.kt