Skip to content

test(api/github): Enhance mock-integrations coverage for async service layer and cache - #8390

Open
Robo-Synaptic-Vaish wants to merge 2 commits into
JhaSourav07:mainfrom
Robo-Synaptic-Vaish:test/github-route-mock-integrations
Open

test(api/github): Enhance mock-integrations coverage for async service layer and cache#8390
Robo-Synaptic-Vaish wants to merge 2 commits into
JhaSourav07:mainfrom
Robo-Synaptic-Vaish:test/github-route-mock-integrations

Conversation

@Robo-Synaptic-Vaish

Copy link
Copy Markdown
Contributor

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.tsx as 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 where RadarChart actually 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 in app/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):

  • Cache is checked before a fresh service call is made (bypassCache: false by default)
  • An explicit refresh (?refresh=true) bypasses the cache
  • A hung request times out via AbortController and falls back with a 504
  • A repeated refresh within the cooldown window falls back to serving cache instead of bypassing again
  • A successful stale-cache read triggers exactly one background cache sync (backgroundRefresh.triggerRefresh)

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A — this PR adds test coverage only, no UI/visual changes.

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

@retenta-bot

retenta-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

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!

@retenta-bot retenta-bot Bot changed the title test(api/github): add mock-integrations covergae for cache/service/ti… test(api/github): Enhance mock-integrations coverage for async service layer and cache Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 4052.50 KB 4052.50 KB 0 B
Total CSS 338.94 KB 338.94 KB 0 B

@Aamod007 Aamod007 added level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. mentor:Aamod007 type:testing Adding, updating, or fixing tests labels Jul 27, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:testing Adding, updating, or fixing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(RadarChart-mock-integrations): verify Asynchronous Service Layer Mocking & Local Cache Stubs (Variation 9)

2 participants