Actions block allows testTag (#1122)

This commit is contained in:
David Perez 2024-03-11 16:58:17 -05:00 committed by Álison Fernandes
parent 53c241b4d7
commit b649288948
5 changed files with 14 additions and 4 deletions

View file

@ -50,6 +50,7 @@ fun BitwardenTextFieldWithActions(
keyboardType: KeyboardType = KeyboardType.Text,
trailingIconContent: (@Composable () -> Unit)? = null,
actions: @Composable RowScope.() -> Unit = {},
actionsTestTag: String? = null,
textFieldTestTag: String? = null,
) {
Row(
@ -73,7 +74,10 @@ fun BitwardenTextFieldWithActions(
shouldAddCustomLineBreaks = shouldAddCustomLineBreaks,
visualTransformation = visualTransformation,
)
BitwardenRowOfActions(actions)
BitwardenRowOfActions(
modifier = Modifier.run { actionsTestTag?.let { semantics { testTag = it } } ?: this },
actions = actions,
)
}
}

View file

@ -26,9 +26,12 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
* layout individual icons or buttons.
*/
@Composable
fun BitwardenRowOfActions(actions: @Composable RowScope.() -> Unit) {
fun BitwardenRowOfActions(
modifier: Modifier = Modifier,
actions: @Composable RowScope.() -> Unit,
) {
Row(
modifier = Modifier.padding(start = 8.dp),
modifier = modifier.padding(start = 8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically,
content = actions,

View file

@ -39,6 +39,7 @@ fun BitwardenStepper(
isIncrementEnabled: Boolean = true,
isDecrementEnabled: Boolean = true,
textFieldReadOnly: Boolean = true,
stepperActionsTestTag: String? = null,
increaseButtonTestTag: String? = null,
decreaseButtonTestTag: String? = null,
) {
@ -53,6 +54,7 @@ fun BitwardenStepper(
value = clampedValue
?.toString()
?: ZERO_WIDTH_CHARACTER,
actionsTestTag = stepperActionsTestTag,
actions = {
BitwardenIconButtonWithResource(
iconRes = IconResource(

View file

@ -64,7 +64,7 @@ fun BitwardenSwitchWithActions(
onCheckedChange = null,
)
BitwardenRowOfActions(actions)
BitwardenRowOfActions(actions = actions)
}
}

View file

@ -830,6 +830,7 @@ private fun PassphraseNumWordsCounterItem(
value = coercedNumWords,
range = minValue..maxValue,
onValueChange = onPassphraseNumWordsCounterChange,
stepperActionsTestTag = "NumberOfWordsStepper",
increaseButtonTestTag = "NumberOfWordsIncreaseButton",
decreaseButtonTestTag = "NumberOfWordsDecreaseButton",
modifier = Modifier