BIT-1166: Adding element ids for the account switcher (#669)

This commit is contained in:
Joshua Queen 2024-01-18 14:46:56 -05:00 committed by Álison Fernandes
parent e7a5cb86f3
commit 3500f90812

View file

@ -34,10 +34,14 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.R import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.lowercaseWithCurrentLocal import com.x8bit.bitwarden.ui.platform.base.util.lowercaseWithCurrentLocal
@ -84,7 +88,7 @@ private const val MAXIMUM_ACCOUNT_LIMIT = 5
* @param topAppBarScrollBehavior Used to derive the background color of the content and keep it in * @param topAppBarScrollBehavior Used to derive the background color of the content and keep it in
* sync with the associated app bar. * sync with the associated app bar.
*/ */
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@Suppress("LongMethod") @Suppress("LongMethod")
@Composable @Composable
fun BitwardenAccountSwitcher( fun BitwardenAccountSwitcher(
@ -137,7 +141,7 @@ fun BitwardenAccountSwitcher(
} }
} }
Box(modifier = modifier) { Box(modifier = modifier.semantics { testTagsAsResourceId = true }) {
BitwardenAnimatedScrim( BitwardenAnimatedScrim(
isVisible = isVisible, isVisible = isVisible,
onClick = onDismissRequest, onClick = onDismissRequest,
@ -196,6 +200,7 @@ private fun AnimatedAccountSwitcher(
) { ) {
LazyColumn( LazyColumn(
modifier = modifier modifier = modifier
.semantics { testTag = "AccountListView" }
// To prevent going all the way up to the bottom of the screen, we'll add some small // To prevent going all the way up to the bottom of the screen, we'll add some small
// bottom padding. // bottom padding.
.padding(bottom = 24.dp) .padding(bottom = 24.dp)
@ -209,6 +214,7 @@ private fun AnimatedAccountSwitcher(
onSwitchAccountLongClick = onSwitchAccountLongClick, onSwitchAccountLongClick = onSwitchAccountLongClick,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.semantics { testTag = "AccountIconButton" }
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
HorizontalDivider( HorizontalDivider(
@ -222,6 +228,7 @@ private fun AnimatedAccountSwitcher(
onClick = onAddAccountClick, onClick = onAddAccountClick,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.semantics { testTag = "AddAccountButton" }
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
} }