Skip to content

Commit 05dc09c

Browse files
committed
fix
1 parent 2e23da5 commit 05dc09c

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

auth/src/test/java/com/firebase/ui/auth/compose/FirebaseAuthUIAuthStateTest.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,8 @@ class FirebaseAuthUIAuthStateTest {
198198
}
199199

200200
@Test
201-
fun `authStateFlow() emits Success even with unverified email for now`() = runBlocking {
202-
// Given a signed-in user with unverified email
203-
// Note: The current implementation checks for password provider, which might not be
204-
// matched properly due to mocking limitations. This test verifies current behavior.
201+
fun `authStateFlow() emits RequiresEmailVerification for unverified password users`() = runBlocking {
202+
// Given a signed-in user with unverified email using password authentication
205203
val mockProviderData = mock(UserInfo::class.java)
206204
`when`(mockProviderData.providerId).thenReturn("password")
207205

@@ -213,10 +211,11 @@ class FirebaseAuthUIAuthStateTest {
213211
// When collecting auth state flow
214212
val state = authUI.authStateFlow().first()
215213

216-
// Then it should emit Success state (current behavior with mocked data)
217-
assertThat(state).isInstanceOf(AuthState.Success::class.java)
218-
val successState = state as AuthState.Success
219-
assertThat(successState.user).isEqualTo(mockFirebaseUser)
214+
// Then it should emit RequiresEmailVerification state
215+
assertThat(state).isInstanceOf(AuthState.RequiresEmailVerification::class.java)
216+
val verificationState = state as AuthState.RequiresEmailVerification
217+
assertThat(verificationState.user).isEqualTo(mockFirebaseUser)
218+
assertThat(verificationState.email).isEqualTo("[email protected]")
220219
}
221220

222221
@Test

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class MfaEnrollmentScreenTest {
6363
@Mock
6464
private lateinit var mockFirebaseApp: FirebaseApp
6565

66+
@Mock
67+
private lateinit var mockMultiFactor: com.google.firebase.auth.MultiFactor
68+
6669
private lateinit var capturedState: MfaEnrollmentContentState
6770

6871
@Before
@@ -72,6 +75,8 @@ class MfaEnrollmentScreenTest {
7275
`when`(mockAuth.app).thenReturn(mockFirebaseApp)
7376
`when`(mockFirebaseApp.name).thenReturn("TestApp")
7477
`when`(mockUser.email).thenReturn("[email protected]")
78+
`when`(mockUser.multiFactor).thenReturn(mockMultiFactor)
79+
`when`(mockMultiFactor.enrolledFactors).thenReturn(emptyList())
7580
}
7681

7782
@Test

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class MfaEnrollmentScreenTest {
7373
@Mock
7474
private lateinit var mockFirebaseUser: FirebaseUser
7575

76+
@Mock
77+
private lateinit var mockMultiFactor: com.google.firebase.auth.MultiFactor
78+
7679
@Before
7780
fun setUp() {
7881
MockitoAnnotations.openMocks(this)
@@ -100,6 +103,8 @@ class MfaEnrollmentScreenTest {
100103
// Use mock user instead of real Firebase user
101104
`when`(mockFirebaseUser.email).thenReturn("[email protected]")
102105
`when`(mockFirebaseUser.uid).thenReturn("test-uid-123")
106+
`when`(mockFirebaseUser.multiFactor).thenReturn(mockMultiFactor)
107+
`when`(mockMultiFactor.enrolledFactors).thenReturn(emptyList())
103108
testUser = mockFirebaseUser
104109
}
105110

0 commit comments

Comments
 (0)