-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: frontend mock endpoint to edit org codelist #14522
Conversation
Warning Rate limit exceeded@wrt95 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 11 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, 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 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. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis pull request introduces functionality for editing organization-level code lists across multiple frontend files. The changes include adding a new mutation function Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
frontend/packages/shared/src/hooks/mutations/useEditOrgCodeListMutation.ts (1)
11-11
: Simplify query invalidation.The
Promise.all
is unnecessary when invalidating a single query.- onSuccess: () => Promise.all([q.invalidateQueries({ queryKey: [QueryKey.OrgLevelCodeLists] })]), + onSuccess: () => q.invalidateQueries({ queryKey: [QueryKey.OrgLevelCodeLists] }),frontend/packages/shared/src/hooks/mutations/useEditOrgCodeListMutation.test.ts (1)
20-46
: Enhance test coverage with error and loading states.The tests cover the happy path well, but consider adding:
- Error case testing
- Loading state verification
describe('useEditOrgCodeListMutation', () => { + it('Shows loading state during mutation', async () => { + const result = renderHookWithProviders()(() => useEditOrgCodeListMutation()).renderHookResult.result; + result.current.mutate(codeListToEdit); + expect(result.current.isLoading).toBe(true); + await waitFor(() => expect(result.current.isSuccess).toBe(true)); + }); + + it('Handles error states correctly', async () => { + const error = new Error('Failed to edit code list'); + jest.spyOn(queriesMock, 'editOrgLevelCodeList').mockRejectedValueOnce(error); + const result = renderHookWithProviders()(() => useEditOrgCodeListMutation()).renderHookResult.result; + result.current.mutate(codeListToEdit); + await waitFor(() => expect(result.current.isError).toBe(true)); + expect(result.current.error).toBe(error); + });frontend/packages/shared/src/api/mutations.ts (2)
172-172
: Track the TODO comment.The TODO comment about replacing mocks should be tracked in your issue system.
Would you like me to create an issue to track the implementation of the actual API endpoints?
173-179
: Remove console.log before production.The console.log statement should be removed as it's only useful for development.
export const editOrgLevelCodeList = async (codeListItem: OptionListsResponse): Promise<void> => new Promise((resolve) => { setTimeout(() => { - console.log('Code list edited:', codeListItem); resolve(); }, 1000); });
frontend/packages/shared/src/mocks/queriesMock.ts (1)
206-206
: Consider adding type information to the mock implementation.The mock implementation looks good and follows the established pattern. However, consider adding type information to make it more type-safe:
- editOrgLevelCodeList: jest.fn().mockImplementation(() => Promise.resolve()), + editOrgLevelCodeList: jest.fn().mockImplementation(() => Promise.resolve<void>()),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
frontend/packages/shared/src/api/mutations.ts
(2 hunks)frontend/packages/shared/src/hooks/mutations/useEditOrgCodeListMutation.test.ts
(1 hunks)frontend/packages/shared/src/hooks/mutations/useEditOrgCodeListMutation.ts
(1 hunks)frontend/packages/shared/src/mocks/queriesMock.ts
(1 hunks)frontend/packages/shared/src/types/QueryKey.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build environment and run e2e test
- GitHub Check: Testing
🔇 Additional comments (1)
frontend/packages/shared/src/types/QueryKey.ts (1)
52-52
: LGTM!The new enum value follows the existing naming pattern and maintains alphabetical order.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #14522 +/- ##
=======================================
Coverage 95.70% 95.70%
=======================================
Files 1901 1902 +1
Lines 24739 24749 +10
Branches 2833 2833
=======================================
+ Hits 23676 23686 +10
Misses 802 802
Partials 261 261 ☔ View full report in Codecov by Sentry. |
Closing this as it has become fixed during today's workshop. |
Description
Related Issue(s)
Verification
Summary by CodeRabbit
Release Notes
New Features
Improvements
Testing