From 6b984968ebb995dc0afba61d65baa0d20dd678c3 Mon Sep 17 00:00:00 2001 From: Niklas Berglund Date: Thu, 22 Aug 2024 15:00:21 +0200 Subject: [PATCH 1/3] Re-enable testConnectAndVerifyWithConnectionCheck --- .../mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt | 3 ++- .../kotlin/net/mullvad/mullvadvpn/test/e2e/ConnectionTest.kt | 2 -- 2 files changed, 2 insertions(+), 3 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 bc2481e55f07..d170e1463296 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 @@ -91,7 +91,8 @@ class AppInteractor( device.findObjectWithTimeout(By.res("location_info_test_tag")).click() return device .findObjectWithTimeout( - By.res("location_info_connection_out_test_tag"), + // Text exist and contains IP address + By.res("location_info_connection_out_test_tag").textContains("."), CONNECTION_TIMEOUT ) .text diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/ConnectionTest.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/ConnectionTest.kt index f25ca9a8b505..62db4484944f 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/ConnectionTest.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/ConnectionTest.kt @@ -9,7 +9,6 @@ import net.mullvad.mullvadvpn.test.e2e.misc.AccountTestRule import net.mullvad.mullvadvpn.test.e2e.misc.ConnCheckState import net.mullvad.mullvadvpn.test.e2e.misc.SimpleMullvadHttpClient import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -35,7 +34,6 @@ class ConnectionTest : EndToEndTest(BuildConfig.FLAVOR_infrastructure) { } @Test - @Disabled("Disabled since the connection check isn't reliable in the stagemole infrastructure.") fun testConnectAndVerifyWithConnectionCheck() { // Given app.launchAndEnsureLoggedIn(accountTestRule.validAccountNumber) From 0e93fd3cd3150c846035e1dd3ebf2d84d218a8db Mon Sep 17 00:00:00 2001 From: Niklas Berglund Date: Fri, 23 Aug 2024 09:35:52 +0200 Subject: [PATCH 2/3] Wait for login button to be enabled --- .../mullvadvpn/test/common/interactor/AppInteractor.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 d170e1463296..19de2ac789b0 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 @@ -57,7 +57,9 @@ class AppInteractor( device.findObjectWithTimeout(By.clazz("android.widget.EditText")).apply { text = accountNumber } - loginObject.parent.findObject(By.clazz(Button::class.java)).click() + val loginButton = loginObject.parent.findObject(By.clazz(Button::class.java)) + loginButton.wait(Until.enabled(true), DEFAULT_INTERACTION_TIMEOUT) + loginButton.click() } fun attemptCreateAccount() { From 2e280c73a2f1e599a9651ad96dbca04713d56a75 Mon Sep 17 00:00:00 2001 From: Niklas Berglund Date: Fri, 23 Aug 2024 11:41:39 +0200 Subject: [PATCH 3/3] Handle alternative wording for deleting VPN profile --- .../rule/ForgetAllVpnAppsInSettingsTestRule.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/rule/ForgetAllVpnAppsInSettingsTestRule.kt b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/rule/ForgetAllVpnAppsInSettingsTestRule.kt index 9457b7862e38..2bb751c5d261 100644 --- a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/rule/ForgetAllVpnAppsInSettingsTestRule.kt +++ b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/rule/ForgetAllVpnAppsInSettingsTestRule.kt @@ -23,14 +23,22 @@ class ForgetAllVpnAppsInSettingsTestRule : BeforeTestExecutionCallback { device.findObjects(By.res(SETTINGS_PACKAGE, VPN_SETTINGS_BUTTON_ID)) vpnSettingsButtons.forEach { button -> button.click() - device.findObjectWithTimeout(By.text(FORGET_VPN_VPN_BUTTON_TEXT)).click() - device.findObjectByCaseInsensitiveText(FORGET_VPN_VPN_CONFIRM_BUTTON_TEXT).click() + + try { + device.findObjectWithTimeout(By.text(FORGET_VPN_VPN_BUTTON_TEXT)).click() + device.findObjectByCaseInsensitiveText(FORGET_VPN_VPN_CONFIRM_BUTTON_TEXT).click() + } catch (_: Exception) { + device.findObjectWithTimeout(By.text(DELETE_VPN_PROFILE_TEXT)).click() + device.findObjectWithTimeout(By.text(DELETE_VPN_CONFIRM_BUTTON_TEXT)).click() + } } } companion object { private const val FORGET_VPN_VPN_BUTTON_TEXT = "Forget VPN" + private const val DELETE_VPN_PROFILE_TEXT = "Delete VPN profile" private const val FORGET_VPN_VPN_CONFIRM_BUTTON_TEXT = "Forget" + private const val DELETE_VPN_CONFIRM_BUTTON_TEXT = "DELETE" private const val SETTINGS_PACKAGE = "com.android.settings" private const val VPN_SETTINGS_BUTTON_ID = "settings_button" }