Skip to content

test(core): configure shared vitest setup#232

Merged
halvaradop merged 2 commits into
masterfrom
test/set-up-files
Jul 23, 2026
Merged

test(core): configure shared vitest setup#232
halvaradop merged 2 commits into
masterfrom
test/set-up-files

Conversation

@halvaradop

@halvaradop halvaradop commented Jul 23, 2026

Copy link
Copy Markdown
Member

Description

This pull request configures a shared Vitest setup across the @aura-stack/auth monorepo.

It introduces two new setup files, vitest.setup.ts and actions.setup.ts, to centralize common test configuration and reduce duplicated setup code across test suites. This results in a simpler, more maintainable testing infrastructure while keeping individual test files focused on their specific behavior.

Key Changes

  • Added a shared vitest.setup.ts file.
  • Added a shared actions.setup.ts file.
  • Centralized common test configuration.
  • Reduced duplicated setup code across test suites.
  • Simplified the test configuration for packages within the monorepo.

@coderabbitai ignore

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
auth Skipped Skipped Jul 23, 2026 6:04pm

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Vitest cleanup and rate-limiter mocks are centralized in shared setup. Individual action, API, and utility tests remove duplicated teardown logic. Vitest configuration now separates core and rate-limiter projects, and stateless getSession coverage is added.

Changes

Vitest harness and test suites

Layer / File(s) Summary
Shared setup and project configuration
packages/core/test/setup/vitest.setup.ts, packages/core/vitest.config.ts
Adds global cleanup and rate-limiter mocking, and defines separate core and rate-limiter Vitest projects with scoped aliases.
Action test setup consolidation
packages/core/test/actions/...
Removes per-file afterEach cleanup and local rate-limiter mocks from action tests while retaining existing test behavior.
API test setup consolidation
packages/core/test/api/...
Removes duplicated teardown and rate-limiter overrides from stateful and stateless API tests.
Core test cleanup and session coverage
packages/core/test/{client,env,identity,instance,jose}.test.ts, packages/core/test/api/stateless/getSession.test.ts
Removes local cleanup from utility tests and adds stateless getSession coverage for token validity, claims, expiration, and rolling refresh.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: refactor

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding shared Vitest setup/configuration for the core test suite.
✨ 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 test/set-up-files

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/test/api/stateless/getSession.test.ts`:
- Around line 100-107: Update the session assertions in the affected stateless
session tests to distinguish fixed and rolling behavior: remove the
incoming-cookie decode assertion from the fixed-session case, and in the
rolling-session case assert that the refreshed decodeSession does not contain
role or permissions rather than relying only on toMatchObject. Preserve the
existing session.user assertions and use the visible decodeSession variable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 74733914-be64-461d-b327-911922aa3779

📥 Commits

Reviewing files that changed from the base of the PR and between 7bcc069 and e9d6a50.

📒 Files selected for processing (39)
  • packages/core/test/actions/callback/stateless.test.ts
  • packages/core/test/actions/csrfToken/stateless.test.ts
  • packages/core/test/actions/providers/connected/stateless.test.ts
  • packages/core/test/actions/providers/tokens/revoke/stateless.test.ts
  • packages/core/test/actions/providers/tokens/tokens/stateful.test.ts
  • packages/core/test/actions/providers/tokens/tokens/stateless.test.ts
  • packages/core/test/actions/session/session/stateful.test.ts
  • packages/core/test/actions/session/session/stateless.test.ts
  • packages/core/test/actions/session/updateSession/stateless.test.ts
  • packages/core/test/actions/signIn/signIn/stateless.test.ts
  • packages/core/test/actions/signIn/signInCredentials/stateful.test.ts
  • packages/core/test/actions/signIn/signInCredentials/stateless.test.ts
  • packages/core/test/actions/signOut/stateless.test.ts
  • packages/core/test/actions/signUp/stateful.test.ts
  • packages/core/test/actions/signUp/stateless.test.ts
  • packages/core/test/api/stateful/getProviderTokens.test.ts
  • packages/core/test/api/stateful/getSession.test.ts
  • packages/core/test/api/stateful/signInCredentials.test.ts
  • packages/core/test/api/stateful/signOut.test.ts
  • packages/core/test/api/stateful/signUp.test.ts
  • packages/core/test/api/stateful/updateSession.test.ts
  • packages/core/test/api/stateless/getAccessToken.test.ts
  • packages/core/test/api/stateless/getProviderTokens.test.ts
  • packages/core/test/api/stateless/getSession.test.ts
  • packages/core/test/api/stateless/isProviderConnected.test.ts
  • packages/core/test/api/stateless/refreshUserInfo.test.ts
  • packages/core/test/api/stateless/revokeToken.test.ts
  • packages/core/test/api/stateless/signIn.test.ts
  • packages/core/test/api/stateless/signInCredentials.test.ts
  • packages/core/test/api/stateless/signOut.test.ts
  • packages/core/test/api/stateless/signUp.test.ts
  • packages/core/test/api/stateless/updateSession.test.ts
  • packages/core/test/client/client.test.ts
  • packages/core/test/env.test.ts
  • packages/core/test/identity.test.ts
  • packages/core/test/instance.test.ts
  • packages/core/test/jose.test.ts
  • packages/core/test/setup/vitest.setup.ts
  • packages/core/vitest.config.ts
💤 Files with no reviewable changes (3)
  • packages/core/test/actions/callback/stateless.test.ts
  • packages/core/test/client/client.test.ts
  • packages/core/test/jose.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/test/api/stateless/getSession.test.ts`:
- Around line 100-107: Update the session assertions in the affected stateless
session tests to distinguish fixed and rolling behavior: remove the
incoming-cookie decode assertion from the fixed-session case, and in the
rolling-session case assert that the refreshed decodeSession does not contain
role or permissions rather than relying only on toMatchObject. Preserve the
existing session.user assertions and use the visible decodeSession variable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 74733914-be64-461d-b327-911922aa3779

📥 Commits

Reviewing files that changed from the base of the PR and between 7bcc069 and e9d6a50.

📒 Files selected for processing (39)
  • packages/core/test/actions/callback/stateless.test.ts
  • packages/core/test/actions/csrfToken/stateless.test.ts
  • packages/core/test/actions/providers/connected/stateless.test.ts
  • packages/core/test/actions/providers/tokens/revoke/stateless.test.ts
  • packages/core/test/actions/providers/tokens/tokens/stateful.test.ts
  • packages/core/test/actions/providers/tokens/tokens/stateless.test.ts
  • packages/core/test/actions/session/session/stateful.test.ts
  • packages/core/test/actions/session/session/stateless.test.ts
  • packages/core/test/actions/session/updateSession/stateless.test.ts
  • packages/core/test/actions/signIn/signIn/stateless.test.ts
  • packages/core/test/actions/signIn/signInCredentials/stateful.test.ts
  • packages/core/test/actions/signIn/signInCredentials/stateless.test.ts
  • packages/core/test/actions/signOut/stateless.test.ts
  • packages/core/test/actions/signUp/stateful.test.ts
  • packages/core/test/actions/signUp/stateless.test.ts
  • packages/core/test/api/stateful/getProviderTokens.test.ts
  • packages/core/test/api/stateful/getSession.test.ts
  • packages/core/test/api/stateful/signInCredentials.test.ts
  • packages/core/test/api/stateful/signOut.test.ts
  • packages/core/test/api/stateful/signUp.test.ts
  • packages/core/test/api/stateful/updateSession.test.ts
  • packages/core/test/api/stateless/getAccessToken.test.ts
  • packages/core/test/api/stateless/getProviderTokens.test.ts
  • packages/core/test/api/stateless/getSession.test.ts
  • packages/core/test/api/stateless/isProviderConnected.test.ts
  • packages/core/test/api/stateless/refreshUserInfo.test.ts
  • packages/core/test/api/stateless/revokeToken.test.ts
  • packages/core/test/api/stateless/signIn.test.ts
  • packages/core/test/api/stateless/signInCredentials.test.ts
  • packages/core/test/api/stateless/signOut.test.ts
  • packages/core/test/api/stateless/signUp.test.ts
  • packages/core/test/api/stateless/updateSession.test.ts
  • packages/core/test/client/client.test.ts
  • packages/core/test/env.test.ts
  • packages/core/test/identity.test.ts
  • packages/core/test/instance.test.ts
  • packages/core/test/jose.test.ts
  • packages/core/test/setup/vitest.setup.ts
  • packages/core/vitest.config.ts
💤 Files with no reviewable changes (3)
  • packages/core/test/actions/callback/stateless.test.ts
  • packages/core/test/client/client.test.ts
  • packages/core/test/jose.test.ts
🛑 Comments failed to post (1)
packages/core/test/api/stateless/getSession.test.ts (1)

100-107: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert filtering on the refreshed token, not the request token.

Line 100 decodes the incoming cookie because fixed sessions do not issue a replacement token. Remove that assertion. For the rolling case, explicitly assert decodeSession lacks role and permissions; toMatchObject permits both claims.

Proposed fix
-        const decodeSession = await jose.decodeJWT(getCookie(session.headers, "aura-auth.session_token")!)
-        expect(decodeSession).toMatchObject({
-            sub: "123",
-            name: "Alice",
-            email: "alice@example.com",
-        })
         expect(session.session?.user).not.toHaveProperty("role")
         expect(session.session?.user).not.toHaveProperty("permissions")
@@
         expect(decodeSession).toMatchObject({
             sub: "123",
             name: "Alice",
             email: "alice@example.com",
         })
-        expect(session.session?.user).not.toHaveProperty("role")
-        expect(session.session?.user).not.toHaveProperty("permissions")
+        expect(decodeSession).not.toHaveProperty("role")
+        expect(decodeSession).not.toHaveProperty("permissions")

Also applies to: 135-142

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/test/api/stateless/getSession.test.ts` around lines 100 - 107,
Update the session assertions in the affected stateless session tests to
distinguish fixed and rolling behavior: remove the incoming-cookie decode
assertion from the fixed-session case, and in the rolling-session case assert
that the refreshed decodeSession does not contain role or permissions rather
than relying only on toMatchObject. Preserve the existing session.user
assertions and use the visible decodeSession variable.

@halvaradop
halvaradop merged commit 499211c into master Jul 23, 2026
7 checks passed
@halvaradop
halvaradop deleted the test/set-up-files branch July 23, 2026 18:06
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