test(e2e): add test for getToken with custom JWT templates#8053
test(e2e): add test for getToken with custom JWT templates#8053
getToken with custom JWT templates#8053Conversation
🦋 Changeset detectedLatest commit: 1a5cf77 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
getToken with custom JWT templates and skipCachegetToken with custom JWT templates and skipCache
@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: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis pull request adds a changeset marker file and introduces a new integration test for custom JWT templates. The changeset file (.changeset/dull-breads-watch.md) was created as an empty YAML document. The integration test (custom-jwt.test.ts) validates a complete custom JWT template workflow in a Next.js environment, including setting up a test app, creating a JWT template, authenticating a user via UI, and verifying the custom JWT token claims and issued-at timestamps across multiple token requests. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Comment |
|
|
||
| const payload2 = JSON.parse(atob(body2.customToken.split('.')[1])); | ||
| expect(payload2.test_claim).toBe('hello_from_e2e'); | ||
| expect(payload2.iat).toBeGreaterThanOrEqual(payload1.iat); |
There was a problem hiding this comment.
Is this a strong enough assertion to know that we got a freshly minted token with skipCache?
There was a problem hiding this comment.
approved, but defer to jacek
jacekradko
left a comment
There was a problem hiding this comment.
Overall looks good, even though I think we can iterate on this a little bit. For one, we should prove caching works — call fetchToken(false) twice, assert tokens are equal, then fetchToken(true) and assert it differs. The iat assertion can be stronger to not give false positives.
@jacekradko I think I accidentally removed my initial call. You're absolutely right. |
getToken with custom JWT templates and skipCachegetToken with custom JWT templates
@jacekradko So, |
Description
getToken({ template })returns valid custom JWT tokens via a Next.js App Router API routegetTokenreturn tokens with the expectedtest_claimpayloadChecklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Tests
Chores