diff --git a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt index 33e1e6f6b4..042e9ef3ee 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt @@ -55,6 +55,10 @@ class UiAllScreensSanityTest { fun allScreensTest() { IdlingPolicies.setMasterPolicyTimeout(120, TimeUnit.SECONDS) + elementRobot.onboarding { + crawl() + } + // Create an account val userId = "UiTest_" + UUID.randomUUID().toString() elementRobot.signUp(userId) diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt index 22a5a0790b..638cf9840e 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt @@ -40,6 +40,10 @@ import timber.log.Timber class ElementRobot { + fun onboarding(block: OnboardingRobot.() -> Unit) { + block(OnboardingRobot()) + } + fun signUp(userId: String) { val onboardingRobot = OnboardingRobot() onboardingRobot.createAccount(userId = userId) diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt index 633d3cceab..57693709c6 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt @@ -18,6 +18,7 @@ package im.vector.app.ui.robot import androidx.test.espresso.Espresso.closeSoftKeyboard import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import com.adevinta.android.barista.assertion.BaristaEnabledAssertions.assertDisabled @@ -31,6 +32,24 @@ import im.vector.app.waitForView class OnboardingRobot { + fun crawl() { + waitUntilViewVisible(withId(R.id.loginSplashSubmit)) + crawlGetStarted() + crawlAlreadyHaveAccount() + } + + private fun crawlGetStarted() { + clickOn(R.id.loginSplashSubmit) + AuthOptionsRobot().crawlGetStarted() + pressBack() + } + + private fun crawlAlreadyHaveAccount() { + clickOn(R.id.loginSplashAlreadyHaveAccount) + AuthOptionsRobot().crawlAlreadyHaveAccount() + pressBack() + } + fun createAccount(userId: String, password: String = "password", homeServerUrl: String = "http://10.0.2.2:8080") { initSession(true, userId, password, homeServerUrl) } @@ -73,3 +92,76 @@ class OnboardingRobot { clickOn(R.id.loginSubmit) } } + +class AuthOptionsRobot { + + fun crawlGetStarted() { + assertDisplayed(R.id.loginServerTitle, R.string.login_server_title) + crawlMatrixServer(isSignUp = true) + crawlEmsServer() + crawlOtherServer(isSignUp = true) + crawlSignInWithMatrixId() + } + + fun crawlAlreadyHaveAccount() { + assertDisplayed(R.id.loginServerTitle, R.string.login_server_title) + crawlMatrixServer(isSignUp = false) + crawlEmsServer() + crawlOtherServer(isSignUp = false) + crawlSignInWithMatrixId() + } + + private fun crawlOtherServer(isSignUp: Boolean) { + clickOn(R.id.loginServerChoiceOther) + waitUntilViewVisible(withId(R.id.loginServerUrlFormTitle)) + writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://chat.mozilla.org") + clickOn(R.id.loginServerUrlFormSubmit) + waitUntilViewVisible(withId(R.id.loginSignupSigninTitle)) + assertDisplayed(R.id.loginSignupSigninText, "Connect to chat.mozilla.org") + assertDisplayed(R.id.loginSignupSigninSubmit, R.string.login_signin_sso) + pressBack() + + writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://matrix.org") + clickOn(R.id.loginServerUrlFormSubmit) + assetMatrixSignInOptions(isSignUp) + pressBack() + pressBack() + } + + private fun crawlEmsServer() { + clickOn(R.id.loginServerChoiceEms) + waitUntilViewVisible(withId(R.id.loginServerUrlFormTitle)) + assertDisplayed(R.id.loginServerUrlFormTitle, R.string.login_connect_to_modular) + + writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://one.ems.host") + clickOn(R.id.loginServerUrlFormSubmit) + + waitUntilViewVisible(withId(R.id.loginSignupSigninTitle)) + assertDisplayed(R.id.loginSignupSigninText, "one.ems.host") + assertDisplayed(R.id.loginSignupSigninSubmit, R.string.login_signin_sso) + pressBack() + pressBack() + } + + private fun crawlMatrixServer(isSignUp: Boolean) { + clickOn(R.id.loginServerChoiceMatrixOrg) + assetMatrixSignInOptions(isSignUp) + pressBack() + } + + private fun assetMatrixSignInOptions(isSignUp: Boolean) { + waitUntilViewVisible(withId(R.id.loginTitle)) + when (isSignUp) { + true -> assertDisplayed(R.id.loginTitle, "Sign up to matrix.org") + false -> assertDisplayed(R.id.loginTitle, "Connect to matrix.org") + } + } + + private fun crawlSignInWithMatrixId() { + clickOn(R.id.loginServerIKnowMyIdSubmit) + waitUntilViewVisible(withId(R.id.loginTitle)) + assertDisplayed(R.id.loginTitle, R.string.login_signin_matrix_id_title) + pressBack() + } +} +