Fix next-auth mock configuration in API route tests #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Why
Fixes #3
Fixes #4
Orders and analytics API route tests were failing due to incorrect next-auth mock setup. 112 tests blocked feature development.
What
Orders API Tests (95 tests)
defaultexport to next-auth mocks across 4 route test filesvi.mock('next-auth', () => ({ default: vi.fn(), getServerSession: vi.fn() }))undefinedvsnullfor absent storeId)Analytics API Tests (17 tests)
AnalyticsService→analyticsServiceSessionDatainterface (flat structure vs nesteduserobject)expect.any(Date)insightsobject) and products limit (caps at 50, doesn't reject)Type of Change
Checklist
Code Quality
npm run format)npm run lint)npm run type-check)anytypes used (except for documented third-party library interfaces)Testing
npm run test)Build & Deployment
npm run build)Additional Context
Test Results:
Pattern Source:
Mock configuration follows established pattern in
tests/unit/lib/security-headers.test.tsReviewer Notes
Changes are test-only with no implementation modifications. All fixes follow existing patterns and correct mismatches between test expectations and actual implementation behavior.
By submitting this pull request, I confirm that:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.