From 27824a279ab350874d8d9fbd4eea3111630df48f Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Tue, 25 Apr 2023 18:01:54 +0200 Subject: [PATCH] Fix: Maestro tests fail when using settings (#358) * Fix Maestro tests using 'Settings' to open the settings screen. * Try to allow manually running Maestro tests. * Also adjust logout flow. --- .github/workflows/maestro.yml | 2 +- .maestro/tests/account/logout.yaml | 3 ++- .maestro/tests/settings/settings.yaml | 3 ++- .../features/roomlist/impl/components/RoomListTopBar.kt | 9 +++++++-- .../io/element/android/libraries/testtags/TestTags.kt | 5 +++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/maestro.yml b/.github/workflows/maestro.yml index 72f9aee8f1..13e0c3b4ad 100644 --- a/.github/workflows/maestro.yml +++ b/.github/workflows/maestro.yml @@ -16,7 +16,7 @@ jobs: maestro-cloud: name: Maestro test suite runs-on: ubuntu-latest - if: github.event.review.state == 'approved' + if: github.event.review.state == 'approved' || github.event_name == 'workflow_dispatch' strategy: fail-fast: false # Allow one per PR. diff --git a/.maestro/tests/account/logout.yaml b/.maestro/tests/account/logout.yaml index 3c9dd07972..a06ac25e2d 100644 --- a/.maestro/tests/account/logout.yaml +++ b/.maestro/tests/account/logout.yaml @@ -1,6 +1,7 @@ appId: ${APP_ID} --- -- tapOn: "Settings" +- tapOn: + id: "home_screen-settings" - tapOn: "Sign out" - takeScreenshot: build/maestro/900-SignOutDialg # Ensure cancel cancels diff --git a/.maestro/tests/settings/settings.yaml b/.maestro/tests/settings/settings.yaml index 397a0f70b5..ee3104024c 100644 --- a/.maestro/tests/settings/settings.yaml +++ b/.maestro/tests/settings/settings.yaml @@ -1,6 +1,7 @@ appId: ${APP_ID} --- -- tapOn: "Settings" +- tapOn: + id: "home_screen-settings" - assertVisible: "Rageshake to report bug" - takeScreenshot: build/maestro/600-Settings - tapOn: diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt index 48c8ac0253..11f0616e07 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt @@ -45,6 +45,8 @@ import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.designsystem.utils.LogCompositions import io.element.android.libraries.matrix.api.core.UserId import io.element.android.libraries.matrix.ui.model.MatrixUser +import io.element.android.libraries.testtags.TestTags +import io.element.android.libraries.testtags.testTag import io.element.android.libraries.ui.strings.R as StringR @OptIn(ExperimentalMaterial3Api::class) @@ -101,14 +103,17 @@ private fun DefaultRoomListTopBar( }, navigationIcon = { if (matrixUser != null) { - IconButton(onClick = onOpenSettings) { + IconButton( + modifier = Modifier.testTag(TestTags.homeScreenSettings), + onClick = onOpenSettings + ) { Avatar(matrixUser.avatarData, contentDescription = stringResource(StringR.string.common_settings)) } } }, actions = { IconButton( - onClick = onSearchClicked + onClick = onSearchClicked, ) { Icon(Icons.Default.Search, contentDescription = stringResource(StringR.string.action_search)) } diff --git a/libraries/testtags/src/main/kotlin/io/element/android/libraries/testtags/TestTags.kt b/libraries/testtags/src/main/kotlin/io/element/android/libraries/testtags/TestTags.kt index a254a636ef..df12c755e3 100644 --- a/libraries/testtags/src/main/kotlin/io/element/android/libraries/testtags/TestTags.kt +++ b/libraries/testtags/src/main/kotlin/io/element/android/libraries/testtags/TestTags.kt @@ -38,6 +38,11 @@ object TestTags { */ val changeServerServer = TestTag("change_server-server") val changeServerContinue = TestTag("change_server-continue") + + /** + * Room list / Home screen. + */ + val homeScreenSettings = TestTag("home_screen-settings") }