test: Fix UI test for converting credential-less account into regular user.

Use email verification, which should be more stable in tests.
This commit is contained in:
Mateusz Armatys 2024-03-27 17:47:25 +01:00 committed by MargeBot
parent 49a40b1f15
commit e87ee6de51
3 changed files with 30 additions and 8 deletions

View File

@ -96,6 +96,7 @@ public final class me/proton/core/auth/test/MinimalSignInExternalTests$DefaultIm
public abstract interface class me/proton/core/auth/test/MinimalSignInGuestTests {
public abstract fun credentialLessToRegularAccount ()V
public abstract fun getIntentsRule ()Landroidx/test/espresso/intent/rule/IntentsRule;
public abstract fun getQuark ()Lme/proton/core/test/quark/Quark;
public abstract fun navigateToSignupFromCredentialLess ()V
public abstract fun opensTermsAndConditionsLink ()V
public abstract fun opensVpnNoLogsLink ()V

View File

@ -19,9 +19,14 @@
package me.proton.core.auth.test
import androidx.test.espresso.intent.rule.IntentsRule
import me.proton.core.auth.test.flow.SignUpFlow
import me.proton.core.auth.test.robot.CredentialLessWelcomeRobot
import me.proton.core.auth.test.robot.signup.RecoveryMethodRobot
import me.proton.core.auth.test.robot.signup.SetPasswordRobot
import me.proton.core.auth.test.robot.signup.SignUpRobot
import me.proton.core.test.android.robots.CoreRobot
import me.proton.core.test.android.robots.humanverification.HVCodeRobot
import me.proton.core.test.android.robots.humanverification.HVRobot
import me.proton.core.test.quark.Quark
import me.proton.core.util.kotlin.random
import me.proton.test.fusion.Fusion.intent
import org.junit.Rule
@ -33,6 +38,8 @@ public interface MinimalSignInGuestTests {
public val intentsRule: IntentsRule
get() = IntentsRule()
public val quark: Quark
public fun navigateToSignupFromCredentialLess()
public fun verifyAfterCredentialLessSignup()
public fun verifyAfterRegularSignup(username: String)
@ -40,6 +47,7 @@ public interface MinimalSignInGuestTests {
@BeforeTest
public fun setUp() {
intent.stubExternalIntents()
quark.jailUnban()
}
@Test
@ -57,7 +65,23 @@ public interface MinimalSignInGuestTests {
val testUsername = "test-${String.random()}"
SignUpRobot.forExternal().clickSwitch()
SignUpFlow.signUpInternal(testUsername)
SignUpRobot
.forInternal()
.fillUsername(testUsername)
.clickNext()
SetPasswordRobot
.fillAndClickNext("123123123")
RecoveryMethodRobot
.skip()
.skipConfirm()
HVRobot()
.email()
.setEmail("${testUsername}@proton.wtf")
.getVerificationCode()
HVCodeRobot()
.setCode("666666")
.verifyCode(CoreRobot::class.java)
verifyAfterRegularSignup(testUsername)
}

View File

@ -26,10 +26,7 @@ import androidx.test.espresso.web.webdriver.DriverAtoms.findElement
import androidx.test.espresso.web.webdriver.DriverAtoms.webClick
import androidx.test.espresso.web.webdriver.DriverAtoms.webKeys
import androidx.test.espresso.web.webdriver.Locator
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.SearchCondition
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until.findObject
import androidx.test.uiautomator.Until.hasObject
import me.proton.core.humanverification.domain.entity.TokenType
@ -58,9 +55,9 @@ internal class HV3Robot : BaseHVRobot(), WithUiDevice {
private inline fun <reified T> hvOption(option: TokenType): T {
view.withId(R.id.humanVerificationWebView).checkDisplayed()
val testId = when (option) {
CAPTCHA -> "tab-header-CAPTCHA-button"
SMS -> "tab-header-SMS-button"
EMAIL -> "tab-header-Email-button"
CAPTCHA -> "tab-header-captcha-button"
SMS -> "tab-header-sms-button"
EMAIL -> "tab-header-email-button"
else -> throw IllegalArgumentException("Only Captcha, SMS and Email are supported")
}
onWebView()