Merge pull request #4975 from vector-im/feature/adm/ftue-sanity-test-updates

Including onboarding auth options in sanity test
This commit is contained in:
Benoit Marty 2022-01-18 19:04:47 +01:00 committed by GitHub
commit 488486a74f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 137 additions and 3 deletions

1
changelog.d/4975.misc Normal file
View file

@ -0,0 +1 @@
Including onboarding server options in the all screen sanity test suite

View file

@ -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)

View file

@ -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)

View file

@ -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)
OnboardingServersRobot().crawlSignUp()
pressBack()
}
private fun crawlAlreadyHaveAccount() {
clickOn(R.id.loginSplashAlreadyHaveAccount)
OnboardingServersRobot().crawlSignIn()
pressBack()
}
fun createAccount(userId: String, password: String = "password", homeServerUrl: String = "http://10.0.2.2:8080") {
initSession(true, userId, password, homeServerUrl)
}

View file

@ -0,0 +1,97 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.ui.robot
import androidx.test.espresso.Espresso
import androidx.test.espresso.matcher.ViewMatchers
import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions
import com.adevinta.android.barista.interaction.BaristaClickInteractions
import com.adevinta.android.barista.interaction.BaristaEditTextInteractions
import im.vector.app.R
import im.vector.app.espresso.tools.waitUntilViewVisible
class OnboardingServersRobot {
fun crawlSignUp() {
BaristaVisibilityAssertions.assertDisplayed(R.id.loginServerTitle, R.string.login_server_title)
crawlMatrixServer(isSignUp = true)
crawlEmsServer()
crawlOtherServer(isSignUp = true)
crawlSignInWithMatrixId()
}
fun crawlSignIn() {
BaristaVisibilityAssertions.assertDisplayed(R.id.loginServerTitle, R.string.login_server_title)
crawlMatrixServer(isSignUp = false)
crawlEmsServer()
crawlOtherServer(isSignUp = false)
crawlSignInWithMatrixId()
}
private fun crawlOtherServer(isSignUp: Boolean) {
BaristaClickInteractions.clickOn(R.id.loginServerChoiceOther)
waitUntilViewVisible(ViewMatchers.withId(R.id.loginServerUrlFormTitle))
BaristaEditTextInteractions.writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://chat.mozilla.org")
BaristaClickInteractions.clickOn(R.id.loginServerUrlFormSubmit)
waitUntilViewVisible(ViewMatchers.withId(R.id.loginSignupSigninTitle))
BaristaVisibilityAssertions.assertDisplayed(R.id.loginSignupSigninText, "Connect to chat.mozilla.org")
BaristaVisibilityAssertions.assertDisplayed(R.id.loginSignupSigninSubmit, R.string.login_signin_sso)
Espresso.pressBack()
BaristaEditTextInteractions.writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://matrix.org")
BaristaClickInteractions.clickOn(R.id.loginServerUrlFormSubmit)
assetMatrixSignInOptions(isSignUp)
Espresso.pressBack()
Espresso.pressBack()
}
private fun crawlEmsServer() {
BaristaClickInteractions.clickOn(R.id.loginServerChoiceEms)
waitUntilViewVisible(ViewMatchers.withId(R.id.loginServerUrlFormTitle))
BaristaVisibilityAssertions.assertDisplayed(R.id.loginServerUrlFormTitle, R.string.login_connect_to_modular)
BaristaEditTextInteractions.writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://one.ems.host")
BaristaClickInteractions.clickOn(R.id.loginServerUrlFormSubmit)
waitUntilViewVisible(ViewMatchers.withId(R.id.loginSignupSigninTitle))
BaristaVisibilityAssertions.assertDisplayed(R.id.loginSignupSigninText, "one.ems.host")
BaristaVisibilityAssertions.assertDisplayed(R.id.loginSignupSigninSubmit, R.string.login_signin_sso)
Espresso.pressBack()
Espresso.pressBack()
}
private fun crawlMatrixServer(isSignUp: Boolean) {
BaristaClickInteractions.clickOn(R.id.loginServerChoiceMatrixOrg)
assetMatrixSignInOptions(isSignUp)
Espresso.pressBack()
}
private fun assetMatrixSignInOptions(isSignUp: Boolean) {
waitUntilViewVisible(ViewMatchers.withId(R.id.loginTitle))
when (isSignUp) {
true -> BaristaVisibilityAssertions.assertDisplayed(R.id.loginTitle, "Sign up to matrix.org")
false -> BaristaVisibilityAssertions.assertDisplayed(R.id.loginTitle, "Connect to matrix.org")
}
}
private fun crawlSignInWithMatrixId() {
BaristaClickInteractions.clickOn(R.id.loginServerIKnowMyIdSubmit)
waitUntilViewVisible(ViewMatchers.withId(R.id.loginTitle))
BaristaVisibilityAssertions.assertDisplayed(R.id.loginTitle, R.string.login_signin_matrix_id_title)
Espresso.pressBack()
}
}

View file

@ -37,7 +37,6 @@ import im.vector.app.features.home.room.detail.timeline.action.MessageActionsBot
import im.vector.app.features.home.room.detail.timeline.reactions.ViewReactionsBottomSheet
import im.vector.app.features.reactions.data.EmojiDataSource
import im.vector.app.interactWithSheet
import im.vector.app.waitForView
import im.vector.app.withRetry
import java.lang.Thread.sleep
@ -127,7 +126,7 @@ class RoomDetailRobot {
fun openSettings(block: RoomSettingsRobot.() -> Unit) {
clickMenu(R.id.timeline_setting)
waitForView(withId(R.id.roomProfileAvatarView))
waitUntilViewVisible(withId(R.id.roomProfileAvatarView))
sleep(1000)
block(RoomSettingsRobot())
pressBack()

View file

@ -852,7 +852,7 @@ class OnboardingViewModel @AssistedInject constructor(
}
withState {
if (it.serverType == ServerType.MatrixOrg) {
if (loginMode.supportsSignModeScreen()) {
when (it.onboardingFlow) {
OnboardingFlow.SignIn -> handleUpdateSignMode(OnboardingAction.UpdateSignMode(SignMode.SignIn))
OnboardingFlow.SignUp -> handleUpdateSignMode(OnboardingAction.UpdateSignMode(SignMode.SignUp))
@ -880,3 +880,13 @@ class OnboardingViewModel @AssistedInject constructor(
return authenticationService.getFallbackUrl(forSignIn, deviceId)
}
}
private fun LoginMode.supportsSignModeScreen(): Boolean {
return when (this) {
LoginMode.Password,
is LoginMode.SsoAndPassword -> true
is LoginMode.Sso,
LoginMode.Unknown,
LoginMode.Unsupported -> false
}
}