test(e2e): add multi-session token refresh tests#7949
test(e2e): add multi-session token refresh tests#7949jacekradko wants to merge 2 commits intomainfrom
Conversation
Add integration tests proving that in a multi-session scenario, each session always gets its own correct token — not a token belonging to whichever session was last active. Test 1 (fast): Verifies FAPI token fetch returns a JWT with the correct sid claim for each session after switching between them. Test 2 (slow, ~70s): Verifies server-side middleware refresh/handshake preserves the correct active session after the __session cookie JWT expires, rather than swapping to the most recently touched session.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughA new integration test suite for multi-session token refresh flow is added to the file integration/tests/session-refresh-multi-session.test.ts using Playwright. The suite creates two fake users, registers them, and performs end-to-end interactions across two sessions to verify distinct session IDs (SIDs) in JWT payloads, session switching, and server-side token refresh behavior. Tests are run serially to prevent parallel session interference and include UI-driven sign-in for the first session alongside programmatic sign-in for the second session, JWT token fetching and decoding validation, temporary route blocking for token refresh manipulation, and timeout handling. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Summary
getToken({ skipCache: true })returns a JWT with the correctsidclaim for each session when switching between two active sessions__sessioncookie JWT expires — ensuring session1 isn't swapped to session2 just because session2 was last touchedTest plan
npx playwright test session-refresh-multi-session --project chromepasses against a running app withwithEmailCodesenvSummary by CodeRabbit