Skip to content

Commit cc80238

Browse files
committed
fix: e2e tests
1 parent a91a68b commit cc80238

File tree

3 files changed

+133
-113
lines changed

3 files changed

+133
-113
lines changed

e2eTest/src/test/java/com/firebase/ui/auth/compose/ui/screens/EmailAuthScreenTest.kt

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.firebase.ui.auth.compose.ui.screens
33
import android.content.Context
44
import android.os.Looper
55
import androidx.compose.runtime.Composable
6+
import androidx.compose.runtime.CompositionLocalProvider
67
import androidx.compose.runtime.collectAsState
78
import androidx.compose.runtime.getValue
89
import androidx.compose.ui.test.assertIsDisplayed
@@ -22,16 +23,11 @@ import com.firebase.ui.auth.compose.configuration.authUIConfiguration
2223
import com.firebase.ui.auth.compose.configuration.auth_provider.AuthProvider
2324
import com.firebase.ui.auth.compose.configuration.string_provider.AuthUIStringProvider
2425
import com.firebase.ui.auth.compose.configuration.string_provider.DefaultAuthUIStringProvider
26+
import com.firebase.ui.auth.compose.configuration.string_provider.LocalAuthUIStringProvider
2527
import com.firebase.ui.auth.compose.testutil.AUTH_STATE_WAIT_TIMEOUT_MS
2628
import com.firebase.ui.auth.compose.testutil.EmulatorAuthApi
27-
import com.firebase.ui.auth.compose.testutil.awaitWithLooper
2829
import com.firebase.ui.auth.compose.testutil.ensureFreshUser
2930
import com.firebase.ui.auth.compose.testutil.verifyEmailInEmulator
30-
import com.firebase.ui.auth.compose.ui.screens.EmailAuthMode
31-
import com.firebase.ui.auth.compose.ui.screens.EmailAuthScreen
32-
import com.firebase.ui.auth.compose.ui.screens.ResetPasswordUI
33-
import com.firebase.ui.auth.compose.ui.screens.SignInUI
34-
import com.firebase.ui.auth.compose.ui.screens.SignUpUI
3531
import com.google.common.truth.Truth.assertThat
3632
import com.google.firebase.FirebaseApp
3733
import com.google.firebase.FirebaseOptions
@@ -540,57 +536,61 @@ class EmailAuthScreenTest {
540536
onError: ((AuthException) -> Unit) = {},
541537
onCancel: (() -> Unit) = {},
542538
) {
543-
EmailAuthScreen(
544-
context = applicationContext,
545-
configuration = configuration,
546-
authUI = authUI,
547-
onSuccess = onSuccess,
548-
onError = onError,
549-
onCancel = onCancel,
550-
) { state ->
551-
when (state.mode) {
552-
EmailAuthMode.SignIn -> {
553-
SignInUI(
554-
configuration = configuration,
555-
email = state.email,
556-
isLoading = state.isLoading,
557-
emailSignInLinkSent = state.emailSignInLinkSent,
558-
password = state.password,
559-
onEmailChange = state.onEmailChange,
560-
onPasswordChange = state.onPasswordChange,
561-
onSignInClick = state.onSignInClick,
562-
onGoToSignUp = state.onGoToSignUp,
563-
onGoToResetPassword = state.onGoToResetPassword,
564-
)
565-
}
566-
567-
EmailAuthMode.SignUp -> {
568-
SignUpUI(
569-
configuration = configuration,
570-
isLoading = state.isLoading,
571-
displayName = state.displayName,
572-
email = state.email,
573-
password = state.password,
574-
confirmPassword = state.confirmPassword,
575-
onDisplayNameChange = state.onDisplayNameChange,
576-
onEmailChange = state.onEmailChange,
577-
onPasswordChange = state.onPasswordChange,
578-
onConfirmPasswordChange = state.onConfirmPasswordChange,
579-
onSignUpClick = state.onSignUpClick,
580-
onGoToSignIn = state.onGoToSignIn,
581-
)
582-
}
583-
584-
EmailAuthMode.ResetPassword -> {
585-
ResetPasswordUI(
586-
configuration = configuration,
587-
isLoading = state.isLoading,
588-
email = state.email,
589-
resetLinkSent = state.resetLinkSent,
590-
onEmailChange = state.onEmailChange,
591-
onSendResetLink = state.onSendResetLinkClick,
592-
onGoToSignIn = state.onGoToSignIn
593-
)
539+
CompositionLocalProvider(
540+
LocalAuthUIStringProvider provides DefaultAuthUIStringProvider(applicationContext)
541+
) {
542+
EmailAuthScreen(
543+
context = applicationContext,
544+
configuration = configuration,
545+
authUI = authUI,
546+
onSuccess = onSuccess,
547+
onError = onError,
548+
onCancel = onCancel,
549+
) { state ->
550+
when (state.mode) {
551+
EmailAuthMode.SignIn -> {
552+
SignInUI(
553+
configuration = configuration,
554+
email = state.email,
555+
isLoading = state.isLoading,
556+
emailSignInLinkSent = state.emailSignInLinkSent,
557+
password = state.password,
558+
onEmailChange = state.onEmailChange,
559+
onPasswordChange = state.onPasswordChange,
560+
onSignInClick = state.onSignInClick,
561+
onGoToSignUp = state.onGoToSignUp,
562+
onGoToResetPassword = state.onGoToResetPassword,
563+
)
564+
}
565+
566+
EmailAuthMode.SignUp -> {
567+
SignUpUI(
568+
configuration = configuration,
569+
isLoading = state.isLoading,
570+
displayName = state.displayName,
571+
email = state.email,
572+
password = state.password,
573+
confirmPassword = state.confirmPassword,
574+
onDisplayNameChange = state.onDisplayNameChange,
575+
onEmailChange = state.onEmailChange,
576+
onPasswordChange = state.onPasswordChange,
577+
onConfirmPasswordChange = state.onConfirmPasswordChange,
578+
onSignUpClick = state.onSignUpClick,
579+
onGoToSignIn = state.onGoToSignIn,
580+
)
581+
}
582+
583+
EmailAuthMode.ResetPassword -> {
584+
ResetPasswordUI(
585+
configuration = configuration,
586+
isLoading = state.isLoading,
587+
email = state.email,
588+
resetLinkSent = state.resetLinkSent,
589+
onEmailChange = state.onEmailChange,
590+
onSendResetLink = state.onSendResetLinkClick,
591+
onGoToSignIn = state.onGoToSignIn
592+
)
593+
}
594594
}
595595
}
596596
}

e2eTest/src/test/java/com/firebase/ui/auth/compose/ui/screens/MfaChallengeScreenTest.kt

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package com.firebase.ui.auth.compose.ui.screens
1616

1717
import android.content.Context
1818
import androidx.compose.runtime.Composable
19+
import androidx.compose.runtime.CompositionLocalProvider
1920
import androidx.compose.ui.test.assertIsDisplayed
2021
import androidx.compose.ui.test.assertIsEnabled
2122
import androidx.compose.ui.test.assertIsNotEnabled
@@ -28,6 +29,7 @@ import com.firebase.ui.auth.compose.FirebaseAuthUI
2829
import com.firebase.ui.auth.compose.configuration.MfaFactor
2930
import com.firebase.ui.auth.compose.configuration.string_provider.AuthUIStringProvider
3031
import com.firebase.ui.auth.compose.configuration.string_provider.DefaultAuthUIStringProvider
32+
import com.firebase.ui.auth.compose.configuration.string_provider.LocalAuthUIStringProvider
3133
import com.firebase.ui.auth.compose.mfa.MfaChallengeContentState
3234
import com.google.common.truth.Truth.assertThat
3335
import com.google.firebase.FirebaseApp
@@ -296,13 +298,17 @@ class MfaChallengeScreenTest {
296298
`when`(mockResolver.hints).thenReturn(listOf<MultiFactorInfo>(mockTotpHint))
297299

298300
composeTestRule.setContent {
299-
MfaChallengeScreen(
300-
resolver = mockResolver,
301-
auth = authUI.auth,
302-
onSuccess = {},
303-
onCancel = {},
304-
onError = {}
305-
)
301+
CompositionLocalProvider(
302+
LocalAuthUIStringProvider provides DefaultAuthUIStringProvider(applicationContext)
303+
) {
304+
MfaChallengeScreen(
305+
resolver = mockResolver,
306+
auth = authUI.auth,
307+
onSuccess = {},
308+
onCancel = {},
309+
onError = {}
310+
)
311+
}
306312
}
307313

308314
composeTestRule.waitForIdle()
@@ -325,13 +331,17 @@ class MfaChallengeScreenTest {
325331
`when`(mockResolver.hints).thenReturn(listOf<MultiFactorInfo>(mockPhoneHint))
326332

327333
composeTestRule.setContent {
328-
MfaChallengeScreen(
329-
resolver = mockResolver,
330-
auth = authUI.auth,
331-
onSuccess = {},
332-
onCancel = {},
333-
onError = {}
334-
)
334+
CompositionLocalProvider(
335+
LocalAuthUIStringProvider provides DefaultAuthUIStringProvider(applicationContext)
336+
) {
337+
MfaChallengeScreen(
338+
resolver = mockResolver,
339+
auth = authUI.auth,
340+
onSuccess = {},
341+
onCancel = {},
342+
onError = {}
343+
)
344+
}
335345
}
336346

337347
composeTestRule.waitForIdle()
@@ -348,13 +358,17 @@ class MfaChallengeScreenTest {
348358
`when`(mockResolver.hints).thenReturn(listOf<MultiFactorInfo>(mockTotpHint))
349359

350360
composeTestRule.setContent {
351-
MfaChallengeScreen(
352-
resolver = mockResolver,
353-
auth = authUI.auth,
354-
onSuccess = {},
355-
onCancel = {},
356-
onError = {}
357-
)
361+
CompositionLocalProvider(
362+
LocalAuthUIStringProvider provides DefaultAuthUIStringProvider(applicationContext)
363+
) {
364+
MfaChallengeScreen(
365+
resolver = mockResolver,
366+
auth = authUI.auth,
367+
onSuccess = {},
368+
onCancel = {},
369+
onError = {}
370+
)
371+
}
358372
}
359373

360374
composeTestRule.waitForIdle()

e2eTest/src/test/java/com/firebase/ui/auth/compose/ui/screens/PhoneAuthScreenTest.kt

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.firebase.ui.auth.compose.ui.screens
33
import android.content.Context
44
import android.os.Looper
55
import androidx.compose.runtime.Composable
6+
import androidx.compose.runtime.CompositionLocalProvider
67
import androidx.compose.runtime.collectAsState
78
import androidx.compose.runtime.getValue
89
import androidx.compose.ui.test.assertIsDisplayed
@@ -27,6 +28,7 @@ import com.firebase.ui.auth.compose.configuration.authUIConfiguration
2728
import com.firebase.ui.auth.compose.configuration.auth_provider.AuthProvider
2829
import com.firebase.ui.auth.compose.configuration.string_provider.AuthUIStringProvider
2930
import com.firebase.ui.auth.compose.configuration.string_provider.DefaultAuthUIStringProvider
31+
import com.firebase.ui.auth.compose.configuration.string_provider.LocalAuthUIStringProvider
3032
import com.firebase.ui.auth.compose.data.CountryUtils
3133
import com.firebase.ui.auth.compose.testutil.AUTH_STATE_WAIT_TIMEOUT_MS
3234
import com.firebase.ui.auth.compose.testutil.EmulatorAuthApi
@@ -411,41 +413,45 @@ class PhoneAuthScreenTest {
411413
onCancel: (() -> Unit) = {},
412414
onStepChange: ((PhoneAuthStep) -> Unit) = {},
413415
) {
414-
PhoneAuthScreen(
415-
context = applicationContext,
416-
configuration = configuration,
417-
authUI = authUI,
418-
onSuccess = onSuccess,
419-
onError = onError,
420-
onCancel = onCancel,
421-
) { state ->
422-
onStepChange(state.step)
423-
424-
when (state.step) {
425-
PhoneAuthStep.EnterPhoneNumber -> {
426-
EnterPhoneNumberUI(
427-
configuration = configuration,
428-
isLoading = state.isLoading,
429-
phoneNumber = state.phoneNumber,
430-
selectedCountry = state.selectedCountry,
431-
onPhoneNumberChange = state.onPhoneNumberChange,
432-
onCountrySelected = state.onCountrySelected,
433-
onSendCodeClick = state.onSendCodeClick,
434-
)
435-
}
436-
437-
PhoneAuthStep.EnterVerificationCode -> {
438-
EnterVerificationCodeUI(
439-
configuration = configuration,
440-
isLoading = state.isLoading,
441-
verificationCode = state.verificationCode,
442-
fullPhoneNumber = state.fullPhoneNumber,
443-
resendTimer = state.resendTimer,
444-
onVerificationCodeChange = state.onVerificationCodeChange,
445-
onVerifyCodeClick = state.onVerifyCodeClick,
446-
onResendCodeClick = state.onResendCodeClick,
447-
onChangeNumberClick = state.onChangeNumberClick,
448-
)
416+
CompositionLocalProvider(
417+
LocalAuthUIStringProvider provides DefaultAuthUIStringProvider(applicationContext)
418+
) {
419+
PhoneAuthScreen(
420+
context = applicationContext,
421+
configuration = configuration,
422+
authUI = authUI,
423+
onSuccess = onSuccess,
424+
onError = onError,
425+
onCancel = onCancel,
426+
) { state ->
427+
onStepChange(state.step)
428+
429+
when (state.step) {
430+
PhoneAuthStep.EnterPhoneNumber -> {
431+
EnterPhoneNumberUI(
432+
configuration = configuration,
433+
isLoading = state.isLoading,
434+
phoneNumber = state.phoneNumber,
435+
selectedCountry = state.selectedCountry,
436+
onPhoneNumberChange = state.onPhoneNumberChange,
437+
onCountrySelected = state.onCountrySelected,
438+
onSendCodeClick = state.onSendCodeClick,
439+
)
440+
}
441+
442+
PhoneAuthStep.EnterVerificationCode -> {
443+
EnterVerificationCodeUI(
444+
configuration = configuration,
445+
isLoading = state.isLoading,
446+
verificationCode = state.verificationCode,
447+
fullPhoneNumber = state.fullPhoneNumber,
448+
resendTimer = state.resendTimer,
449+
onVerificationCodeChange = state.onVerificationCodeChange,
450+
onVerifyCodeClick = state.onVerifyCodeClick,
451+
onResendCodeClick = state.onResendCodeClick,
452+
onChangeNumberClick = state.onChangeNumberClick,
453+
)
454+
}
449455
}
450456
}
451457
}

0 commit comments

Comments
 (0)