Skip to content

test(mocks): export SAFE_MOCK_SESSION in next-auth mock and standardize auth test fixtures - #1799

Merged
GauravKarakoti merged 3 commits into
GauravKarakoti:mainfrom
qalvinahmad:qalvinahmad-auth-mock-fixtures
Nov 16, 2026
Merged

GauravKarakoti merged 3 commits into
GauravKarakoti:mainfrom
qalvinahmad:qalvinahmad-auth-mock-fixtures

Conversation

@qalvinahmad

Copy link
Copy Markdown
Contributor

Summary

  • Export a canonical frozen SAFE_MOCK_SESSION from the next-auth mock and consume/re-export it from the auth mock while retaining the legacy alias.
  • Standardize non-sensitive credential and token placeholders across mocks and use shared session fixtures in tests.
  • Update mock credential audit/scanner coverage.

Closes #1792

Validation

  • 49 auth/admin and mock tests
  • 122 CLI tests
  • Both type checks
  • Prettier on changed files

qalvinahmad and others added 2 commits November 16, 2026 14:16
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

@qalvinahmad is attempting to deploy a commit to the Gaurav's projects Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread __mocks__/next-auth/index.ts Outdated
import { SAFE_MOCK_SESSION } from "../../tests/fixtures/mock-session";
export { SAFE_MOCK_SESSION };

export const SAFE_MOCK_SESSION = Object.freeze({

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Actually i was getting some errors with this... thats why i moved this to fixtures so please revert this change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved the canonical session definition back to tests/fixtures/mock-session.ts and kept this mock re-exporting that shared fixture.

Comment thread tests/fixtures/mock-session.ts Outdated
},
expires: "2099-01-01T00:00:00.000Z",
});
export { SAFE_MOCK_SESSION } from "../../__mocks__/next-auth/index.js";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

and revert this as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Restored the frozen SAFE_MOCK_SESSION definition in the shared fixture as requested.

Comment thread __mocks__/auth.ts Outdated
* without any hardcoded production secrets, session keys, or private credentials.
*/
import { vi } from "vitest";
import { SAFE_MOCK_SESSION } from "./next-auth/index.js";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Import this from fixtures

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated __mocks__/auth.ts to import SAFE_MOCK_SESSION from the shared fixtures module.

Comment thread tests/audit-mock-credentials.test.ts Outdated
import NextAuth from "../__mocks__/next-auth";
import { SAFE_MOCK_SESSION } from "./fixtures/mock-session";
import NextAuth from "../__mocks__/next-auth/index.js";
import { SAFE_MOCK_SESSION } from "../__mocks__/next-auth/index.js";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Revert this as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Restored the original NextAuth mock and fixture imports in the audit test.

@GauravKarakoti

Copy link
Copy Markdown
Owner

Go through this review

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GauravKarakoti GauravKarakoti added bug Something isn't working good first issue Good for newcomers testing nsoc26 level2 labels Nov 16, 2026
@GauravKarakoti
GauravKarakoti merged commit 5c508be into GauravKarakoti:main Nov 16, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working good first issue Good for newcomers level2 nsoc26 testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(mocks): export SAFE_MOCK_SESSION in next-auth mock and standardize auth test fixtures

2 participants