Skip to content

fix(auth): show the link-sent confirmation on anonymous upgrade, with e2e tests - #2484

Open
demolaf wants to merge 2 commits into
version-10.0.0-beta05from
fix/email-link-sign-in-confirmation
Open

fix(auth): show the link-sent confirmation on anonymous upgrade, with e2e tests#2484
demolaf wants to merge 2 commits into
version-10.0.0-beta05from
fix/email-link-sign-in-confirmation

Conversation

@demolaf

@demolaf demolaf commented Sep 6, 2026

Copy link
Copy Markdown
Member

Sending an email link while an anonymous user was signed in showed no confirmation. Retracting the EmailSignInLinkSent notification to Idle makes authStateFlow()'s combine fall back to reporting the session, so the pre-existing anonymous session arrived as a fresh Success and reset the back stack to the success route, tearing the dialog down with the screen that owned it.

  • FirebaseAuthScreen.kt: the steps that own a "link sent" confirmation are no longer reset off by a re-asserted session — only a real credential exchange, which is the only thing carrying an AuthResult, still completes to the success route. Applied to the RequiresEmailVerification / RequiresProfileCompletion branch too, since authUserState routes an unverified password user there rather than to Success. The guard is stateless, so it holds across activity recreation and is unaffected by StateFlow conflation. Same reasoning as the existing Phone.EnterPhoneNumber exemption in the Idle branch.

Email link sign-in had a single e2e test buried in EmailAuthScreenTest. It now has its own EmailLinkAuthScreenTest with nine, covering the cross-device prompt and completion, the method-picker hand-off, anonymous upgrade, and the wrong-device, foreign-anonymous-id and different-anonymous-user guards — with the anonymous upgrade case asserting the flow stayed on the email link step, verified to fail on the old code and pass with the fix. Link delivery now fails rather than Assume-skips on timeout, so a slow emulator can no longer report the class green. 966 unit and 71 e2e tests pass.

This is an interim fix. The underlying cause — one-shot outcomes modelled as AuthState values, which is what makes retraction expose the session at all — is tracked separately and would delete this guard along with five other workarounds.


Maintainer note: Fixes internal CPRN-422

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the email link sign-in logic and significantly expands its test coverage. In FirebaseAuthScreen.kt, a check is added to prevent resetting the backstack to AuthRoute.Success on notification trailing events. Additionally, email link sign-in tests are extracted from EmailAuthScreenTest.kt into a dedicated EmailLinkAuthScreenTest.kt suite with comprehensive end-to-end scenarios. Feedback includes addressing a potential infinite loop in Robolectric tests due to virtual clock behavior when using Thread.sleep() with System.currentTimeMillis(), and safely checking if lateinit properties are initialized in tearDown() to avoid masking setup failures.

@demolaf
demolaf force-pushed the feat/require-navigation-followups branch from 04ed088 to d9b2cc2 Compare September 6, 2026 21:51
@demolaf
demolaf force-pushed the fix/email-link-sign-in-confirmation branch from c5e1b56 to 9118458 Compare September 6, 2026 21:54
@demolaf
demolaf force-pushed the feat/require-navigation-followups branch from d9b2cc2 to 598ea96 Compare September 7, 2026 10:40
@demolaf
demolaf force-pushed the fix/email-link-sign-in-confirmation branch 3 times, most recently from e0fee1c to 3072f52 Compare September 7, 2026 11:36
@demolaf
demolaf force-pushed the feat/require-navigation-followups branch 2 times, most recently from 42afa07 to cab710b Compare September 7, 2026 14:27
@demolaf
demolaf changed the base branch from feat/require-navigation-followups to version-10.0.0-beta05 September 7, 2026 15:01
@demolaf
demolaf force-pushed the fix/email-link-sign-in-confirmation branch from 3072f52 to f6fd6a7 Compare September 7, 2026 15:01
@demolaf
demolaf force-pushed the fix/email-link-sign-in-confirmation branch from f6fd6a7 to 2371997 Compare September 7, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant