From 7036d2424cd8b9866243edbe5e9954c3895e2a4e Mon Sep 17 00:00:00 2001 From: demolaf Date: Wed, 26 Aug 2026 16:36:27 +0100 Subject: [PATCH] fix(e2e): wait for linked provider, not just AuthState.Success, in credential linking tests --- .../auth/ui/screens/CredentialLinkingScreenTest.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/e2eTest/src/test/java/com/firebase/ui/auth/ui/screens/CredentialLinkingScreenTest.kt b/e2eTest/src/test/java/com/firebase/ui/auth/ui/screens/CredentialLinkingScreenTest.kt index 49346377f..59c92a4f8 100644 --- a/e2eTest/src/test/java/com/firebase/ui/auth/ui/screens/CredentialLinkingScreenTest.kt +++ b/e2eTest/src/test/java/com/firebase/ui/auth/ui/screens/CredentialLinkingScreenTest.kt @@ -248,11 +248,16 @@ class CredentialLinkingScreenTest { shadowOf(Looper.getMainLooper()).idle() // Step 7: Wait for success + // Note: `currentAuthState` may already be `AuthState.Success` from the initial + // email/password sign-in, so checking `is AuthState.Success` alone can pass + // immediately before the phone link has actually completed. Wait for the + // linked provider to actually show up on the (mutated-in-place) user instead. println("TEST: Waiting for auth state change after phone verification...") composeTestRule.waitUntil(timeoutMillis = AUTH_STATE_WAIT_TIMEOUT_MS) { shadowOf(Looper.getMainLooper()).idle() println("TEST: Auth state: $currentAuthState") - currentAuthState is AuthState.Success + val state = currentAuthState + state is AuthState.Success && state.user.providerData.any { it.providerId == "phone" } } // Step 8: Verify the UID is preserved (linking happened, not a new account) @@ -369,11 +374,16 @@ class CredentialLinkingScreenTest { shadowOf(Looper.getMainLooper()).idle() // Step 6: Wait for linking to complete + // Note: `currentAuthState` may already be `AuthState.Success` from the initial + // email/password sign-in, so checking `is AuthState.Success` alone can pass + // immediately before the Google link has actually completed. Wait for the + // linked provider to actually show up on the (mutated-in-place) user instead. println("TEST: Waiting for Google linking to complete...") composeTestRule.waitUntil(timeoutMillis = AUTH_STATE_WAIT_TIMEOUT_MS) { shadowOf(Looper.getMainLooper()).idle() println("TEST: Auth state: $currentAuthState") - currentAuthState is AuthState.Success + val state = currentAuthState + state is AuthState.Success && state.user.providerData.any { it.providerId == "google.com" } } // Step 7: Verify the UID is preserved and Google provider is added