Skip to content

test(journeys-admin): enhance ImpersonateDialog tests with Firebase a…#9243

Open
mikeallisonJS wants to merge 2 commits into
mainfrom
26-00-MA-fix-impersonation
Open

test(journeys-admin): enhance ImpersonateDialog tests with Firebase a…#9243
mikeallisonJS wants to merge 2 commits into
mainfrom
26-00-MA-fix-impersonation

Conversation

@mikeallisonJS
Copy link
Copy Markdown
Collaborator

@mikeallisonJS mikeallisonJS commented May 21, 2026

…uthentication mocks

  • Added mocks for Firebase authentication to improve test reliability.
  • Updated tests to verify user impersonation and session handling.
  • Removed unnecessary Apollo client usage in ImpersonateDialog component.

Summary by CodeRabbit

  • Bug Fixes

    • Improved user impersonation process with enhanced server-side session management for more reliable authentication state handling.
  • Tests

    • Updated impersonation tests to validate authentication flow with proper session credential verification.

Review Change Stack

…uthentication mocks

- Added mocks for Firebase authentication to improve test reliability.
- Updated tests to verify user impersonation and session handling.
- Removed unnecessary Apollo client usage in ImpersonateDialog component.
@mikeallisonJS mikeallisonJS requested a review from csiyang May 21, 2026 18:52
@mikeallisonJS mikeallisonJS self-assigned this May 21, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 52cc171a-6c38-43b3-bf52-39843fcf0eda

📥 Commits

Reviewing files that changed from the base of the PR and between 64b1ad2 and b59db6d.

📒 Files selected for processing (2)
  • apps/journeys-admin/src/components/PageWrapper/NavigationDrawer/UserNavigation/ImpersonateDialog/ImpersonateDialog.spec.tsx
  • apps/journeys-admin/src/components/PageWrapper/NavigationDrawer/UserNavigation/ImpersonateDialog/ImpersonateDialog.tsx

Walkthrough

ImpersonateDialog shifts from Apollo cache reset to credential-based session refresh. The implementation now signs in with a custom Firebase token to obtain a credential, then calls loginWithCredential to refresh the server-side session. Tests mock both Firebase auth and the credential helper, verifying both calls occur after successful impersonation.

Changes

Impersonation Authentication Refactoring

Layer / File(s) Summary
Impersonation credential-based login implementation
apps/journeys-admin/src/components/PageWrapper/NavigationDrawer/UserNavigation/ImpersonateDialog/ImpersonateDialog.tsx
Removes useApolloClient hook and client.resetStore() call; adds loginWithCredential import and replaces the post-token-signin flow with a credential capture step followed by loginWithCredential(credential) to refresh server-side session.
Test mocks and assertions for credential-based impersonation
apps/journeys-admin/src/components/PageWrapper/NavigationDrawer/UserNavigation/ImpersonateDialog/ImpersonateDialog.spec.tsx
Mocks firebase/auth and loginWithCredential helper; creates a mock UserCredential object; adds assertions verifying signInWithCustomToken is called with the token and loginWithCredential is called with the returned credential.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'test(journeys-admin): enhance ImpersonateDialog tests with Firebase a…' directly describes the main change: enhancing tests for ImpersonateDialog with Firebase authentication mocks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 26-00-MA-fix-impersonation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 21, 2026

View your CI Pipeline Execution ↗ for commit b59db6d

Command Status Duration Result
nx affected --target=build --base=64b1ad2a90b5b... ✅ Succeeded 3s View ↗
nx affected --target=fetch-secrets --base=64b1a... ✅ Succeeded <1s View ↗
nx run-many --target=prisma-generate --all --pa... ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-21 20:27:06 UTC

@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin May 21, 2026 18:53 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Fri May 22 07:02:01 NZST 2026

@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin May 21, 2026 18:59 Inactive
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