-
-
Notifications
You must be signed in to change notification settings - Fork 845
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
Fixes #2670 : Refactored src/screen/PageNotFound component test from jest to vitest #2708
Fixes #2670 : Refactored src/screen/PageNotFound component test from jest to vitest #2708
Conversation
WalkthroughThe pull request involves migrating the test suite for the Changes
Possibly related issues
Possibly related PRs
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: 1
🧹 Nitpick comments (2)
src/screens/PageNotFound/PageNotFound.spec.tsx (2)
Line range hint
15-15
: Improve test structure and prevent state leakageA few suggestions to enhance the test suite:
- Remove or uncomment the commented code
- Add cleanup between tests to prevent localStorage state leakage
- Use more descriptive test names
+ import { describe, it, expect, afterEach } from 'vitest'; + afterEach(() => { + setItem('AdminFor', undefined); + }); - test('Component should be rendered properly for User', () => { + it('displays user-specific content when no admin privileges are set', () => { - test('Component should be rendered properly for ADMIN or SUPERADMIN', () => { + it('displays admin content when user has admin privileges', () => {Also applies to: 37-37
Line range hint
28-33
: Enhance test assertions and maintainabilityConsider these improvements to make the tests more robust and maintainable:
- Add snapshot testing for UI verification
- Extract test data to fixtures
- Group related assertions
+ import { describe, it, expect, afterEach } from 'vitest'; + const ADMIN_FIXTURE = { + _id: '6537904485008f171cf29924', + __typename: 'Organization', + }; it('displays user-specific content when no admin privileges are set', () => { render( <BrowserRouter> <Provider store={store}> <I18nextProvider i18n={i18nForTest}> <PageNotFound /> </I18nextProvider> </Provider> </BrowserRouter>, ); + // Verify the rendered component matches snapshot + expect(screen.container).toMatchSnapshot(); + // Verify all required text elements are present + const expectedTexts = [ + 'Talawa User', + '404', + 'Oops! The Page you requested was not found!', + 'Back to Home' + ]; + expectedTexts.forEach(text => + expect(screen.getByText(text)).toBeInTheDocument() + );Also applies to: 52-57
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #2708 +/- ##
====================================================
+ Coverage 82.81% 86.35% +3.53%
====================================================
Files 295 312 +17
Lines 7274 8134 +860
Branches 1592 1785 +193
====================================================
+ Hits 6024 7024 +1000
+ Misses 1012 933 -79
+ Partials 238 177 -61 ☔ View full report in Codecov by Sentry. |
Please make sure coderabbit.ai approves your changes |
a295db3
into
PalisadoesFoundation:develop-postgres
What kind of change does this PR introduce?
Refactoring
This PR also fixes last #2669 PR which shows 2 file change but only 1 file changed (src/screen/PageNotFound.test.tsx)
Issue Number:
#2568
Fixes #
Snapshots/Videos:
Summary
Does this PR introduce a breaking change?
No
Other information
Have you read the contributing guide?
Yes
Summary by CodeRabbit
PageNotFound
component to utilize the Vitest framework.