Skip to content

Commit

Permalink
Merge branch 'login-tests-fail-on-ci-droid-405'
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-mullvad committed Oct 12, 2023
2 parents cfdfcb1 + a7c27d9 commit 7f092c3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
Expand All @@ -57,6 +60,7 @@ import net.mullvad.mullvadvpn.compose.state.LoginError
import net.mullvad.mullvadvpn.compose.state.LoginState
import net.mullvad.mullvadvpn.compose.state.LoginState.*
import net.mullvad.mullvadvpn.compose.state.LoginUiState
import net.mullvad.mullvadvpn.compose.test.LOGIN_TITLE_TEST_TAG
import net.mullvad.mullvadvpn.compose.textfield.mullvadWhiteTextFieldColors
import net.mullvad.mullvadvpn.compose.util.accountTokenVisualTransformation
import net.mullvad.mullvadvpn.lib.theme.AlphaTopBar
Expand Down Expand Up @@ -95,6 +99,7 @@ private fun PreviewLoginSuccess() {
AppTheme { LoginScreen(uiState = LoginUiState(loginState = Success)) }
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun LoginScreen(
uiState: LoginUiState,
Expand All @@ -105,6 +110,7 @@ fun LoginScreen(
onSettingsClick: () -> Unit = {},
) {
ScaffoldWithTopBar(
modifier = Modifier.semantics { testTagsAsResourceId = true },
topBarColor = MaterialTheme.colorScheme.primary,
statusBarColor = MaterialTheme.colorScheme.primary,
navigationBarColor = MaterialTheme.colorScheme.background,
Expand Down Expand Up @@ -147,7 +153,10 @@ private fun LoginContent(
text = uiState.loginState.title(),
style = MaterialTheme.typography.headlineLarge,
color = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.fillMaxWidth().padding(bottom = Dimens.smallPadding)
modifier =
Modifier.testTag(LOGIN_TITLE_TEST_TAG)
.fillMaxWidth()
.padding(bottom = Dimens.smallPadding)
)

var tfFocusState: FocusState? by remember { mutableStateOf(null) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ const val LOCATION_INFO_TEST_TAG = "location_info_test_tag"

// ConnectScreen - Notification banner
const val NOTIFICATION_BANNER = "notification_banner"

const val LOGIN_TITLE_TEST_TAG = "login_title_test_tag"
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ package net.mullvad.mullvadvpn.test.mockapi

import androidx.test.runner.AndroidJUnit4
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import net.mullvad.mullvadvpn.compose.test.LOGIN_TITLE_TEST_TAG
import net.mullvad.mullvadvpn.test.common.constant.DEFAULT_INTERACTION_TIMEOUT
import net.mullvad.mullvadvpn.test.common.extension.clickAgreeOnPrivacyDisclaimer
import net.mullvad.mullvadvpn.test.common.extension.clickAllowOnNotificationPermissionPromptIfApiLevel33AndAbove
import net.mullvad.mullvadvpn.test.common.extension.findObjectWithTimeout
import net.mullvad.mullvadvpn.test.mockapi.util.currentUtcTimeWithOffsetZero
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith

Expand All @@ -28,7 +32,12 @@ class LoginMockApiTest : MockApiTest() {
app.attemptLogin(validAccountToken)

// Assert
device.findObjectWithTimeout(By.text("Login failed"))
val result =
device
.findObject(By.res(LOGIN_TITLE_TEST_TAG))
.wait(Until.textEquals("Login failed"), DEFAULT_INTERACTION_TIMEOUT)

assertTrue(result)
}

@Test
Expand Down

0 comments on commit 7f092c3

Please sign in to comment.