Skip to content

Commit a5a8bb9

Browse files
msimonides-protonMargeBot
authored and
MargeBot
committed
Fix release_tests for the new login UI [VPNAND-2047].
1 parent 8c8c9e9 commit a5a8bb9

File tree

6 files changed

+47
-30
lines changed

6 files changed

+47
-30
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def accountSentryDsn = System.getenv("ACCOUNT_SENTRY_DSN") ?: ""
132132
def preferencesSalt = System.getenv("DEPRECATED_PREF_SALT") ?: "Salt"
133133
def preferencesKey = System.getenv("DEPRECATED_PREF_KEY") ?: "Key"
134134
def serviceAccountCredentialsPath = project.hasProperty('serviceAccountFilePath') ? serviceAccountFilePath : "service_account.json"
135-
def testAccountPassword = System.getenv("TEST_ACCOUNT_PASS") ?: "Pass"
135+
def testAccountPassword = System.getenv("TEST_ACCOUNT_PASS") ?: project.hasProperty('testAccountPassword') ? testAccountPassword : "Pass"
136136
def appId = project.hasProperty('appId') ? appId : "ch.protonvpn.android"
137137
def supportedLocales = ['b+es+419', 'be', 'cs', 'de', 'el', 'en', 'es-rES', 'es-rMX', 'fa', 'fi', 'fr', 'hr', 'in', 'it', 'ja', 'ka', 'ko', 'nb-rNO', 'nl', 'pl', 'pt-rBR', 'pt-rPT', 'ro', 'ru', 'sk', 'sl', 'sv-rSE', 'tr', 'uk', 'zh-rTW']
138138
def helpers = new Helpers(rootDir, providers)

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ buildscript {
2323
// We should migrate to version catalogs as soon as IDE support is available:
2424
// https://issuetracker.google.com/issues/226078451
2525
ext.androidx_lifecycle_version = '2.8.7'
26-
ext.core_version = '30.3.1'
26+
ext.core_version = '30.3.2'
2727
ext.datastore_version = '1.1.1'
2828
ext.desugar_jdk_version = '2.0.4'
2929
ext.detekt_version = '1.23.7'

release_tests/src/main/java/com/protonvpn/android/release_tests/robots/LoginRobot.kt

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,35 @@
2121

2222
package com.protonvpn.android.release_tests.robots
2323

24+
import androidx.test.platform.app.InstrumentationRegistry
25+
import androidx.test.uiautomator.By
26+
import androidx.test.uiautomator.UiDevice
27+
import androidx.test.uiautomator.Until
2428
import com.protonvpn.android.release_tests.data.TestConstants
2529
import me.proton.test.fusion.Fusion.byObject
26-
import me.proton.test.fusion.Fusion.device
2730
import me.proton.test.fusion.ui.uiautomator.ByObject
2831

2932
object LoginRobot {
30-
fun signIn(username: String, password: String) {
33+
fun signIn(username: String, password: String): LoginRobot {
3134
navigateToSignIn()
32-
enterCredentials(username, password)
33-
pressSignIn()
34-
waitUntilLoggedIn()
35-
}
3635

37-
fun navigateToSignIn(): LoginRobot {
38-
byObject.withTimeout(TestConstants.TWENTY_SECOND_TIMEOUT).withText("Sign in").click()
39-
return this
40-
}
36+
// Skip Fusion, it's nothing but limitations.
37+
val uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
38+
val hasNewUsernameInput = uiDevice.wait(
39+
Until.hasObject(By.res("LOGIN_USERNAME_FIELD_TAG")),
40+
TestConstants.FIVE_SECONDS_TIMEOUT_MS
41+
)
42+
if (hasNewUsernameInput) {
43+
fillSignIn(username, password)
44+
} else {
45+
fillSignInLegacy(username, password)
46+
}
4147

42-
fun enterCredentials(username: String, password: String): LoginRobot {
43-
protonInput("usernameInput").typeText(username)
44-
protonInput("passwordInput").typeText(password)
4548
return this
4649
}
4750

48-
fun pressSignIn(): LoginRobot {
49-
// Use ID for the button because "Sign in" text is not unique (also used in header).
50-
byObject.withResId(TestConstants.TEST_PACKAGE, "signInButton").click()
51+
fun navigateToSignIn(): LoginRobot {
52+
byObject.withTimeout(TestConstants.TWENTY_SECOND_TIMEOUT).withText("Sign in").click()
5153
return this
5254
}
5355

@@ -57,7 +59,25 @@ object LoginRobot {
5759
return this
5860
}
5961

60-
private fun protonInput(resourceId: String): ByObject =
61-
byObject.withResId(TestConstants.TEST_PACKAGE, resourceId)
62+
private fun fillSignIn(username: String, password: String) {
63+
byObject.protonComposeInput("LOGIN_USERNAME_FIELD_TAG").typeText(username)
64+
byObject.withText("Continue").click()
65+
byObject.protonComposeInput("LOGIN_PASSWORD_FIELD_TAG").typeText(password)
66+
byObject.withText("Continue").click()
67+
}
68+
69+
private fun fillSignInLegacy(username: String, password: String) {
70+
byObject.protonInput("usernameInput").typeText(username)
71+
byObject.protonInput("passwordInput").typeText(password)
72+
// Use ID for the button because "Sign in" text is not unique (also used in header).
73+
byObject.withResId(TestConstants.TEST_PACKAGE, "signInButton").click()
74+
}
75+
76+
private fun ByObject.protonInput(resourceId: String): ByObject =
77+
withResId(TestConstants.TEST_PACKAGE, resourceId)
6278
.onDescendant(byObject.withResId(TestConstants.TEST_PACKAGE, "input"))
63-
}
79+
80+
private fun ByObject.protonComposeInput(testTag: String): ByObject =
81+
withResName(testTag)
82+
.onDescendant(byObject.withResName("PROTON_OUTLINED_TEXT_INPUT_TAG"))
83+
}

release_tests/src/main/java/com/protonvpn/android/release_tests/tests/AltRoutingSli.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ class AltRoutingSli {
6363
.addMeasurement(DurationMeasurement())
6464
.setLogcatFilter(LokiConfig.logcatFilter)
6565

66-
LoginRobot.navigateToSignIn()
67-
.enterCredentials("testas3", BuildConfig.TEST_ACCOUNT_PASSWORD)
68-
.pressSignIn()
66+
LoginRobot.signIn("testas3", BuildConfig.TEST_ACCOUNT_PASSWORD)
6967

7068
profile.measure {
7169
LoginRobot.waitUntilLoggedIn()
@@ -78,4 +76,4 @@ class AltRoutingSli {
7876
profile.pushLogcatLogs()
7977
profile.clearLogcatLogs()
8078
}
81-
}
79+
}

release_tests/src/main/java/com/protonvpn/android/release_tests/tests/MainMeasurementsSli.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ class MainMeasurementsSli {
5555

5656
@Before
5757
fun setup() {
58-
LoginRobot.navigateToSignIn()
59-
.enterCredentials("testas3", BuildConfig.TEST_ACCOUNT_PASSWORD)
60-
.pressSignIn()
58+
LoginRobot.signIn("testas3", BuildConfig.TEST_ACCOUNT_PASSWORD)
6159
}
6260

6361
@Test
@@ -126,4 +124,4 @@ class MainMeasurementsSli {
126124
//Delay to prevent issues when sending SLI results
127125
Thread.sleep(TestConstants.FIVE_SECONDS_TIMEOUT_MS)
128126
}
129-
}
127+
}

release_tests/src/main/java/com/protonvpn/android/release_tests/tests/SmokeTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ class SmokeTest {
3535
@Test
3636
fun testSignIn() {
3737
LoginRobot.signIn("testas3", BuildConfig.TEST_ACCOUNT_PASSWORD)
38+
.waitUntilLoggedIn()
3839
}
39-
}
40+
}

0 commit comments

Comments
 (0)