test(api/github): Enhance mock-integrations coverage for async service layer and cache - #8390
Conversation
|
This pull request enhances the testing framework by adding mock-integrations coverage for the async service layer and local cache, which is crucial for ensuring the reliability of these components. This approach aligns with previous decisions to improve test coverage for similar functionalities, such as the ControlsPanel and other routes. Thank you for your contribution, and I look forward to your updates! |
📦 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.
Solid mock integration tests for the github API route. The async service layer stubbing with getFullDashboardData mock is well done, and the timeout/hang simulation using fake timers demonstrates good edge case coverage. The beforeEach cleanup of quotaMonitor, refreshPolicy, refreshRateLimiter, and backgroundRefresh is thorough.
CI is pending — once green, this is ready to merge.
Labels: level:beginner (1 file, focused test coverage), quality:clean, type:testing, mentor:Aamod007
Aamod007
left a comment
There was a problem hiding this comment.
Re-reviewing after noting the only CI failure is Vercel authorization (not code-related). All other checks (Format · Lint · Typecheck · Test, Production Build, CodeQL) pass. Approving — the Vercel deploy auth is a repo-level config issue, not a code problem.
Fixes #2591
Description
Adds test coverage for asynchronous service layer mocking and local cache stubs, as requested in #2591.
The original ticket named
components/dashboard/RadarChart.tsxas the target file, but that component is a pure presentational component — it receives all its data via props and has no cache, service call, or async logic to test. After tracing whereRadarChartactually gets its data from, the real async service layer + local cache behavior (checking cache before fetching, timing out on a hung request, syncing the cache after a successful refresh) lives inapp/api/github/route.ts. This PR adds the requested test coverage there instead, since that's where the behavior actually exists.Tests added (
app/api/github/route.mock-integrations.test.tsx):bypassCache: falseby default)?refresh=true) bypasses the cacheAbortControllerand falls back with a504backgroundRefresh.triggerRefresh)Pillar
Visual Preview
N/A — this PR adds test coverage only, no UI/visual changes.
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).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.