mirror of
https://github.com/bitwarden/android.git
synced 2024-11-25 02:46:00 +03:00
BIT-859: Add automated test IDs to LandingScreen (#110)
This commit is contained in:
parent
9879e6fd23
commit
3c7a2a99e6
1 changed files with 18 additions and 4 deletions
|
@ -27,10 +27,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.graphics.ColorFilter
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
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.semantics
|
||||||
|
import androidx.compose.ui.semantics.testTag
|
||||||
|
import androidx.compose.ui.semantics.testTagsAsResourceId
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
|
@ -45,6 +49,7 @@ import com.x8bit.bitwarden.ui.platform.components.BitwardenTextField
|
||||||
/**
|
/**
|
||||||
* The top level composable for the Landing screen.
|
* The top level composable for the Landing screen.
|
||||||
*/
|
*/
|
||||||
|
@OptIn(ExperimentalComposeUiApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
@Suppress("LongMethod")
|
@Suppress("LongMethod")
|
||||||
fun LandingScreen(
|
fun LandingScreen(
|
||||||
|
@ -67,6 +72,7 @@ fun LandingScreen(
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.semantics { testTagsAsResourceId = true }
|
||||||
.background(MaterialTheme.colorScheme.surface)
|
.background(MaterialTheme.colorScheme.surface)
|
||||||
.fillMaxHeight()
|
.fillMaxHeight()
|
||||||
.padding(horizontal = 16.dp)
|
.padding(horizontal = 16.dp)
|
||||||
|
@ -99,6 +105,7 @@ fun LandingScreen(
|
||||||
|
|
||||||
BitwardenTextField(
|
BitwardenTextField(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.semantics { testTag = "EmailAddressEntry" }
|
||||||
.padding(
|
.padding(
|
||||||
top = 32.dp,
|
top = 32.dp,
|
||||||
bottom = 10.dp,
|
bottom = 10.dp,
|
||||||
|
@ -113,10 +120,12 @@ fun LandingScreen(
|
||||||
|
|
||||||
RegionSelector(
|
RegionSelector(
|
||||||
selectedOption = state.selectedRegion,
|
selectedOption = state.selectedRegion,
|
||||||
options = LandingState.RegionOption.values().toList(),
|
|
||||||
onOptionSelected = remember(viewModel) {
|
onOptionSelected = remember(viewModel) {
|
||||||
{ viewModel.trySendAction(LandingAction.RegionOptionSelect(it)) }
|
{ viewModel.trySendAction(LandingAction.RegionOptionSelect(it)) }
|
||||||
},
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.semantics { testTag = "RegionSelectorDropdown" }
|
||||||
|
.fillMaxWidth(),
|
||||||
)
|
)
|
||||||
|
|
||||||
BitwardenSwitch(
|
BitwardenSwitch(
|
||||||
|
@ -126,6 +135,7 @@ fun LandingScreen(
|
||||||
{ viewModel.trySendAction(LandingAction.RememberMeToggle(it)) }
|
{ viewModel.trySendAction(LandingAction.RememberMeToggle(it)) }
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.semantics { testTag = "RememberMeSwitch" }
|
||||||
.padding(top = 8.dp)
|
.padding(top = 8.dp)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
)
|
)
|
||||||
|
@ -137,6 +147,7 @@ fun LandingScreen(
|
||||||
},
|
},
|
||||||
isEnabled = state.isContinueButtonEnabled,
|
isEnabled = state.isContinueButtonEnabled,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.semantics { testTag = "ContinueButton" }
|
||||||
.padding(top = 32.dp)
|
.padding(top = 32.dp)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
)
|
)
|
||||||
|
@ -163,6 +174,8 @@ fun LandingScreen(
|
||||||
onClick = remember(viewModel) {
|
onClick = remember(viewModel) {
|
||||||
{ viewModel.trySendAction(LandingAction.CreateAccountClick) }
|
{ viewModel.trySendAction(LandingAction.CreateAccountClick) }
|
||||||
},
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.semantics { testTag = "CreateAccountLabel" },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,20 +189,21 @@ fun LandingScreen(
|
||||||
* and displays the currently selected region on the UI.
|
* and displays the currently selected region on the UI.
|
||||||
*
|
*
|
||||||
* @param selectedOption The currently selected region option.
|
* @param selectedOption The currently selected region option.
|
||||||
* @param options A list of region options available for selection.
|
|
||||||
* @param onOptionSelected A callback that gets invoked when a region option is selected
|
* @param onOptionSelected A callback that gets invoked when a region option is selected
|
||||||
* and passes the selected option as an argument.
|
* and passes the selected option as an argument.
|
||||||
|
* @param modifier A [Modifier] for the composable.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
private fun RegionSelector(
|
private fun RegionSelector(
|
||||||
selectedOption: LandingState.RegionOption,
|
selectedOption: LandingState.RegionOption,
|
||||||
options: List<LandingState.RegionOption>,
|
|
||||||
onOptionSelected: (LandingState.RegionOption) -> Unit,
|
onOptionSelected: (LandingState.RegionOption) -> Unit,
|
||||||
|
modifier: Modifier,
|
||||||
) {
|
) {
|
||||||
|
val options = LandingState.RegionOption.values().toList()
|
||||||
var expanded by remember { mutableStateOf(false) }
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Box(modifier = Modifier.fillMaxWidth()) {
|
Box(modifier = modifier) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable { expanded = !expanded }
|
.clickable { expanded = !expanded }
|
||||||
|
|
Loading…
Reference in a new issue