Skip to content

Commit

Permalink
Update auth screen for consistent UI testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hueachilles committed Jan 23, 2024
1 parent 985942f commit 8bf0ee9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
8 changes: 7 additions & 1 deletion .maestro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ Target app
[Specify device](https://maestro.mobile.dev/advanced/specify-a-device)
`maestro --device emulator-5554 test auth-tests`

List devices

- Android `adb devices`
- iOS `xcrun simctl list devices booted`

Full test command
`MAESTRO_APP_ID=com.crisiscleanup.demo maestro --device emulator-5554 test auth-tests`
`MAESTRO_APP_ID=com.crisiscleanup.demo.debug maestro --device emulator-5554 test auth-tests`
`MAESTRO_APP_ID=com.crisiscleanup.dev maestro --device device-uuid-from-list test auth-tests`
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import com.crisiscleanup.core.common.R as commonR

@Composable
fun CrisisCleanupLogoRow(
modifier: Modifier = Modifier,
hideHeaderText: Boolean = false,
) {
// TODO Adjust to other screen sizes as necessary
Box(Modifier.padding(top = 16.dp, start = 8.dp)) {
Box(modifier.padding(top = 16.dp, start = 8.dp)) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun RegisterSuccessView(

Spacer(Modifier.weight(1f))

CrisisCleanupLogoRow(true)
CrisisCleanupLogoRow(Modifier,true)

Spacer(Modifier.weight(1f))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.rememberScrollState
Expand All @@ -28,6 +29,7 @@ import com.crisiscleanup.core.designsystem.component.LinkifyText
import com.crisiscleanup.core.designsystem.component.actionHeight
import com.crisiscleanup.core.designsystem.theme.CrisisCleanupTheme
import com.crisiscleanup.core.designsystem.theme.DayNightPreviews
import com.crisiscleanup.core.designsystem.theme.LocalDimensions
import com.crisiscleanup.core.designsystem.theme.LocalFontStyles
import com.crisiscleanup.core.designsystem.theme.fillWidthPadded
import com.crisiscleanup.core.designsystem.theme.listItemModifier
Expand Down Expand Up @@ -65,7 +67,6 @@ fun RootAuthRoute(

@Composable
internal fun RootAuthScreen(
modifier: Modifier = Modifier,
viewModel: RootAuthViewModel = hiltViewModel(),
openLoginWithEmail: () -> Unit = {},
openLoginWithPhone: () -> Unit = {},
Expand All @@ -84,13 +85,22 @@ internal fun RootAuthScreen(
val isKeyboardOpen = rememberIsKeyboardOpen()
val closeKeyboard = rememberCloseKeyboard(viewModel)
val accountData = (authState as AuthState.Authenticated).accountData
Box(modifier) {
Column(
Modifier
.scrollFlingListener(closeKeyboard)
.fillMaxSize()
.verticalScroll(rememberScrollState()),
) {
val contentModifier = Modifier
.fillMaxSize()
.scrollFlingListener(closeKeyboard)
.verticalScroll(rememberScrollState())
if (LocalDimensions.current.isListDetailWidth) {
Row {
Column(Modifier.weight(1f)) {
AuthenticatedScreen(
accountData,
closeAuthentication,
)
}
CrisisCleanupLogoRow(Modifier.weight(1f))
}
} else {
Column(contentModifier) {
AnimatedVisibility(visible = !isKeyboardOpen) {
CrisisCleanupLogoRow()
}
Expand Down Expand Up @@ -124,7 +134,7 @@ private fun AuthenticatedScreen(
val t = LocalAppTranslator.current

Text(
modifier = fillWidthPadded.testTag("authedProfileAccountInfo"),
modifier = fillWidthPadded.testTag("authedAccountInfoText"),
text = t("info.account_is")
.replace("{full_name}", accountData.fullName)
.replace("{email_address}", accountData.emailAddress),
Expand All @@ -136,7 +146,7 @@ private fun AuthenticatedScreen(
val isNotBusy by viewModel.isNotAuthenticating.collectAsStateWithLifecycle()

BusyButton(
modifier = fillWidthPadded.testTag("authedProfileLogoutBtn"),
modifier = fillWidthPadded.testTag("authedLogoutAction"),
onClick = viewModel::logout,
enabled = isNotBusy,
text = t("actions.logout"),
Expand All @@ -147,7 +157,7 @@ private fun AuthenticatedScreen(
"actions.back",
modifier = Modifier
.listItemPadding()
.testTag("authedProfileDismissBtn"),
.testTag("authedCloseScreenAction"),
arrangement = Arrangement.Start,
enabled = isNotBusy,
action = closeAuthentication,
Expand Down

0 comments on commit 8bf0ee9

Please sign in to comment.