test(pr-insights): Enhance mock-integrations tests for async service layer and local cache stubs#8094
Conversation
…r and local cache stubs
|
This PR adds important test coverage for the asynchronous service layer and local cache stubs in the PR insights route. It follows a similar approach to previous decisions made regarding mock integrations, such as the tests added for types and wrapped API routes. This ensures that our testing strategy remains consistent and effective. Thank you for your contribution! |
|
Hi maintainers 👋 The failing TypeScript Type Check job is caused by pre-existing errors on Running None of these files are touched by this PR. My changes are limited to a single new test file: Verification that my change is clean:
Could you please advise whether:
Happy to help fix the type errors on |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Aamod007
left a comment
There was a problem hiding this comment.
Excellent work on the mock integrations test for PR insights. Testing the async service layer boundaries and local cache fallback behaviors adds great stability. However, the Vercel check is failing. Please resolve the issues and rerun the CI pipeline.
|
Hi @Aamod007, thanks for the review! I checked the Checks tab and I don't see a Vercel check listed among the 9 checks that ran — all visible checks are passing. Could you share a screenshot or link to the failing Vercel check so I can investigate? It's possible the Vercel bot isn't running on PRs from forks. Thanks! |
Aamod007
left a comment
There was a problem hiding this comment.
Upon re-evaluation, I realized I previously misinterpreted the Vercel deployment failure as an issue with this PR. The Vercel build failure seems unrelated to the changes introduced here, so I will ignore it moving forward. The rest of the PR looks good, so I'm approving it!
|
🎉 Congratulations @soumyasekharshee265-ux! Your PR has been successfully merged. 🚀 Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.
Keep building! 💻✨ |
Description
Fixes #6781
This PR adds the new test file
app/api/pr-insights/route.mock-integrations.test.tstargeting Asynchronous Service Layer Mocking & Local Cache Stubs for theapp/api/pr-insights/route.tsroute (Variation 9).The tests use
vi.mock()to stub every async boundary the route depends on — the PR insights service, the local GitHub token cache, the client IP resolver, and the abort-error type guard — so the suite stays hermetic, deterministic, and offline.What is covered (5 test cases)
fetchPRInsightsservice is invoked once with the trimmed username and returns the mocked payload with a 200 status.getUserGitHubToken(local cache layer) executes beforefetchPRInsights(remote fetch) and that the cached token is forwarded to the downstream call.AbortControllerfiring and confirms the route returns a504with the correct timeout message.500with the underlying error message.Verification
npm run test -- app/api/pr-insights/route.mock-integrations.test.ts→ 5/5 passing ✅npm run format→ clean ✅npm run lint→ 0 errors in the new file ✅Pillar
Visual Preview
Not applicable — this PR adds unit tests only and does not touch any SVG output or UI.
Checklist before requesting a review:
CONTRIBUTING.mdfile.npm run test -- app/api/pr-insights/route.mock-integrations.test.ts— all 5 tests pass).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter. (N/A — no new theme or URL parameter added)