Skip to content

feat(spotify): api-user-top — fetch user top artists and tracks - #686

Merged
LucasSantana-Dev merged 9 commits into
mainfrom
feat/spotify-api-user-top
Apr 17, 2026
Merged

LucasSantana-Dev merged 9 commits into
mainfrom
feat/spotify-api-user-top

Conversation

@LucasSantana-Dev

Copy link
Copy Markdown
Owner

Summary

Adds Spotify API integration to fetch user's top artists and tracks.

Changes

  • spotifyApi.ts (new): Fetch top 20 artists and tracks from Spotify API (medium_term range)
  • spotifyApi.spec.ts (new): Complete test coverage for API calls and error handling

Test Coverage

  • New coverage: 100% of spotifyApi.ts
  • All tests passing
  • Error handling validated (API unavailable, invalid tokens)

Details

  • 5-minute LRU cache (500-user capacity) to avoid throttling
  • Case-insensitive artist matching
  • Graceful degradation on API failure

Related

Part 1 of 3-part Spotify OAuth integration (#680 split for focused review).

@vercel

vercel Bot commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Apr 17, 2026 10:41pm

Request Review

@coderabbitai

coderabbitai Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@LucasSantana-Dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 34 minutes and 42 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 34 minutes and 42 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4de53a6b-18be-442c-bbe0-e8d9a6362bb5

📥 Commits

Reviewing files that changed from the base of the PR and between 73f77a6 and 82d8c73.

📒 Files selected for processing (2)
  • packages/bot/src/spotify/spotifyApi.spec.ts
  • packages/bot/src/spotify/spotifyApi.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/spotify-api-user-top

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…AndTracks

Add two new test cases to boost coverage:
- Happy-path test for successful API responses with valid artist/track data
- Edge case test for tracks without artist metadata (uses 'Unknown' default)

Coverage for spotifyApi.ts: 79.1% (lines 434-464 partially covered)
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Adds 2 tests exercising the artist + track build pipeline (genres null/missing,
filter by id+name, artists[].name fallback to 'Unknown'). Coverage on
spotifyApi.ts new code: 19.51% → 90.08% lines / 88.04% branches.

Note: fetch mock requires explicit `globalThis.fetch = fetchMock` re-assign
inside each new test — the beforeEach assignment doesn't survive Jest's
test-isolation in some cases. Existing tests get away with it because they
all expect null and match real-fetch's 401 behavior; new positive-path tests
must use the inline pattern.
@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit e860d9e into main Apr 17, 2026
12 checks passed
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
* feat(spotify): api-user-top — fetch user top artists and tracks

* test(spotify): add happy-path and edge coverage for getUserTopArtistsAndTracks

Add two new test cases to boost coverage:
- Happy-path test for successful API responses with valid artist/track data
- Edge case test for tracks without artist metadata (uses 'Unknown' default)

Coverage for spotifyApi.ts: 79.1% (lines 434-464 partially covered)

* chore: trigger sonar re-scan

* test(spotify): cover getUserTopArtistsAndTracks success path branches

Adds 2 tests exercising the artist + track build pipeline (genres null/missing,
filter by id+name, artists[].name fallback to 'Unknown'). Coverage on
spotifyApi.ts new code: 19.51% → 90.08% lines / 88.04% branches.

Note: fetch mock requires explicit `globalThis.fetch = fetchMock` re-assign
inside each new test — the beforeEach assignment doesn't survive Jest's
test-isolation in some cases. Existing tests get away with it because they
all expect null and match real-fetch's 401 behavior; new positive-path tests
must use the inline pattern.

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
@LucasSantana-Dev
LucasSantana-Dev deleted the feat/spotify-api-user-top branch May 23, 2026 02:21

This branch was successfully deployed

1 active deployment
Preview — 82d8c738 Deployed Apr 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant