summaryrefslogtreecommitdiffhomepage
path: root/android/test/common
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2025-07-31 09:34:16 +0200
committerJonatan Rhodin <jonatan.rhodin@mullvad.net>2025-07-31 11:02:31 +0200
commitca2cf224a91bb9729add4bc097448677bfcd610b (patch)
tree9b11d9c382524f2da063dcb66ce21e358be0a8ea /android/test/common
parent49f294775042c4fc5e585546957d4b9fb774145f (diff)
downloadmullvadvpn-ca2cf224a91bb9729add4bc097448677bfcd610b.tar.xz
mullvadvpn-ca2cf224a91bb9729add4bc097448677bfcd610b.zip
Fix tests failing when the notification allowed dialog is not shown
Diffstat (limited to 'android/test/common')
-rw-r--r--android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt14
-rw-r--r--android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/page/PrivacyPage.kt23
2 files changed, 5 insertions, 32 deletions
diff --git a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt
index 7bf2a5911d..8e731d2554 100644
--- a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt
+++ b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt
@@ -6,12 +6,14 @@ import android.os.Build
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
+import co.touchlab.kermit.Logger
import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointOverride
import net.mullvad.mullvadvpn.lib.endpoint.putApiEndpointConfigurationExtra
import net.mullvad.mullvadvpn.test.common.constant.DEFAULT_TIMEOUT
import net.mullvad.mullvadvpn.test.common.constant.LONG_TIMEOUT
import net.mullvad.mullvadvpn.test.common.extension.findObjectWithTimeout
import net.mullvad.mullvadvpn.test.common.page.LoginPage
+import net.mullvad.mullvadvpn.test.common.page.PrivacyPage
import net.mullvad.mullvadvpn.test.common.page.on
class AppInteractor(
@@ -39,7 +41,7 @@ class AppInteractor(
fun launchAndEnsureOnLoginPage() {
launch()
- clickAgreeOnPrivacyDisclaimer()
+ on<PrivacyPage> { clickAgreeOnPrivacyDisclaimer() }
clickAllowOnNotificationPermissionPromptIfApiLevel33AndAbove()
on<LoginPage>()
}
@@ -52,10 +54,6 @@ class AppInteractor(
}
}
- private fun clickAgreeOnPrivacyDisclaimer() {
- device.findObjectWithTimeout(By.text("Agree and continue")).click()
- }
-
private fun clickAllowOnNotificationPermissionPromptIfApiLevel33AndAbove(
timeout: Long = DEFAULT_TIMEOUT
) {
@@ -70,10 +68,8 @@ class AppInteractor(
try {
device.findObjectWithTimeout(selector).click()
- } catch (_: IllegalArgumentException) {
- throw IllegalArgumentException(
- "Failed to allow notification permission within timeout ($timeout ms)"
- )
+ } catch (e: IllegalArgumentException) {
+ Logger.e("Failed to allow notification permission within timeout ($timeout ms)", e)
}
}
}
diff --git a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/page/PrivacyPage.kt b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/page/PrivacyPage.kt
index f5ca662113..18b1213fc8 100644
--- a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/page/PrivacyPage.kt
+++ b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/page/PrivacyPage.kt
@@ -1,15 +1,11 @@
package net.mullvad.mullvadvpn.test.common.page
-import android.os.Build
import androidx.test.uiautomator.By
-import androidx.test.uiautomator.Until
-import net.mullvad.mullvadvpn.test.common.constant.DEFAULT_TIMEOUT
import net.mullvad.mullvadvpn.test.common.extension.findObjectWithTimeout
class PrivacyPage internal constructor() : Page() {
private val privacySelector = By.text("Privacy")
private val agreeSelector = By.text("Agree and continue")
- private val allowSelector = By.text("Allow")
override fun assertIsDisplayed() {
uiDevice.findObjectWithTimeout(privacySelector)
@@ -18,23 +14,4 @@ class PrivacyPage internal constructor() : Page() {
fun clickAgreeOnPrivacyDisclaimer() {
uiDevice.findObjectWithTimeout(agreeSelector).click()
}
-
- fun clickAllowOnNotificationPermissionPromptIfApiLevel33AndAbove(
- timeout: Long = DEFAULT_TIMEOUT
- ) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
- // Skipping as notification permissions are not shown.
- return
- }
-
- uiDevice.wait(Until.hasObject(allowSelector), timeout)
-
- try {
- uiDevice.findObjectWithTimeout(allowSelector).click()
- } catch (e: IllegalArgumentException) {
- throw IllegalArgumentException(
- "Failed to allow notification permission within timeout ($timeout)"
- )
- }
- }
}