-
-
Notifications
You must be signed in to change notification settings - Fork 826
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
improve code coverage of src/screens/EventManagement #3149
improve code coverage of src/screens/EventManagement #3149
Conversation
WalkthroughThis pull request focuses on refactoring the Changes
Assessment against linked issues
Possibly related PRs
Suggested Labels
Suggested Reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (2)
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 (3)
src/screens/EventManagement/EventManagement.tsx (2)
203-205
: Consider expanding accessibility attributes for the dropdown items.While the implementation correctly switches the tab, it might be beneficial to include ARIA labels or roles to enhance screen reader support. For example, adding
aria-label
orrole="menuitem"
can improve usability for assistive technologies.
270-272
: Remove or clarify commented-out default case.Since you already handle the default tab via
useState('dashboard')
, keeping these commented-out lines may cause confusion. Removing them or clarifying their purpose helps maintain a clean codebase.- // no use of default here as the default tab is the dashboard selected in useState - // default: - // return null;src/screens/EventManagement/EventManagement.spec.tsx (1)
57-66
: Use consistent mocking patterns.Great job mocking
useParams
. For future maintainability, consider collectively defining all mocks (e.g., foruseNavigate
,useParams
) in a single place or helper function. This helps streamline testing and ensures consistency across various tests.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/screens/EventManagement/EventManagement.spec.tsx
(1 hunks)src/screens/EventManagement/EventManagement.test.tsx
(0 hunks)src/screens/EventManagement/EventManagement.tsx
(2 hunks)
💤 Files with no reviewable changes (1)
- src/screens/EventManagement/EventManagement.test.tsx
🔇 Additional comments (3)
src/screens/EventManagement/EventManagement.spec.tsx (3)
1-19
: Enhance test coverage for edge cases.The setup code and mocking are comprehensive. However, consider adding tests to handle edge cases such as invalid orgId/eventId that only partially match the required parameters, or tests for partial localStorage states (e.g., missing
AdminFor
key). This can detect rare scenarios where user data might be inconsistent.Would you like me to propose additional test cases or scripts to verify coverage for these edge scenarios?
164-185
: Verify consistent handling of invalid tabs.Currently, the test sets the tab to
'invalid'
and expects the dashboard tab to show by default. Although this behavior is correct, consider explicitly handling an invalid tab in the component logic for clearer code flow, rather than silently showing the default.
223-250
: Validate UI feedback when switching tabs from the dropdown.These tests assert that the dropdown item gets the
'text-secondary'
class after being clicked. Confirm in manual testing or storybook that the user receives a clear, visible cue that the tab changed (e.g., updated content area or highlighting).
please fix the failing test cases |
@AVtheking when i'm running the failed test locally it is giving me more 20 % coverage |
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #3149 +/- ##
=====================================================
+ Coverage 16.54% 89.92% +73.38%
=====================================================
Files 308 329 +21
Lines 7810 8526 +716
Branches 1701 1913 +212
=====================================================
+ Hits 1292 7667 +6375
+ Misses 6429 627 -5802
- Partials 89 232 +143 ☔ View full report in Codecov by Sentry. |
@AVtheking can you please review the PR or let me know if anything i wanted to do ? |
@palisadoes fixed the failing tests |
Please fix the conflicting file |
@coderabbitai full review |
✅ Actions performedFull review triggered. |
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: 2
🧹 Nitpick comments (3)
src/screens/EventManagement/EventManagement.spec.tsx (3)
208-216
: Extract repeated tab options array to reduce duplication.The tab options array is duplicated. Consider extracting it to a constant at the top of the test file.
+const TAB_OPTIONS = [ + 'dashboard', + 'registrants', + 'attendance', + 'agendas', + 'actions', + 'volunteers', + 'statistics', +]; describe('Responsive Dropdown Tests', () => { // ... existing code ... it('renders dropdown with all options', async () => { // ... existing code ... - const tabOptions = [ - 'dashboard', - 'registrants', - 'attendance', - 'agendas', - 'actions', - 'volunteers', - 'statistics', - ]; - tabOptions.forEach((option) => { + TAB_OPTIONS.forEach((option) => { expect(screen.getByTestId(`${option}DropdownItem`)).toBeInTheDocument(); }); }); it('switches tabs through dropdown selection', async () => { // ... existing code ... - const tabOptions = [ - 'dashboard', - 'registrants', - 'attendance', - 'agendas', - 'actions', - 'volunteers', - 'statistics', - ]; - for (const option of tabOptions) { + for (const option of TAB_OPTIONS) { // ... existing code ... } }); });Also applies to: 231-239
196-221
: Add accessibility tests for the dropdown.Consider adding tests to verify that the dropdown is keyboard accessible and properly labeled for screen readers.
it('is keyboard accessible', async () => { renderEventManagement(); const toggle = screen.getByTestId('tabsDropdownToggle'); expect(toggle).toHaveAttribute('aria-expanded', 'false'); await act(async () => { toggle.focus(); userEvent.keyboard('{Enter}'); }); expect(toggle).toHaveAttribute('aria-expanded', 'true'); const firstItem = screen.getByTestId('dashboardDropdownItem'); expect(firstItem).toHaveFocus(); });
57-252
: Add tests for GraphQL error and loading states.Consider adding test cases to verify the component's behavior when:
- GraphQL operations fail
- Data is in a loading state
it('handles GraphQL errors gracefully', async () => { const errorLink = new StaticMockLink([ { ...MOCKS_WITH_TIME[0], error: new Error('GraphQL Error'), }, ]); render( <MockedProvider link={errorLink}> <EventManagement /> </MockedProvider> ); await waitFor(() => { expect(screen.getByText('Error loading event data')).toBeInTheDocument(); }); }); it('shows loading state', async () => { renderEventManagement(); expect(screen.getByTestId('loadingSpinner')).toBeInTheDocument(); await waitFor(() => { expect(screen.queryByTestId('loadingSpinner')).not.toBeInTheDocument(); }); });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/screens/EventManagement/EventManagement.spec.tsx
(1 hunks)src/screens/EventManagement/EventManagement.test.tsx
(0 hunks)src/screens/EventManagement/EventManagement.tsx
(2 hunks)
💤 Files with no reviewable changes (1)
- src/screens/EventManagement/EventManagement.test.tsx
🧰 Additional context used
📓 Learnings (1)
📓 Common learnings
Learnt from: bitbard3
PR: PalisadoesFoundation/talawa-admin#2588
File: src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx:145-155
Timestamp: 2024-12-02T04:20:11.745Z
Learning: In PRs focused solely on refactoring test cases from Jest to Vitest, avoid suggesting optimizations or changes outside the migration scope.
🔇 Additional comments (2)
src/screens/EventManagement/EventManagement.tsx (2)
203-205
: LGTM! Clean simplification of the onClick handler.The simplified onClick handler maintains the same functionality while improving code readability.
270-272
: LGTM! Well-documented removal of unnecessary default case.The default case removal is justified by the clear comment explaining that 'dashboard' is always the default tab selected in useState.
0c0b077
into
PalisadoesFoundation:develop-postgres
…ation#3149) * code coverage * jest global coverage decreased * global jest coverage * rename file problem solved * changes requested resolved
* prevented unnecessary page reload with complementary test * Update jest.config.js * Fixes #2986 - Multiple UI Updates (#3165) * UI fixes on organisation pages * Added TSDoc for Truncated Text * Added Debouncer * Update src/components/OrgListCard/OrgListCard.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Added code rabbit suggestions * Fixed test error --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * refactore src/screens/OrgList from jest to vitest (#3200) * Improved Code Coverage in src/components/Venues/VenueModal.tsx (#3203) * Improved Code Coverage in src/components/Venues/VenueModal.tsx * removed the ignore statements from VenueModal.tsx * Removed istanbul ignore lines. Code coverage remians 100% (#3207) * refactored src/screens/FundCampaignPledge from jest to vitest (#3208) * prettier formatting and disabled ts-specific rules for js in eslint (#3186) * Improve Code Coverage in src/screens/UserPortal/Settings/Settings.tsx (#3189) * Preventing Overflow of images in Advertisement and Venue Post modals (#3204) * improve code coverage of src/screens/EventManagement (#3149) * code coverage * jest global coverage decreased * global jest coverage * rename file problem solved * changes requested resolved * fix: update Chat section title to 'Chats' (#3216) * removed stale comment line * Revert "removed stale comment line" This reverts commit e0fa894. * removed stale comment line --------- Co-authored-by: Peter Harrison <16875803+palisadoes@users.noreply.github.com> Co-authored-by: Mehul Aggarwal <88583647+AceHunterr@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Syed Ali Ul Hasan <syedaliulhasan19@gmail.com> Co-authored-by: harshk-89 <133699216+harshk-89@users.noreply.github.com> Co-authored-by: Amaan ali <amaan.ali.ug22@nsut.ac.in> Co-authored-by: Yugal Sadhwani <yashsadhwani544@gmail.com> Co-authored-by: Pranav Nathe <93403830+pranavnathe@users.noreply.github.com> Co-authored-by: prathmesh703 <146568950+prathmesh703@users.noreply.github.com> Co-authored-by: Nivedita <141390434+Nivedita-Chhokar@users.noreply.github.com>
What kind of change does this PR introduce?
refactoring,code-coverage
Issue Number:
Fixes #3024 ,Fixes #2546
Did you add tests for your changes?
no
Snapshots/Videos:
Summary
refactor of src/screens/EventManagement test file from jest to vitest
added test cases are written for the file src/screens/EventManagement.tsx
Does this PR introduce a breaking change?
NO
Have you read the contributing guide?
Yes
Summary by CodeRabbit
Tests
Refactor