From 6badbe738d1659617665953d460a1bd2131b1395 Mon Sep 17 00:00:00 2001 From: NIkita Fedrunov Date: Thu, 8 Sep 2022 12:09:33 +0200 Subject: [PATCH] robots are not checking feature flag for newAppLayout --- .../im/vector/app/ui/robot/ElementRobot.kt | 29 +++++++++---------- .../im/vector/app/ui/robot/NewRoomRobot.kt | 6 ++-- .../im/vector/app/ui/robot/RoomListRobot.kt | 10 +++---- .../settings/labs/LabFeaturesPreferences.kt | 19 ++++++++++++ .../vector/app/ui/robot/space/SpaceRobot.kt | 11 +++---- 5 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 vector-app/src/androidTest/java/im/vector/app/ui/robot/settings/labs/LabFeaturesPreferences.kt diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt index 48a435c877..b70fcfec25 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt @@ -37,8 +37,6 @@ import im.vector.app.espresso.tools.clickOnPreference import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilViewVisible -import im.vector.app.features.DefaultVectorFeatures -import im.vector.app.features.VectorFeatures import im.vector.app.features.createdirect.CreateDirectRoomActivity import im.vector.app.features.home.HomeActivity import im.vector.app.features.onboarding.OnboardingActivity @@ -46,13 +44,14 @@ import im.vector.app.features.settings.VectorSettingsActivity 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.settings.labs.LabFeaturesPreferences import im.vector.app.ui.robot.space.SpaceRobot import im.vector.app.withIdlingResource import timber.log.Timber -class ElementRobot { - private val features: VectorFeatures = DefaultVectorFeatures() - +class ElementRobot( + private val labsPreferences: LabFeaturesPreferences = LabFeaturesPreferences(false) +) { fun onboarding(block: OnboardingRobot.() -> Unit) { block(OnboardingRobot()) } @@ -83,7 +82,7 @@ class ElementRobot { } fun settings(shouldGoBack: Boolean = true, block: SettingsRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { onView(withId((R.id.avatar))).perform(click()) } else { openDrawer() @@ -96,7 +95,7 @@ class ElementRobot { } fun newDirectMessage(block: NewDirectMessageRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.newLayoutCreateChatButton) waitUntilDialogVisible(withId(R.id.start_chat)) clickOn(R.id.start_chat) @@ -111,29 +110,29 @@ class ElementRobot { closeSoftKeyboard() block(NewDirectMessageRobot()) pressBack() - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { pressBack() // close create dialog } waitUntilViewVisible(withId(R.id.roomListContainer)) } fun newRoom(block: NewRoomRobot.() -> Unit) { - if (!features.isNewAppLayoutEnabled()) { + if (!labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.bottom_action_rooms) } - RoomListRobot().newRoom { block() } - if (features.isNewAppLayoutEnabled()) { + RoomListRobot(labsPreferences).newRoom { block() } + if (labsPreferences.isNewAppLayoutEnabled) { pressBack() // close create dialog } waitUntilViewVisible(withId(R.id.roomListContainer)) } fun roomList(block: RoomListRobot.() -> Unit) { - if (!features.isNewAppLayoutEnabled()) { + if (!labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.bottom_action_rooms) } - block(RoomListRobot()) + block(RoomListRobot(labsPreferences)) waitUntilViewVisible(withId(R.id.roomListContainer)) } @@ -174,7 +173,7 @@ class ElementRobot { } fun signout(expectSignOutWarning: Boolean) { - if (features.isNewAppLayoutFeatureEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { onView(withId((R.id.avatar))) .perform(click()) waitUntilActivityVisible { @@ -224,7 +223,7 @@ class ElementRobot { } fun space(block: SpaceRobot.() -> Unit) { - block(SpaceRobot()) + block(SpaceRobot(labsPreferences)) } } diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt index 3d82fa4a65..55142d128c 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt @@ -23,14 +23,16 @@ import im.vector.app.R import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.VectorFeatures +import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences class NewRoomRobot( - var createdRoom: Boolean = false + var createdRoom: Boolean = false, + private val labsPreferences: LabFeaturesPreferences ) { private val features: VectorFeatures = DefaultVectorFeatures() fun createNewRoom(block: CreateNewRoomRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.string.create_new_room) } waitUntilViewVisible(withId(R.id.createRoomForm)) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt index 71ccad0870..e4984aeed0 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt @@ -28,12 +28,10 @@ import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import im.vector.app.R import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilDialogVisible -import im.vector.app.features.DefaultVectorFeatures -import im.vector.app.features.VectorFeatures import im.vector.app.features.roomdirectory.RoomDirectoryActivity +import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences -class RoomListRobot { - private val features: VectorFeatures = DefaultVectorFeatures() +class RoomListRobot(private val labsPreferences: LabFeaturesPreferences) { fun openRoom(roomName: String, block: RoomDetailRobot.() -> Unit) { clickOn(roomName) @@ -53,7 +51,7 @@ class RoomListRobot { } fun newRoom(block: NewRoomRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.newLayoutCreateChatButton) waitUntilDialogVisible(ViewMatchers.withId(R.id.create_room)) clickOn(R.id.create_room) @@ -63,7 +61,7 @@ class RoomListRobot { BaristaVisibilityAssertions.assertDisplayed(R.id.publicRoomsList) } } - val newRoomRobot = NewRoomRobot() + val newRoomRobot = NewRoomRobot(false, labsPreferences) block(newRoomRobot) if (!newRoomRobot.createdRoom) { pressBack() diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/settings/labs/LabFeaturesPreferences.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/settings/labs/LabFeaturesPreferences.kt new file mode 100644 index 0000000000..8f36e7ae23 --- /dev/null +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/settings/labs/LabFeaturesPreferences.kt @@ -0,0 +1,19 @@ +/* + * 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 + +data class LabFeaturesPreferences(val isNewAppLayoutEnabled: Boolean) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt index 8b69b43107..e8ff58ba6a 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt @@ -30,13 +30,14 @@ import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.VectorFeatures +import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences import org.hamcrest.Matchers -class SpaceRobot { +class SpaceRobot(private val labsPreferences: LabFeaturesPreferences) { private val features: VectorFeatures = DefaultVectorFeatures() fun createSpace(isFirstSpace: Boolean, block: SpaceCreateRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.newLayoutOpenSpacesButton) if (isFirstSpace) { waitUntilDialogVisible(ViewMatchers.withId(R.id.spaces_empty_group)) @@ -59,7 +60,7 @@ class SpaceRobot { } fun spaceMenu(spaceName: String, block: SpaceMenuRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.newLayoutOpenSpacesButton) waitUntilDialogVisible(ViewMatchers.withId(R.id.groupListView)) } else { @@ -73,7 +74,7 @@ class SpaceRobot { fun openMenu(spaceName: String) { waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { Espresso.onView(ViewMatchers.withId(R.id.groupListView)) .perform( RecyclerViewActions.actionOnItem( @@ -95,7 +96,7 @@ class SpaceRobot { } fun selectSpace(spaceName: String) { - if (!features.isNewAppLayoutEnabled()) { + if (!labsPreferences.isNewAppLayoutEnabled) { openDrawer() waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) }