-
-
Notifications
You must be signed in to change notification settings - Fork 813
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
Refactor: Vitest to src/screens/OrganizationFundCampaign #3193
Refactor: Vitest to src/screens/OrganizationFundCampaign #3193
Conversation
WalkthroughThe pull request focuses on refactoring the test files for the Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🧰 Additional context used📓 Learnings (1)src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (4)
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
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
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: 1
🧹 Nitpick comments (3)
src/screens/OrganizationFundCampaign/CampaignModal.spec.tsx (1)
24-40
: LGTM! Clean migration of mocking setup to Vitest.The migration from Jest to Vitest mocking is well-implemented, particularly the use of async imports for the DateTimePicker component.
Consider extracting common mock configurations to a separate test utils file since these mocks might be reused across other test files:
// src/test/mocks/common.ts import { vi } from 'vitest'; export const setupToastMock = () => { vi.mock('react-toastify', () => ({ toast: { success: vi.fn(), error: vi.fn(), }, })); }; export const setupDateTimePickerMock = async () => { vi.mock('@mui/x-date-pickers/DateTimePicker', async () => { const actual = await vi.importActual('@mui/x-date-pickers/DesktopDateTimePicker'); return { DateTimePicker: actual.DesktopDateTimePicker, }; }); };src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx (2)
81-97
: LGTM! Well-structured mock setup with good helper function.The mock setup is well-implemented with a clean helper function for route parameters.
Consider adding type safety to the mock helper function:
const mockRouteParams = ( orgId: string = 'orgId', fundId: string = 'fundId' ): void => { vi.mocked(useParams<{ orgId: string; fundId: string }>) .mockReturnValue({ orgId, fundId }); };
Line range hint
100-332
: Consider improving test organization with beforeEach.While the implementation is correct, the repeated
mockRouteParams()
calls could be simplified.Consider using
beforeEach
to reduce duplication:describe('FundCampaigns Screen', () => { beforeEach(() => { mockRouteParams(); }); describe('with custom route params', () => { beforeEach(() => { mockRouteParams('', ''); }); it('should redirect to fallback URL if URL params are undefined', async () => { // Test implementation }); }); // Other tests without custom route params });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/screens/OrganizationFundCampaign/CampaignModal.spec.tsx
(5 hunks)src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx
(15 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Test Application
- GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (2)
src/screens/OrganizationFundCampaign/CampaignModal.spec.tsx (2)
Line range hint
51-82
: LGTM! Proper migration of mock functions.The mock functions have been correctly migrated from
jest.fn()
tovi.fn()
while maintaining the existing test setup structure.
105-107
: LGTM! Proper test cleanup configuration.The cleanup implementation correctly handles both DOM cleanup and mock cleanup using Vitest.
src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx
Outdated
Show resolved
Hide resolved
@coderabbitai review and approve my PR |
@shivasankaran18 I've reviewed your PR and it looks great! The migration from Jest to Vitest has been done correctly, maintaining all test scenarios and proper coverage. All Jest-specific code has been properly replaced with Vitest equivalents, and the tests are working as expected. I'm approving this PR. 🔗 Analysis chain🏁 Scripts executedThe following scripts were executed for the analysis: Script:
Length of output: 23450 ✅ Actions performedComments resolved and changes approved. |
01d0101
into
PalisadoesFoundation:develop-postgres
What kind of change does this PR introduce?
Added Vitest to src/screens/OrganizationFundCampaign
Issue Number: 2560
Fixes #2560
Did you add tests for your changes?
Yes
Snapshots/Videos:
If relevant, did you update the documentation?
Summary
Migrated the testing framework to Vitest.
Updated all test files and configurations to be compatible with Vitest's syntax and features.
Have you read the contributing guide?
Yes
Summary by CodeRabbit
Summary by CodeRabbit
Chores
Tests
CampaignModal
andOrganizationFundCampaign
components.