fixing space menu items not being clicked on during sanity test

- adds a separate clickOn helper for interacting with dialog bottom sheets, it seems the space menu sheet lives in a separte root to the rest of the suite (could be the fast switching of highlighting existing issues)
This commit is contained in:
Adam Brown 2022-02-23 12:01:47 +00:00
parent 924a4f8c94
commit 9a80ff7673
2 changed files with 15 additions and 7 deletions

View File

@ -27,6 +27,9 @@ import androidx.test.espresso.IdlingResource
import androidx.test.espresso.PerformException import androidx.test.espresso.PerformException
import androidx.test.espresso.UiController import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction import androidx.test.espresso.ViewAction
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.util.HumanReadables import androidx.test.espresso.util.HumanReadables
import androidx.test.espresso.util.TreeIterables import androidx.test.espresso.util.TreeIterables
@ -257,6 +260,10 @@ fun clickOnAndGoBack(@StringRes name: Int, block: () -> Unit) {
Espresso.pressBack() Espresso.pressBack()
} }
fun clickOnSheet(id: Int) {
Espresso.onView(ViewMatchers.withId(id)).inRoot(RootMatchers.isDialog()).perform(ViewActions.click())
}
inline fun <reified T : VectorBaseBottomSheetDialogFragment<*>> interactWithSheet( inline fun <reified T : VectorBaseBottomSheetDialogFragment<*>> interactWithSheet(
contentMatcher: Matcher<View>, contentMatcher: Matcher<View>,
@BottomSheetBehavior.State openState: Int = BottomSheetBehavior.STATE_EXPANDED, @BottomSheetBehavior.State openState: Int = BottomSheetBehavior.STATE_EXPANDED,

View File

@ -24,6 +24,7 @@ import androidx.test.espresso.matcher.ViewMatchers
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import com.adevinta.android.barista.internal.viewaction.ClickChildAction import com.adevinta.android.barista.internal.viewaction.ClickChildAction
import im.vector.app.R import im.vector.app.R
import im.vector.app.clickOnSheet
import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilActivityVisible
import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilDialogVisible
import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.espresso.tools.waitUntilViewVisible
@ -49,7 +50,7 @@ class SpaceMenuRobot {
} }
fun invitePeople() = apply { fun invitePeople() = apply {
clickOn(R.id.invitePeople) clickOnSheet(R.id.invitePeople)
waitUntilDialogVisible(ViewMatchers.withId(R.id.inviteByMxidButton)) waitUntilDialogVisible(ViewMatchers.withId(R.id.inviteByMxidButton))
clickOn(R.id.inviteByMxidButton) clickOn(R.id.inviteByMxidButton)
waitUntilActivityVisible<InviteUsersToRoomActivity> { waitUntilActivityVisible<InviteUsersToRoomActivity> {
@ -62,7 +63,7 @@ class SpaceMenuRobot {
} }
fun spaceMembers() { fun spaceMembers() {
clickOn(R.id.showMemberList) clickOnSheet(R.id.showMemberList)
waitUntilActivityVisible<RoomProfileActivity> { waitUntilActivityVisible<RoomProfileActivity> {
waitUntilViewVisible(ViewMatchers.withId(R.id.roomSettingsRecyclerView)) waitUntilViewVisible(ViewMatchers.withId(R.id.roomSettingsRecyclerView))
} }
@ -70,7 +71,7 @@ class SpaceMenuRobot {
} }
fun spaceSettings(block: SpaceSettingsRobot.() -> Unit) { fun spaceSettings(block: SpaceSettingsRobot.() -> Unit) {
clickOn(R.id.spaceSettings) clickOnSheet(R.id.spaceSettings)
waitUntilActivityVisible<SpaceManageActivity> { waitUntilActivityVisible<SpaceManageActivity> {
waitUntilViewVisible(ViewMatchers.withId(R.id.roomSettingsRecyclerView)) waitUntilViewVisible(ViewMatchers.withId(R.id.roomSettingsRecyclerView))
} }
@ -78,7 +79,7 @@ class SpaceMenuRobot {
} }
fun exploreRooms() { fun exploreRooms() {
clickOn(R.id.exploreRooms) clickOnSheet(R.id.exploreRooms)
waitUntilActivityVisible<SpaceExploreActivity> { waitUntilActivityVisible<SpaceExploreActivity> {
waitUntilViewVisible(ViewMatchers.withId(R.id.spaceDirectoryList)) waitUntilViewVisible(ViewMatchers.withId(R.id.spaceDirectoryList))
} }
@ -86,7 +87,7 @@ class SpaceMenuRobot {
} }
fun addRoom() = apply { fun addRoom() = apply {
clickOn(R.id.addRooms) clickOnSheet(R.id.addRooms)
waitUntilActivityVisible<SpaceManageActivity> { waitUntilActivityVisible<SpaceManageActivity> {
waitUntilViewVisible(ViewMatchers.withId(R.id.roomList)) waitUntilViewVisible(ViewMatchers.withId(R.id.roomList))
} }
@ -94,7 +95,7 @@ class SpaceMenuRobot {
} }
fun addSpace() = apply { fun addSpace() = apply {
clickOn(R.id.addSpaces) clickOnSheet(R.id.addSpaces)
waitUntilActivityVisible<SpaceManageActivity> { waitUntilActivityVisible<SpaceManageActivity> {
waitUntilViewVisible(ViewMatchers.withId(R.id.roomList)) waitUntilViewVisible(ViewMatchers.withId(R.id.roomList))
} }
@ -102,7 +103,7 @@ class SpaceMenuRobot {
} }
fun leaveSpace() { fun leaveSpace() {
clickOn(R.id.leaveSpace) clickOnSheet(R.id.leaveSpace)
waitUntilDialogVisible(ViewMatchers.withId(R.id.leaveButton)) waitUntilDialogVisible(ViewMatchers.withId(R.id.leaveButton))
clickOn(R.id.leave_selected) clickOn(R.id.leave_selected)
waitUntilActivityVisible<SpaceLeaveAdvancedActivity> { waitUntilActivityVisible<SpaceLeaveAdvancedActivity> {