Using our updated qaTag instead of testTag

This commit is contained in:
ThomasSession 2024-09-17 10:54:01 +10:00
parent d0537c1e8c
commit 01a702ba9c
2 changed files with 22 additions and 6 deletions

View File

@ -45,7 +45,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
@ -58,11 +57,9 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.canhub.cropper.CropImageContract
import com.squareup.phrase.Phrase
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch
@ -80,7 +77,9 @@ import org.thoughtcrime.securesms.debugmenu.DebugActivity
import org.thoughtcrime.securesms.home.PathActivity
import org.thoughtcrime.securesms.messagerequests.MessageRequestsActivity
import org.thoughtcrime.securesms.permissions.Permissions
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.*
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.NoAvatar
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.TempAvatar
import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.UserAvatar
import org.thoughtcrime.securesms.preferences.appearance.AppearanceSettingsActivity
import org.thoughtcrime.securesms.recoverypassword.RecoveryPasswordActivity
import org.thoughtcrime.securesms.ui.AlertDialog
@ -91,10 +90,10 @@ import org.thoughtcrime.securesms.ui.Divider
import org.thoughtcrime.securesms.ui.GetString
import org.thoughtcrime.securesms.ui.LargeItemButton
import org.thoughtcrime.securesms.ui.LargeItemButtonWithDrawable
import org.thoughtcrime.securesms.ui.components.CircularProgressIndicator
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineCopyButton
import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.qaTag
import org.thoughtcrime.securesms.ui.setThemedContent
import org.thoughtcrime.securesms.ui.theme.LocalColors
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
@ -518,7 +517,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
) {
startAvatarSelection()
}
.testTag(stringResource(R.string.AccessibilityId_avatarPicker))
.qaTag(stringResource(R.string.AccessibilityId_avatarPicker))
.background(
shape = CircleShape,
color = LocalColors.current.backgroundBubbleReceived,

View File

@ -6,7 +6,12 @@ import android.content.ContextWrapper
import android.view.View
import android.view.ViewTreeObserver
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 com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.PermissionState
@ -71,3 +76,15 @@ inline fun <T : View> T.afterMeasured(crossinline block: T.() -> Unit) {
}
})
}
/**
* 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)