-
-
Notifications
You must be signed in to change notification settings - Fork 867
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: jest to vitest of OrganizationActionItems : fixes #2557 #2773
refactor: jest to vitest of OrganizationActionItems : fixes #2557 #2773
Conversation
Not all the params were being mocked properly. As a result of not getting the expected response, useQuery was returning error in actionItemsError. This is fixed now
Migrated to vitest with functionalities
WalkthroughThe pull request involves modifications to the Changes
Assessment against linked issues
Possibly related issues
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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: 0
🧹 Nitpick comments (2)
src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts (1)
27-27
: Consider extractingeventId
into a shared constant.Repeatedly specifying
"eventId"
might introduce duplication. Additionally, if theeventId
is intended to vary, centralizing its management can ensure consistency for future updates or different testing scenarios.Also applies to: 51-51, 69-69, 87-87, 105-105, 124-124, 143-143, 161-161, 418-418, 486-486
src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx (1)
1-13
: Adopt@apollo/client/testing
if possible.Currently, we import
MockedProvider
from@apollo/react-testing
, which is deprecated in some versions of Apollo. Consider switching to@apollo/client/testing
if your Apollo version supports it, ensuring long-term compatibility and community support.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts
(10 hunks)src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx
(1 hunks)src/screens/OrganizationActionItems/OrganizationActionItems.test.tsx
(0 hunks)
💤 Files with no reviewable changes (1)
- src/screens/OrganizationActionItems/OrganizationActionItems.test.tsx
🧰 Additional context used
📓 Learnings (1)
src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx (1)
Learnt from: Chaitanya1672
PR: PalisadoesFoundation/talawa-admin#2049
File: src/screens/OrganizationActionItems/ActionItemUpdateModal.tsx:112-138
Timestamp: 2024-11-12T10:40:58.654Z
Learning: The `istanbul ignore next` comments in the `ActionItemUpdateModal.tsx` file were added as part of a commit that introduced tests for the `ActionItemUpdateModal` component. Removing these comments and writing tests to cover the previously ignored lines is recommended to ensure code integrity and improve test coverage.
🔇 Additional comments (19)
src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx (19)
22-27
: Mock logger usage looks good.
Mocking react-toastify
is a neat approach for controlling side effects in tests.
29-35
: Ensure consistent mocking of date pickers.
Using DesktopDateTimePicker
for the DateTimePicker
mock is fine. Verify that any date-time-specific formatting or handling in your tests aligns with this approach.
50-56
: Well-structured debounce helper.
The debounceWait
helper function is essential for controlling async behavior in UI tests. No issues found.
58-68
: Good setup for Vitest environment.
The creation of the test suite, plus beforeAll and afterAll hooks, matches good practice.
70-97
: URL parameter fallback handling.
The redirect logic upon missing route parameters appears correct. Great job covering edge cases.
99-128
: Comprehensive rendering test.
These lines ensure that the base elements (e.g., search bar) appear for the user, validating essential UI behavior.
130-174
: Sorting action items descending.
The test thoroughly checks sorting functionality by due date and includes relevant assertions. This helps ensure correctness of the UI state after user interactions.
176-220
: Sorting action items ascending.
Similarly, verifying ascending sort is important for completeness. Good coverage.
222-282
: Filtering by status (All/Pending).
These tests demonstrate robust coverage for the filter feature. Combining user interactions (click events) and async checks (waitFor) provides confidence in the final behavior.
284-327
: Filtering by status (Completed).
Continuing the filter coverage, ensuring separate test coverage for each status helps isolate potential bugs.
329-364
: Modal toggling: create action item.
The test verifies that modals appear and dismiss correctly, an important UI detail.
366-401
: Modal toggling: view action item.
Same approach as create. Checks are clear, ensuring consistent user experience for the view functionality.
403-438
: Modal toggling: edit action item.
Ensuring the update flow is tested prevents regressions in editing features.
440-475
: Modal toggling: delete action item.
Tests the deletion flow in a similar manner, maintaining UI consistency.
477-512
: Modal toggling: update status of action item.
Ensures that changing an item’s status triggers the expected UI.
514-558
: Search by assignee coverage.
Properly verifies the correctness of the search functionality. Good usage of debounceWait
.
560-604
: Search by category coverage.
Similarly, verifies the category search functionality. Reaffirms robust coverage of search flows.
606-633
: Empty action items scenario.
Confirming that an empty state is handled gracefully is vital for user experience.
635-661
: Error scenario coverage.
Testing error states ensures the UI displays appropriate feedback to the user.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #2773 +/- ##
=====================================================
+ Coverage 71.94% 87.27% +15.32%
=====================================================
Files 296 313 +17
Lines 7358 8204 +846
Branches 1606 1848 +242
=====================================================
+ Hits 5294 7160 +1866
+ Misses 1804 859 -945
+ Partials 260 185 -75 ☔ View full report in Codecov by Sentry. |
Hi @palisadoes . With this PR, the issue #2557 can be closed as all the test files inside that directory will be successfully migrated to vitest. It took total 5 PRs to close the issue. Thank you. |
8ec66ea
into
PalisadoesFoundation:develop-postgres
Hi @palisadoes . As all the issues are already assigned, I was looking for more test files that are not issued to be migrated to vitest. I have made a list which can be found here : https://bandhanmajumder.notion.site/All-test-issues-1666c9979ab38069bbbde2f2b61b8b7c |
What kind of change does this PR introduce?
Refactoring
Issue Number:
There are multiple test files in this directory. So it needs multiple PRs to close the issue. This PR fixes one such file inside that directory
OrganizationActionItems.spec.tsx
Fixes #2557
Snapshots/Videos:
Summary
Refactored the
OrganizationActionItems.tsx
tests from jest to vitest inOrganizationActionItems.spec.tsx
Have you read the contributing guide?
Yes
Summary by CodeRabbit
New Features
eventId
, in various GraphQL request scenarios for action items.Bug Fixes
Tests
OrganizationActionItems
component covering rendering, sorting, filtering, and modal interactions.OrganizationActionItems
component, impacting overall test coverage.