Patch minor update#1100
Conversation
|
Warning Review limit reached
More reviews will be available in 10 minutes and 47 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. 📝 WalkthroughWalkthroughThis PR introduces a new Axios-based API wrapper abstraction ( ChangesAPI Wrapper Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
09e87b4 to
c579cb6
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/api/__tests__/api.test.js (2)
53-82: ⚡ Quick winAdd test coverage for
put()anddelete()methods.The test suite covers
get()andpost()but omitsput()anddelete(). While these methods follow the same pattern, adding tests for them would ensure complete coverage and prevent future regressions.🧪 Suggested test cases
describe('API — put()', () => { test('returns response.data on success', async () => { const mockData = { id: 1, updated: true } axios.put.mockResolvedValue({ data: mockData }) const api = new API('/campaigns', 'v1') const result = await api.put('/123', { name: 'Updated' }) expect(result).toEqual(mockData) }) test('throws APIError on failure', async () => { axios.put.mockRejectedValue({ message: 'Update failed', response: { status: 400 } }) const api = new API('/campaigns', 'v1') await expect(api.put('/123', {})).rejects.toThrow(APIError) }) }) describe('API — delete()', () => { test('returns response.data on success', async () => { const mockData = { deleted: true } axios.delete.mockResolvedValue({ data: mockData }) const api = new API('/campaigns', 'v1') const result = await api.delete('/123') expect(result).toEqual(mockData) }) test('throws APIError on failure', async () => { axios.delete.mockRejectedValue({ message: 'Delete failed', response: { status: 403 } }) const api = new API('/campaigns', 'v1') await expect(api.delete('/123')).rejects.toThrow(APIError) }) })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/api/__tests__/api.test.js` around lines 53 - 82, Add unit tests mirroring the existing post() tests for the API.put and API.delete methods: add a describe block for "API — put()" that stubs axios.put with mockResolvedValue returning { data: ... } and asserts API.put returns response.data, and stubs axios.put with mockRejectedValue (including response.status) and asserts it rejects with APIError; do the same for "API — delete()" using axios.delete and API.delete, checking success returns response.data and failure rejects with APIError and carries the HTTP status. Reference the API class methods API.put and API.delete and the axios.put/axios.delete mocks and the APIError assertion to locate where to add the tests.
22-51: ⚡ Quick winConsider verifying axios call parameters.
The tests validate end-to-end behavior but don't assert that
axios.getwas called with the correct URL and parameters. Adding these assertions would strengthen the test suite.📝 Example enhancement
test('returns response.data on success', async () => { const mockData = { id: 1, name: 'test' } axios.get.mockResolvedValue({ data: mockData }) const api = new API('/campaigns') const result = await api.get() + + expect(axios.get).toHaveBeenCalledWith('/api/campaigns', { params: {} }) expect(result).toEqual(mockData) })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/api/__tests__/api.test.js` around lines 22 - 51, Update the tests for the API.get behavior to also assert that axios.get was invoked with the correct URL and options: after creating new API('/campaigns') and before resolving/rejecting expectations, add assertions that axios.get was called with the full endpoint (e.g., '/campaigns' or the base/path combination used by the API constructor) and any expected params/headers/options; reference the API class and its get() method and assert against axios.get mock calls (using toHaveBeenCalledWith / toHaveBeenCalledTimes) so the tests verify both the return/error behavior and the actual request arguments.docs/superpowers/specs/2026-06-03-api-wrapper-design.md (1)
85-91: 💤 Low valueAdd language identifier to fenced code block.
The fenced code block showing the file structure should specify a language identifier (e.g.,
text) to satisfy markdown linting rules.✨ Proposed fix
-``` +```text src/ api/ index.js ← new __tests__/ api.test.js ← new</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.In
@docs/superpowers/specs/2026-06-03-api-wrapper-design.mdaround lines 85 -
91, The fenced code block showing the file tree (containing entries src/, api/,
index.js, and tests/api.test.js) is missing a language identifier; update
that markdown block by adding a language specifier (e.g., change the openingtotext) so the snippet is lint-compliant while keeping the contents
unchanged.</details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.Nitpick comments:
In@docs/superpowers/specs/2026-06-03-api-wrapper-design.md:
- Around line 85-91: The fenced code block showing the file tree (containing
entries src/, api/, index.js, and tests/api.test.js) is missing a language
identifier; update that markdown block by adding a language specifier (e.g.,
change the openingtotext) so the snippet is lint-compliant while
keeping the contents unchanged.In
@src/api/__tests__/api.test.js:
- Around line 53-82: Add unit tests mirroring the existing post() tests for the
API.put and API.delete methods: add a describe block for "API — put()" that
stubs axios.put with mockResolvedValue returning { data: ... } and asserts
API.put returns response.data, and stubs axios.put with mockRejectedValue
(including response.status) and asserts it rejects with APIError; do the same
for "API — delete()" using axios.delete and API.delete, checking success returns
response.data and failure rejects with APIError and carries the HTTP status.
Reference the API class methods API.put and API.delete and the
axios.put/axios.delete mocks and the APIError assertion to locate where to add
the tests.- Around line 22-51: Update the tests for the API.get behavior to also assert
that axios.get was invoked with the correct URL and options: after creating new
API('/campaigns') and before resolving/rejecting expectations, add assertions
that axios.get was called with the full endpoint (e.g., '/campaigns' or the
base/path combination used by the API constructor) and any expected
params/headers/options; reference the API class and its get() method and assert
against axios.get mock calls (using toHaveBeenCalledWith /
toHaveBeenCalledTimes) so the tests verify both the return/error behavior and
the actual request arguments.</details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro **Run ID**: `05b52edf-6d05-4916-acf5-e9557dcd89e2` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between c186d012c813600bc7a86790bd8ab572bab7d99b and 09e87b43542d60a9a67255f74b45d195c5e42924. </details> <details> <summary>📒 Files selected for processing (7)</summary> * `.claude/settings.local.json` * `README.md` * `docs/superpowers/plans/2026-06-03-api-wrapper.md` * `docs/superpowers/specs/2026-06-03-api-wrapper-design.md` * `src/api/__tests__/api.test.js` * `src/api/index.js` * `src/router/index.js` </details> <details> <summary>💤 Files with no reviewable changes (1)</summary> * src/router/index.js </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Summary by CodeRabbit
New Features
Documentation
Tests
Chores