Add new use case about threads in the allScreensTest

This commit is contained in:
ariskotsomitopoulos 2022-02-23 18:39:02 +02:00
parent a9b3882bf6
commit 8788fb974d
6 changed files with 122 additions and 5 deletions

View file

@ -27,6 +27,7 @@ import im.vector.app.espresso.tools.ScreenshotFailureRule
import im.vector.app.features.MainActivity
import im.vector.app.getString
import im.vector.app.ui.robot.ElementRobot
import im.vector.app.ui.robot.settings.labs.LabFeature
import im.vector.app.ui.robot.withDeveloperMode
import org.junit.Rule
import org.junit.Test
@ -97,6 +98,8 @@ class UiAllScreensSanityTest {
}
}
testThreadScreens()
elementRobot.space {
createSpace {
crawl()
@ -148,4 +151,25 @@ class UiAllScreensSanityTest {
// TODO Deactivate account instead of logout?
elementRobot.signout(expectSignOutWarning = false)
}
/**
* Testing multiple threads screens
*/
private fun testThreadScreens() {
elementRobot.toggleLabFeature(LabFeature.THREAD_MESSAGES)
elementRobot.newRoom {
createNewRoom {
crawl()
createRoom {
val message = "Hello This message will be a thread!"
postMessage(message)
replyToThread(message)
viewInRoom(message)
openThreadSummaries()
selectThreadSummariesFilter()
}
}
}
elementRobot.toggleLabFeature(LabFeature.THREAD_MESSAGES)
}
}

View file

@ -17,9 +17,15 @@
package im.vector.app.ui.robot
import android.view.View
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import com.adevinta.android.barista.interaction.BaristaDialogInteractions.clickDialogNegativeButton
@ -35,6 +41,7 @@ import im.vector.app.features.home.HomeActivity
import im.vector.app.features.onboarding.OnboardingActivity
import im.vector.app.initialSyncIdlingResource
import im.vector.app.ui.robot.settings.SettingsRobot
import im.vector.app.ui.robot.settings.labs.LabFeature
import im.vector.app.ui.robot.space.SpaceRobot
import im.vector.app.withIdlingResource
import timber.log.Timber
@ -70,11 +77,11 @@ class ElementRobot {
}
}
fun settings(block: SettingsRobot.() -> Unit) {
fun settings(shouldGoBack: Boolean = true, block: SettingsRobot.() -> Unit) {
openDrawer()
clickOn(R.id.homeDrawerHeaderSettingsView)
block(SettingsRobot())
pressBack()
if (shouldGoBack) pressBack()
waitUntilViewVisible(withId(R.id.bottomNavigationView))
}
@ -103,6 +110,22 @@ class ElementRobot {
waitUntilViewVisible(withId(R.id.bottomNavigationView))
}
fun toggleLabFeature(labFeature: LabFeature) {
when (labFeature) {
LabFeature.THREAD_MESSAGES -> {
settings(shouldGoBack = false) {
labs(shouldGoBack = false) {
onView(withText(R.string.labs_enable_thread_messages))
.check(ViewAssertions.matches(isDisplayed()))
.perform(ViewActions.closeSoftKeyboard(), click())
}
}
}
else -> {
}
}
}
fun signout(expectSignOutWarning: Boolean) {
clickOn(R.id.groupToolbarAvatarImageView)
clickOn(R.id.homeDrawerHeaderSignoutView)

View file

@ -70,4 +70,13 @@ class MessageMenuRobot(
clickOn(R.string.edit)
autoClosed = true
}
fun replyInThread() {
clickOn(R.string.reply_in_thread)
autoClosed = true
}
fun viewInRoom() {
clickOn(R.string.view_in_room)
autoClosed = true
}
}

View file

@ -62,6 +62,23 @@ class RoomDetailRobot {
pressBack()
}
fun replyToThread(message: String) {
openMessageMenu(message) {
replyInThread()
}
val threadMessage = "Hello universe - long message to avoid espresso tapping edited!"
writeTo(R.id.composerEditText, threadMessage)
waitUntilViewVisible(withId(R.id.sendButton))
clickOn(R.id.sendButton)
}
fun viewInRoom(message: String) {
openMessageMenu(message) {
viewInRoom()
}
waitUntilViewVisible(withId(R.id.composerEditText))
}
fun crawlMessage(message: String) {
// Test quick reaction
val quickReaction = EmojiDataSource.quickEmojis[0] // 👍
@ -110,7 +127,7 @@ class RoomDetailRobot {
onView(withId(R.id.timelineRecyclerView))
.perform(
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
ViewMatchers.hasDescendant(ViewMatchers.withText(message)),
ViewMatchers.hasDescendant(withText(message)),
ViewActions.longClick()
)
)
@ -130,4 +147,16 @@ class RoomDetailRobot {
block(RoomSettingsRobot())
pressBack()
}
fun openThreadSummaries() {
clickMenu(R.id.menu_timeline_thread_list)
waitUntilViewVisible(withId(R.id.threadListRecyclerView))
}
fun selectThreadSummariesFilter() {
clickMenu(R.id.menu_thread_list_filter)
sleep(1000)
clickOn(R.id.threadListModalMyThreads)
pressBack()
}
}

View file

@ -16,6 +16,7 @@
package im.vector.app.ui.robot.settings
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import im.vector.app.R
import im.vector.app.clickOnAndGoBack
@ -51,8 +52,13 @@ class SettingsRobot {
clickOnAndGoBack(R.string.settings_security_and_privacy) { block(SettingsSecurityRobot()) }
}
fun labs(block: () -> Unit = {}) {
clickOnAndGoBack(R.string.room_settings_labs_pref_title) { block() }
fun labs(shouldGoBack: Boolean = true, block: () -> Unit = {}) {
if (shouldGoBack) {
clickOnAndGoBack(R.string.room_settings_labs_pref_title) { block() }
} else {
clickOn(R.string.room_settings_labs_pref_title)
block()
}
}
fun advancedSettings(block: SettingsAdvancedRobot.() -> Unit) {

View file

@ -0,0 +1,26 @@
/*
* 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.settings.labs
enum class LabFeature {
SWIPE_TO_REPLY,
TAB_UNREAD_NOTIFICATIONS,
LATEX_MATHEMATICS,
THREAD_MESSAGES,
AUTO_REPORT_ERRORS,
RENDER_USER_LOCATION
}