From 79665ad475996f87bb1e08bd36ae8372f875ff7d Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Wed, 21 Aug 2024 14:43:54 +1000 Subject: [PATCH] Creating a custom qaTag modifier --- .../java/org/thoughtcrime/securesms/ui/Util.kt | 17 +++++++++++++++++ .../securesms/ui/components/RadioButton.kt | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt index b49f9c6d60..590e0881a7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt @@ -3,7 +3,12 @@ package org.thoughtcrime.securesms.ui import android.app.Activity import android.content.Context import androidx.compose.runtime.Composable +import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.testTagsAsResourceId import androidx.fragment.app.Fragment import org.thoughtcrime.securesms.ui.theme.SessionMaterialTheme @@ -23,3 +28,15 @@ fun ComposeView.setThemedContent(content: @Composable () -> Unit) = setContent { content() } } + +/** + * This is used to set the test tag that the QA team can use to retrieve an element in appium + * In order to do so we need to set the testTagsAsResourceId to true, which ideally should be done only once + * in the root composable, but our app is currently made up of multiple isolated composables + * set up in the old activity/fragment view system + * As such we need to repeat it for every component that wants to use testTag, until such + * a time as we have one root composable + */ +@OptIn(ExperimentalComposeUiApi::class) +@Composable +fun Modifier.qaTag(tag: String) = semantics { testTagsAsResourceId = true }.testTag(tag) \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/RadioButton.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/RadioButton.kt index 3302ae9de7..ffc029c6d8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/RadioButton.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/RadioButton.kt @@ -35,6 +35,7 @@ import network.loki.messenger.libsession_util.util.ExpiryMode import org.thoughtcrime.securesms.conversation.disappearingmessages.ExpiryType import org.thoughtcrime.securesms.ui.GetString import org.thoughtcrime.securesms.ui.RadioOption +import org.thoughtcrime.securesms.ui.qaTag import org.thoughtcrime.securesms.ui.theme.LocalColors import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.ui.theme.LocalType @@ -122,7 +123,7 @@ fun TitledRadioButton( RadioButton( modifier = modifier .heightIn(min = 60.dp) - .testTag(option.contentDescription.string()), + .qaTag(option.contentDescription.string()), onClick = onClick, selected = option.selected, enabled = option.enabled,