-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
Merging develop-postgres branch into develop #2677
Merging develop-postgres branch into develop #2677
Conversation
Signed-off-by: NishantSinghhhhh <[email protected]>
Signed-off-by: NishantSinghhhhh <[email protected]>
Signed-off-by: NishantSinghhhhh <[email protected]>
Signed-off-by: NishantSinghhhhh <[email protected]>
Signed-off-by: NishantSinghhhhh <[email protected]>
WalkthroughThis pull request represents a comprehensive update to the Talawa Admin project, focusing on migrating test suites from Jest to Vitest, updating styling frameworks, refactoring error handling, and enhancing localization. The changes span multiple files across the project, introducing more consistent testing approaches, improving type safety, and standardizing error messages and UI components. Changes
Sequence DiagramsequenceDiagram
participant User
participant Application
participant ErrorHandler
participant LocalizationService
User->>Application: Performs action
Application->>ErrorHandler: Trigger error handling
ErrorHandler->>LocalizationService: Request localized error message
LocalizationService-->>ErrorHandler: Return specific error message
ErrorHandler->>User: Display localized error message
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2677 +/- ##
============================================
- Coverage 95.82% 85.08% -10.74%
============================================
Files 295 312 +17
Lines 7037 8132 +1095
Branches 1520 1841 +321
============================================
+ Hits 6743 6919 +176
- Misses 98 1056 +958
+ Partials 196 157 -39 ☔ View full report in Codecov by Sentry. |
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: 14
🔭 Outside diff range comments (4)
src/screens/LoginPage/LoginPage.tsx (2)
Line range hint
208-211
: Enhance name validation for international supportThe current name validation regex is too restrictive and doesn't handle:
- International names with special characters
- Names with apostrophes (e.g., O'Connor)
- Names with multiple hyphens or spaces
Consider using this improved regex:
-const isValidName = (value: string): boolean => { - return /^[a-zA-Z]+(?:[-\s][a-zA-Z]+)*$/.test(value.trim()); -}; +const isValidName = (value: string): boolean => { + return /^[a-zA-ZÀ-ÿ]+(?:[''-\s][a-zA-ZÀ-ÿ]+)*$/.test(value.trim()) && value.trim().length >= 2; +};
Line range hint
306-316
: Security: Enhance token and user data storageStoring sensitive information in localStorage poses security risks:
- Tokens in localStorage are vulnerable to XSS attacks
- User details are stored in plain text
Consider these security improvements:
- Store tokens in httpOnly cookies
- Minimize stored user data
- Encrypt sensitive data before storage
-setItem('token', login.accessToken); -setItem('refreshToken', login.refreshToken); -setItem('email', user.email); +// Use httpOnly cookies for tokens (requires backend changes) +document.cookie = `token=${login.accessToken}; httpOnly; secure; sameSite=strict`; +document.cookie = `refreshToken=${login.refreshToken}; httpOnly; secure; sameSite=strict`; +// Store minimal user data +setItem('userInfo', btoa(JSON.stringify({ name: `${user.firstName} ${user.lastName}` })));src/screens/Requests/Requests.spec.tsx (1)
Line range hint
69-76
: Consider using a testing library utility instead of custom wait functionThe custom
wait
function could be replaced withwaitFor
from@testing-library/react
which handles act warnings automatically.-async function wait(ms = 100): Promise<void> { - await act(() => { - return new Promise((resolve) => { - setTimeout(resolve, ms); - }); - }); -} +import { waitFor } from '@testing-library/react'; + +// Usage in tests +await waitFor(() => { + // your assertions here +}, { timeout: 100 });src/components/Advertisements/Advertisements.test.tsx (1)
Based on the search results, I can now generate the final response as we have found evidence of established patterns for organizing test data in separate mock files within the codebase.
Consider moving test mocks to a separate file following established patterns
The codebase already follows a pattern of organizing test mocks in separate files (e.g.,
OrganizationActionItem.mocks.ts
). Consider extracting the advertisement-related mocks intosrc/components/Advertisements/Advertisement.mocks.ts
following the existing pattern of exporting named mock constants. This will improve maintainability and align with the project's conventions.
- Move
ADVERTISEMENTS_LIST_MOCK
,PLUGIN_GET_MOCK
,ADD_ADVERTISEMENT_MUTATION_MOCK
, andORGANIZATIONS_LIST_MOCK
to a new file:src/components/Advertisements/Advertisement.mocks.ts
🔗 Analysis chain
Line range hint
1-654
: Consider refactoring test data setup.The mock data is repeated multiple times in the test file. Consider extracting it to a separate test fixtures file to improve maintainability and reduce duplication.
Let me run another script to check the existing patterns of test data organization in the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check for existing test fixtures pattern in the codebase rg -g '*.{ts,tsx}' -l 'fixtures|mocks|test-utils' src/Length of output: 3533
Script:
#!/bin/bash # Check for existing patterns of test data organization rg -g '*.{ts,tsx}' -A 5 "const.*MOCK.*=" src/screens/OrganizationActionItems/OrganizationActionItem.mocks.tsLength of output: 503
🧹 Nitpick comments (32)
src/screens/OrganizationDashboard/OrganizationDashboard.tsx (2)
34-34
: LGTM! Component naming and style organization improvements.The changes follow React best practices:
- Component name now follows PascalCase convention
- Styles are now centralized in a global stylesheet
Consider documenting the style organization approach in the project's README or style guide to maintain consistency across the codebase.
Also applies to: 44-44
Line range hint
144-152
: Consider enhancing error handling with specific error messages.The current error handling combines all errors into a single generic message. Consider providing more specific error messages based on the type of error (organization data, posts, events, or rankings).
useEffect(() => { if (errorOrg || errorPost || errorEvent || errorRankings) { - toast.error(tErrors('errorLoading', { entity: '' })); + if (errorOrg) { + toast.error(tErrors('errorLoading', { entity: tCommon('organization') })); + } + if (errorPost) { + toast.error(tErrors('errorLoading', { entity: t('posts') })); + } + if (errorEvent) { + toast.error(tErrors('errorLoading', { entity: t('events') })); + } + if (errorRankings) { + toast.error(tErrors('errorLoading', { entity: t('volunteerRankings') })); + } navigate('/'); } }, [errorOrg, errorPost, errorEvent, errorRankings]);public/locales/en/errors.json (1)
10-15
: LGTM with minor suggestions for consistencyThe new error messages are clear and follow a good pattern. Consider these minor improvements for consistency:
- Line 10: Add "Please" to match the style of other messages: "Please try again while loading {{entity}} data"
- Line 15: Consider matching the validation message style: "Please check your inputs and try again."
src/utils/errorHandler.test.tsx (2)
14-22
: Consider removing console.log from test utilityThe console.log in tErrors function isn't necessary for testing and might pollute test output.
- if (options) { - console.log(`options are passed, but the function returns only ${key}`); - }
58-64
: Enhance case sensitivity testingWhile the current tests cover some case variations, consider adding more edge cases:
- Mixed case variations
- Leading/trailing spaces
- Special characters
test.each([ ['value IS not A Valid PHONE number', 'invalidPhoneNumber'], [' Value Is Not A Valid Phone Number ', 'invalidPhoneNumber'], ['This Value Does Not Exist in "Education-Grade"', 'invalidEducationGrade'], ])('should handle various case and format variations: %s', (input, expected) => { errorHandler(t, new Error(input)); expect(toast.error).toHaveBeenCalledWith(tErrors(expected)); });src/screens/LoginPage/LoginPage.tsx (2)
Line range hint
290-294
: Enhance error handling with specific error typesThe current error handling could be more informative for users and easier to debug.
Consider adding specific error handling:
try { const { data: loginData } = await login({ variables: { email: formState.email, password: formState.password, }, }); } catch (error) { - errorHandler(t, error); + if (error.networkError) { + toast.error(t('networkError')); + console.error('Network error:', error); + } else if (error.graphQLErrors) { + const errorMessage = error.graphQLErrors[0]?.message; + toast.error(t(errorMessage) || t('unknownError')); + console.error('GraphQL error:', error.graphQLErrors); + } else { + errorHandler(t, error); + } }
Line range hint
571-584
: Improve accessibility for password validation feedbackThe password validation UI needs proper ARIA attributes for screen readers.
Add ARIA attributes to improve accessibility:
<div className={styles.password_checks}> {isInputFocused ? ( signformState.signPassword.length < 6 ? ( <div data-testid="passwordCheck"> <p className={`form-text text-danger ${styles.password_check_element_top}`} + role="alert" + aria-live="polite" > <span> <Clear className="" /> + <span className="visually-hidden">Error:</span> </span> {t('atleast_6_char_long')} </p> </div>src/components/AddOn/core/AddOnStore/AddOnStore.tsx (1)
13-24
: Consider renaming the interface and consolidating propertiesThe interface
InterfacePluginHelper
may not adhere to the project's naming conventions. In TypeScript, it's common to prefix interface names with anI
(e.g.,IPluginHelper
) or to use descriptive names without redundant prefixes (e.g.,PluginHelper
). Renaming the interface can enhance code readability.Additionally, the properties
pluginName?
andname
might be redundant or could cause confusion. Consider consolidating these properties if they represent the same data or clarifying their distinct purposes.src/components/AddOn/core/AddOnEntry/AddOnEntry.module.css (1)
13-14
: Use theme variables for colors to maintain consistencyThe use of hardcoded color values like
green
in the.card
class may lead to inconsistencies across the application's styling. Consider using predefined theme variables or CSS custom properties to ensure consistency and ease of maintenance.For example:
.card { border: 4px solid var(--primary-border-color); }src/components/Advertisements/Advertisements.module.css (2)
21-25
: Avoid fixed widths to ensure responsive designUsing a fixed width of
560px
in the.input
class can negatively impact responsiveness on different screen sizes. Consider using relative units (e.g., percentages) or responsive CSS techniques to adapt to various screen widths.Example adjustment:
.input { display: flex; position: relative; max-width: 100%; width: 100%; }
33-33
: Remove commented-out code to improve code cleanlinessThe commented-out
margin-bottom: 50px;
line in the.actioninput
class can be removed if it's no longer required. This helps maintain a clean and readable codebase..actioninput { text-decoration: none; - /* margin-bottom: 50px; */ border-color: #e8e5e5; background-color: white; border-radius: 7px; padding-top: 10px; padding-bottom: 10px; padding-right: 10px; padding-left: 10px; box-shadow: none; }
src/components/AddOn/support/components/Action/Action.spec.tsx (1)
15-31
: Consider enhancing test coverage with additional test cases.While the basic rendering test is good, consider adding tests for:
- Component interaction (clicks, hovers)
- Different prop combinations
- Error states
- Edge cases
Example test cases:
test('should handle click events', () => { const handleClick = vi.fn(); const { getByText } = render( <Provider store={store}> <Action {...props} onClick={handleClick} /> </Provider> ); fireEvent.click(getByText(props.label)); expect(handleClick).toHaveBeenCalled(); }); test('should handle empty props', () => { const { container } = render( <Provider store={store}> <Action label="" children={null} /> </Provider> ); expect(container).toBeInTheDocument(); });src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.module.css (1)
31-33
: Consider using responsive width for better mobile support.The fixed width of 28rem might not be optimal for mobile devices. Consider using relative units or media queries.
.card { - width: 28rem; + width: min(28rem, 100%); + max-width: 100%; }src/components/AddOn/core/AddOnStore/AddOnStore.module.css (2)
14-18
: Consider using relative units for widthThe fixed width of 560px in
.input
class may cause overflow issues on smaller screens. Consider using relative units (%, vw) or max-width for better responsiveness..input { display: flex; position: relative; - width: 560px; + width: 100%; + max-width: 560px; }
Line range hint
19-30
: Remove commented codeRemove the commented-out
.actioninput
implementation as it's no longer needed and adds unnecessary noise to the codebase. Version control history can be used to retrieve old implementations if needed.src/components/AddOn/support/services/Plugin.helper.test.ts (1)
Line range hint
7-8
: Remove duplicate property checkThe
generateLinks
property is being checked twice in the test assertions.expect(pluginHelper).toHaveProperty('fetchStore'); expect(pluginHelper).toHaveProperty('fetchInstalled'); expect(pluginHelper).toHaveProperty('generateLinks'); - expect(pluginHelper).toHaveProperty('generateLinks');
src/components/Avatar/Avatar.spec.tsx (1)
45-92
: Consider adding edge cases and error scenariosWhile the current test cases cover the happy path well, consider adding tests for:
- Edge cases:
- Null/undefined name
- Empty string name
- Very long names
- Error scenarios:
- Invalid size values
- Missing required props
Example test cases to add:
test('handles null/undefined name gracefully', () => { const { getByAltText } = render( <Avatar name={undefined} alt="Test Alt" size={64} /> ); const avatarElement = getByAltText("Test Alt"); expect(avatarElement).toBeInTheDocument(); }); test('handles empty string name', () => { const { getByAltText } = render( <Avatar name="" alt="Test Alt" size={64} /> ); const avatarElement = getByAltText("Test Alt"); expect(avatarElement).toBeInTheDocument(); }); test('handles invalid size prop', () => { const { getByAltText } = render( <Avatar name="Test" alt="Test Alt" size={-1} /> ); const avatarElement = getByAltText("Test Alt"); expect(avatarElement).toBeInTheDocument(); // Verify fallback to default size expect(avatarElement).toHaveStyle({ width: '40px', height: '40px' }); });src/components/AddOn/core/AddOnEntry/AddOnEntry.tsx (1)
62-62
: Remove debug console.log statementDebug console.log statement should be removed before merging.
- // console.log(currentOrg);
src/screens/UserPortal/UserScreen/UserScreen.spec.tsx (1)
Line range hint
133-162
: Consider enhancing toggle test robustness.The toggle functionality test could be more comprehensive by:
- Verifying the drawer's visibility state
- Testing keyboard interactions
- Adding assertions for accessibility attributes
it('toggles LeftDrawer correctly based on window size and user interaction', () => { render( <MockedProvider addTypename={false} link={link}> <BrowserRouter> <Provider store={store}> <I18nextProvider i18n={i18nForTest}> <UserScreen /> </I18nextProvider> </Provider> </BrowserRouter> </MockedProvider>, ); const toggleButton = screen.getByTestId('closeMenu') as HTMLElement; const icon = toggleButton.querySelector('i'); + const drawer = screen.getByTestId('leftDrawer'); + + // Test initial state + expect(drawer).toBeVisible(); + expect(toggleButton).toHaveAttribute('aria-expanded', 'true'); // Resize to small screen and check toggle state resizeWindow(800); clickToggleMenuBtn(toggleButton); expect(icon).toHaveClass('fa fa-angle-double-left'); + expect(drawer).not.toBeVisible(); + expect(toggleButton).toHaveAttribute('aria-expanded', 'false'); // Test keyboard interaction + fireEvent.keyDown(toggleButton, { key: 'Enter' }); + expect(drawer).toBeVisible(); + expect(toggleButton).toHaveAttribute('aria-expanded', 'true'); });src/screens/EventVolunteers/Requests/Requests.spec.tsx (1)
Line range hint
39-46
: Consider moving debounceWait to shared test utilities.The
debounceWait
utility function could be useful in other test files. Consider moving it to a shared test utilities file.-const debounceWait = async (ms = 300): Promise<void> => { - await act(() => { - return new Promise((resolve) => { - setTimeout(resolve, ms); - }); - }); -};Create a new file
src/utils/testUtils.ts
:import { act } from 'react-dom/test-utils'; export const debounceWait = async (ms = 300): Promise<void> => { await act(() => { return new Promise((resolve) => { setTimeout(resolve, ms); }); }); };src/components/AddOn/core/AddOnEntry/AddOnEntry.spec.tsx (1)
147-190
: Enhance test coverage for button interactionsThe button click test could be more specific and include negative test cases:
- Test error handling when the install/uninstall operation fails
- Verify button state during loading
- Test for disabled state conditions
test('Button handles error states correctly', async () => { // Mock failed operation const errorLink = new StaticMockLink([{ request: { /* your request */ }, error: new Error('Failed to install') }]); // Render with error link // Verify error message // Verify button returns to previous state });src/components/AddOn/core/AddOnStore/AddOnStore.test.tsx (1)
67-78
: Improve mock implementation type safetyThe
generateLinks
mock implementation could be more type-safe:
- Use type assertion for the mock return type
- Add error handling for invalid plugin data
generateLinks: jest .fn() .mockImplementation((plugins: InterfacePlugin[]) => { + if (!Array.isArray(plugins)) { + throw new Error('Expected plugins to be an array'); + } return plugins .filter((plugin) => plugin.enabled) .map((installedPlugin) => { + if (!installedPlugin.pluginName || !installedPlugin.component) { + throw new Error('Invalid plugin data'); + } return { name: installedPlugin.pluginName, url: `/plugin/${installedPlugin.component.toLowerCase()}`, }; - }); + }) as Array<{ name: string; url: string }>; }),src/screens/Requests/Requests.spec.tsx (1)
29-34
: Move localStorage mock to a test utils fileConsider moving the localStorage mock to a shared test utils file to maintain consistency across test files and reduce duplication.
// src/utils/test/mockLocalStorage.ts export const mockLocalStorage = { getItem: vi.fn(), setItem: vi.fn(), clear: vi.fn(), removeItem: vi.fn(), }; // Usage in test files import { mockLocalStorage } from 'utils/test/mockLocalStorage'; vi.stubGlobal('localStorage', mockLocalStorage);src/screens/UserPortal/Donate/Donate.spec.tsx (1)
146-150
: Toast mock implementation could be improvedWhile the mock implementation works, it could be more robust by including all commonly used toast methods.
Consider expanding the mock to include other commonly used methods:
vi.mock('react-toastify', () => ({ toast: { error: vi.fn(), success: vi.fn(), + info: vi.fn(), + warning: vi.fn(), }, }));src/components/EventCalendar/YearlyEventCalender.tsx (1)
Line range hint
32-32
: Consider using ISO date strings for consistencyThe type definition for dates should explicitly use ISO date strings for better type safety and consistency.
- endDate: string; - startDate: string; + endDate: `${number}-${number}-${number}T${number}:${number}:${number}.${number}Z`; + startDate: `${number}-${number}-${number}T${number}:${number}:${number}.${number}Z`;Also applies to: 33-33
.github/workflows/pull-request.yml (1)
104-104
: Remove trailing whitespace.The line contains trailing whitespace which should be removed.
- src/style/** + src/style/**🧰 Tools
🪛 yamllint (1.35.1)
[error] 104-104: trailing spaces
(trailing-spaces)
src/style/app.module.css (1)
607-618
: Consider enhancing scrollbar accessibility.While the scrollbar styling looks good, consider adding
aria-orientation
attributes to containers with custom scrollbars for better screen reader support.src/screens/Users/Users.tsx (1)
19-19
: Consider using a more specific CSS module import.The import has been changed from a local to a global styles module. While this aligns with the project's move towards centralized styling, consider creating a more specific module for user-related styles to maintain better separation of concerns.
src/screens/OrgList/OrgList.tsx (1)
277-277
: Remove debug console.log statement.The console.log statement appears to be used for debugging and should be removed before merging to production.
- console.log('loadMoreOrganizations');
src/components/EventCalendar/EventCalendar.tsx (1)
399-399
: Improved event rendering logic.The conditional rendering of events has been enhanced with better handling of holiday lists and event visibility. The empty object literal on line 399 appears unnecessary.
- {}
Also applies to: 535-539, 550-550
src/components/Advertisements/Advertisements.test.tsx (2)
Line range hint
464-475
: Consider simplifying the date parsing logic.The current date parsing using regex is complex and brittle. Consider using a date parsing library or simplifying the logic.
- const dateString = date[0].innerHTML; - const dateMatch = dateString.match( - /\b(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(\d{1,2})\s+(\d{4})\b/, - ); - let dateObject = new Date(); - - if (dateMatch) { - const monthName = dateMatch[1]; - const day = parseInt(dateMatch[2], 10); - const year = parseInt(dateMatch[3], 10); - - const monthIndex = - 'JanFebMarAprMayJunJulAugSepOctNovDec'.indexOf(monthName) / 3; + const dateString = date[0].innerHTML; + const dateObject = new Date(dateString);
Line range hint
651-652
: Remove console.log statements.Debug console.log statements should be removed before committing the code.
- console.log('before scroll', moreiconbtn); - fireEvent.scroll(window, { target: { scrollY: 500 } }); + fireEvent.scroll(window, { target: { scrollY: 500 } });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (52)
.github/workflows/check-tsdoc.js
(1 hunks).github/workflows/pull-request.yml
(2 hunks)Dockerfile
(1 hunks)jest.config.js
(3 hunks)package.json
(3 hunks)public/locales/en/errors.json
(1 hunks)public/locales/en/translation.json
(2 hunks)public/locales/fr/errors.json
(1 hunks)public/locales/hi/errors.json
(1 hunks)public/locales/sp/errors.json
(1 hunks)public/locales/zh/errors.json
(1 hunks)src/components/AddOn/core/AddOnEntry/AddOnEntry.module.css
(1 hunks)src/components/AddOn/core/AddOnEntry/AddOnEntry.spec.tsx
(1 hunks)src/components/AddOn/core/AddOnEntry/AddOnEntry.tsx
(5 hunks)src/components/AddOn/core/AddOnStore/AddOnStore.module.css
(2 hunks)src/components/AddOn/core/AddOnStore/AddOnStore.test.tsx
(2 hunks)src/components/AddOn/core/AddOnStore/AddOnStore.tsx
(6 hunks)src/components/AddOn/support/components/Action/Action.spec.tsx
(1 hunks)src/components/AddOn/support/services/Plugin.helper.test.ts
(1 hunks)src/components/Advertisements/Advertisements.module.css
(2 hunks)src/components/Advertisements/Advertisements.test.tsx
(1 hunks)src/components/Advertisements/Advertisements.tsx
(4 hunks)src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.module.css
(1 hunks)src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx
(3 hunks)src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.module.css
(1 hunks)src/components/Avatar/Avatar.spec.tsx
(1 hunks)src/components/Avatar/Avatar.test.tsx
(0 hunks)src/components/EventCalendar/EventCalendar.tsx
(6 hunks)src/components/EventCalendar/YearlyEventCalender.tsx
(2 hunks)src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.test.tsx
(1 hunks)src/components/OrgSettings/General/GeneralSettings.tsx
(1 hunks)src/components/OrganizationScreen/OrganizationScreen.test.tsx
(1 hunks)src/screens/EventVolunteers/Requests/Requests.spec.tsx
(4 hunks)src/screens/LoginPage/LoginPage.tsx
(2 hunks)src/screens/OrgList/OrgList.tsx
(2 hunks)src/screens/OrgSettings/OrgSettings.module.css
(0 hunks)src/screens/OrgSettings/OrgSettings.spec.tsx
(4 hunks)src/screens/OrgSettings/OrgSettings.tsx
(3 hunks)src/screens/OrganizationDashboard/OrganizationDashboard.module.css
(0 hunks)src/screens/OrganizationDashboard/OrganizationDashboard.tsx
(7 hunks)src/screens/Requests/Requests.spec.tsx
(2 hunks)src/screens/UserPortal/Campaigns/Campaigns.spec.tsx
(4 hunks)src/screens/UserPortal/Donate/Donate.spec.tsx
(2 hunks)src/screens/UserPortal/UserScreen/UserScreen.spec.tsx
(6 hunks)src/screens/UserPortal/Volunteer/UpcomingEvents/UpcomingEvents.spec.tsx
(2 hunks)src/screens/Users/Users.module.css
(0 hunks)src/screens/Users/Users.tsx
(5 hunks)src/style/app.module.css
(6 hunks)src/utils/errorHandler.test.tsx
(1 hunks)src/utils/errorHandler.tsx
(1 hunks)vitest.config.ts
(2 hunks)vitest.setup.ts
(1 hunks)
💤 Files with no reviewable changes (4)
- src/components/Avatar/Avatar.test.tsx
- src/screens/Users/Users.module.css
- src/screens/OrganizationDashboard/OrganizationDashboard.module.css
- src/screens/OrgSettings/OrgSettings.module.css
✅ Files skipped from review due to trivial changes (4)
- vitest.setup.ts
- public/locales/en/translation.json
- src/components/OrgSettings/General/GeneralSettings.tsx
- src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.module.css
🧰 Additional context used
📓 Learnings (1)
src/components/AddOn/support/components/Action/Action.spec.tsx (1)
Learnt from: adithyanotfound
PR: PalisadoesFoundation/talawa-admin#2482
File: src/components/AddOn/support/components/Action/Action.spec.tsx:1-8
Timestamp: 2024-11-27T06:37:47.871Z
Learning: In the Talawa-Admin project, the `@testing-library/jest-dom` package is imported globally in `vitest.setup.ts`, so individual test files do not need to import it separately.
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 104-104: trailing spaces
(trailing-spaces)
🔇 Additional comments (52)
src/screens/OrganizationDashboard/OrganizationDashboard.tsx (2)
489-489
: LGTM! Export statement correctly updated.
The export statement properly reflects the renamed component.
302-302
: Verify the className changes across the codebase.
The className changes from 'cardBody' to 'containerBody' look consistent within this file. Let's verify this change across other components.
Also applies to: 344-344, 395-395, 438-441
public/locales/zh/errors.json (1)
11-15
: New error messages added correctly
The additional error messages are consistent with the keys used in the error handling logic and correctly enhance localization support.
public/locales/hi/errors.json (1)
11-15
: New error messages added correctly
The new error messages align with the error handling updates and are correctly incorporated for localization.
public/locales/fr/errors.json (1)
11-15
: New error messages added correctly
The added error messages are consistent with the application's error handling and enhance the French localization.
src/utils/errorHandler.test.tsx (2)
41-49
: Well-structured parameterized tests!
Good use of test.each for testing similar validation scenarios. This makes the tests more maintainable and easier to extend.
72-93
: Comprehensive error handling tests
Good coverage of different error scenarios including:
- Different parameter types
- Non-Error objects
- Direct string messages
src/screens/LoginPage/LoginPage.tsx (1)
199-199
: LGTM: Improved reCAPTCHA verification flow
The early return pattern for reCAPTCHA verification enhances security by preventing form submission when verification fails.
Also applies to: 283-283
vitest.config.ts (3)
1-1
: LGTM! Correct import source for Vitest and SVG plugin.
The change from 'vite' to 'vitest/config' is appropriate for the Jest to Vitest migration. The addition of the SVG plugin will enable proper handling of SVG files in the test environment.
Also applies to: 5-6
14-14
: LGTM! SVG plugin configuration.
The svgrPlugin is correctly added to the plugins array, enabling SVG imports as React components.
20-20
: Verify the setup file exists and contains required configuration.
The setupFiles configuration points to 'vitest.setup.ts', which should contain the global test setup including @testing-library/jest-dom imports.
✅ Verification successful
Setup file exists and contains the required testing library import
The vitest.setup.ts
file exists and correctly imports @testing-library/jest-dom
for DOM testing utilities, which is the expected configuration for the test environment.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify the existence and content of vitest.setup.ts
if [ -f "vitest.setup.ts" ]; then
echo "Setup file exists"
cat vitest.setup.ts
else
echo "Setup file is missing"
fi
Length of output: 131
src/components/AddOn/support/components/Action/Action.spec.tsx (1)
1-6
: LGTM! Well-documented test file.
The JSDoc comments clearly describe the purpose of the test file.
src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.module.css (1)
23-23
: Verify the impact of reduced media height on UI.
The height reduction from 20rem to 16rem might affect the aspect ratio of displayed media.
✅ Verification successful
Height reduction appears safe for both image and video content
The height change affects both <video>
and <Card.Img>
elements which use the admedia
class. The component handles both media types appropriately with proper scaling attributes:
- Videos use
muted
,autoPlay
, andloop
properties - Images use
variant="top"
in Card.Img which maintains aspect ratio - Both elements are contained within a responsive Bootstrap Card layout
The reduction from 20rem to 16rem should maintain visual consistency while being more compact.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for references to this class to understand usage context
rg -l "admedia" --type css --type typescript --type tsx
Length of output: 90
Script:
#!/bin/bash
# Search for references to this class using ripgrep with correct file types
rg -l "admedia" --type css --type jsx --type tsx --type js
# Also check for any image/media components that might be affected
fd -e jsx -e tsx -e js | xargs rg -l "Advertisement"
# Look for the specific CSS module usage
rg -l "AdvertisementEntry\.module\.css"
Length of output: 841
Script:
#!/bin/bash
# Let's check the actual usage of the CSS class in the component
cat src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx
# Also check if there are any media elements or specific height constraints
rg -A 5 -B 5 "admedia" src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx
Length of output: 8351
src/components/AddOn/core/AddOnStore/AddOnStore.module.css (1)
46-72
: LGTM! Well-implemented responsive design
Good implementation of responsive grid layout with proper breakpoints and mobile-first adjustments. The use of CSS Grid and relative units ensures consistent layout across different screen sizes.
.github/workflows/check-tsdoc.js (1)
26-26
: LGTM! Good test file exclusion
Appropriate addition of .spec.tsx
exclusion that aligns with the test framework migration. This ensures that test files are properly excluded from TSDoc requirements while maintaining documentation standards for component files.
src/components/AddOn/support/services/Plugin.helper.test.ts (1)
12-23
: LGTM! Comprehensive test object structure
Good enhancement of the test object with additional plugin properties, providing better coverage of the actual data structure used in the application.
jest.config.js (2)
39-39
: LGTM: CSS module mapping addition
The addition of CSS module mapping to identity-obj-proxy
aligns with the project's migration to use CSS modules and supports the styling framework updates.
71-71
: Verify the necessity of excluding Actions.spec.tsx
The specific exclusion of src/screens/UserPortal/Volunteer/Actions/Actions.spec.tsx
from both coverage and test paths seems unusual. This might indicate:
- A temporary exclusion during the Jest to Vitest migration
- A problematic test that needs attention
Also applies to: 83-83
src/components/OrganizationScreen/OrganizationScreen.test.tsx (1)
84-84
: LGTM: Updated class assertions to use CSS modules
The changes correctly update the class assertions to use CSS module styles instead of hardcoded class names, improving maintainability while preserving test functionality.
Also applies to: 90-90
src/components/Avatar/Avatar.spec.tsx (2)
7-14
: LGTM: Well-documented test cases
Excellent job on the comprehensive test documentation. The JSDoc comments clearly explain the test objectives and steps.
Also applies to: 36-44, 60-68
16-34
: LGTM: Proper dependency mocking
Good practice in mocking the store and i18n dependencies, ensuring proper test isolation.
src/screens/OrgSettings/OrgSettings.tsx (2)
29-29
: LGTM: Component naming follows React conventions
The component has been renamed from orgSettings
to OrgSettings
to follow React's PascalCase naming convention for components.
Also applies to: 129-129
4-4
: Verify style migration from module-specific to app-wide CSS
The style import has been moved from a component-specific module to the app-wide CSS module. Ensure that all necessary styles have been properly migrated and that there are no unintended style conflicts.
✅ Verification successful
Let me verify if the old CSS module exists and check for any potential style conflicts.
Style migration appears to be properly implemented
The verification shows that:
- The old
OrgSettings.module.css
file no longer exists in the src directory - The required styles (
headerBtn
,settingsTabs
,settingsDropdown
) are present in the newapp.module.css
- The OrgSettings component correctly uses these styles from the new location
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if the old CSS module still exists and if styles were properly migrated
rg -l "OrgSettings\.module\.css"
cat src/style/app.module.css 2>/dev/null | grep -A 5 -B 5 "settingsTabs\|settingsDropdown\|headerBtn"
Length of output: 608
Script:
#!/bin/bash
# Check for the old CSS module file
fd "OrgSettings.module.css" src
# Check for any other components using these style classes
rg "className.*(?:headerBtn|settingsTabs|settingsDropdown)" --type ts --type tsx
Length of output: 142
Script:
#!/bin/bash
# Check for the old CSS module file
fd "OrgSettings.module.css" src
# Check for any other components using these style classes (fixed file type)
rg "className.*(?:headerBtn|settingsTabs|settingsDropdown)" -t ts -t tsx
# Check if these styles are used in the OrgSettings component
rg "className.*=.*styles\." src/screens/OrgSettings/OrgSettings.tsx
Length of output: 372
src/components/AddOn/core/AddOnEntry/AddOnEntry.tsx (2)
20-22
: LGTM: Improved type safety
Good improvements to type safety:
- Changed
modified
fromany
toboolean
- Added return type for
getInstalledPlugins
105-108
: Verify visual consistency of UI changes
Multiple UI changes have been made:
- Added border and border-radius to Card
- Changed font weight of Card.Title
- Updated icon class based on installation status
Please ensure these changes align with the design system and maintain visual consistency across the application.
Also applies to: 121-121, 141-141
src/screens/OrgSettings/OrgSettings.spec.tsx (3)
19-27
: LGTM: Improved router mocking implementation
Good implementation of router mocking:
- Uses
vi.doMock
for better isolation - Properly preserves actual router functionality
- Allows dynamic parameter handling
57-58
: LGTM: Proper test cleanup
Good practice: Added cleanup after each test to prevent mock leakage between tests.
133-146
: LGTM: Enhanced test coverage
Good addition of test cases:
- Tests dropdown rendering
- Verifies presence of all settings options
- Checks interaction with dropdown
src/screens/UserPortal/UserScreen/UserScreen.spec.tsx (2)
1-10
: LGTM! Well-documented test suite.
The documentation block clearly describes the purpose and scope of the tests.
29-37
: LGTM! Clean mock implementation.
The mock implementation follows Vitest best practices by using vi.mock
and preserving the actual router implementation.
package.json (1)
140-140
: LGTM! Correct dependency categorization.
Moving cross-env
to devDependencies is correct as it's only used in development scripts.
src/screens/EventVolunteers/Requests/Requests.spec.tsx (2)
32-37
: LGTM! Clean mock implementation.
The toast mock implementation follows Vitest best practices.
85-88
: LGTM! Proper test cleanup.
The router mock and cleanup implementation follow Vitest best practices.
Also applies to: 92-92
src/screens/UserPortal/Volunteer/UpcomingEvents/UpcomingEvents.spec.tsx (2)
24-32
: LGTM! Well-documented test suite.
The documentation block effectively describes the purpose and scenarios being tested, which improves maintainability.
93-99
: LGTM! Proper async module mocking setup.
The mock setup correctly uses async imports and proper cleanup, following Vitest's best practices.
Also applies to: 107-107
src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx (1)
153-156
: LGTM! Improved date display.
The addition of the start date improves user experience by providing complete timeline information.
src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.test.tsx (1)
219-227
: LGTM! Improved test reliability and readability.
The changes enhance the test by:
- Using a more concise way to simulate user input
- Making assertions more specific by checking the exact number of visible categories
src/screens/UserPortal/Donate/Donate.spec.tsx (3)
1-6
: Documentation improvement looks good!
The added documentation header clearly describes the purpose of the test suite.
141-144
: Mock implementation correctly migrated to Vitest
The migration from Jest to Vitest for router mocking follows best practices by using vi.importActual
to preserve the original module's functionality while mocking specific functions.
156-164
: Comprehensive matchMedia mock implementation
The matchMedia mock implementation is thorough and includes all necessary methods, including deprecated ones for backward compatibility.
src/screens/UserPortal/Campaigns/Campaigns.spec.tsx (1)
109-118
: Well-documented mock implementation.
The useParams mock is properly implemented with clear documentation and correct usage of async/await pattern.
.github/workflows/pull-request.yml (1)
52-52
: Verify the impact of automatic formatting.
The change from format
to format:fix
means the workflow will automatically fix formatting issues rather than just reporting them. This could potentially mask underlying issues.
✅ Verification successful
Automatic formatting is safe to use in this workflow
The format:fix
script uses Prettier with standard write mode to format TypeScript, TSX, JSON, SCSS, and CSS files. Since there's no existing format
script and no custom Prettier configurations, this change simply introduces automated formatting rather than replacing an existing check. Prettier is designed to be deterministic and safe for automated fixes.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if format:fix is defined in package.json
jq '.scripts["format:fix"]' package.json
Length of output: 93
Script:
#!/bin/bash
# Check the original format script
jq '.scripts.format' package.json
# Find any Prettier configuration files
fd -e json -e yaml -e yml -e js -e cjs prettier
fd -g '.prettier*'
# Look for any custom Prettier configurations in package.json
jq '.prettier' package.json
Length of output: 350
src/style/app.module.css (3)
1-30
: Well-structured CSS variable declarations.
The CSS variables are well-organized with:
- Clear naming conventions
- Documented color contrast ratios
- Appropriate fallback values
280-289
: Improved button accessibility with semantic colors.
The button styles now use semantic CSS variables and high-contrast text colors, improving accessibility.
682-706
: Well-structured responsive design rules.
The media queries follow mobile-first principles with consistent breakpoints and appropriate spacing adjustments.
src/screens/Users/Users.tsx (3)
94-103
: Great improvement in type safety!
The enhanced type definitions for fetchMore
and refetch
functions provide better type safety and make the code more maintainable. The explicit typing of the updateQuery
function is particularly helpful for preventing runtime errors.
182-186
: Good enhancement of type safety in event handling.
The event type has been properly specified as React.KeyboardEvent<HTMLInputElement>
and the target casting is now type-safe.
414-422
: Excellent accessibility improvements!
The "not found" messages now use semantic HTML with proper ARIA attributes, making the application more accessible to screen readers.
Also applies to: 426-430
src/screens/OrgList/OrgList.tsx (1)
52-53
: LGTM! Clean and concise implementation.
The toggleDialogModal
function has been simplified while maintaining its functionality.
src/components/EventCalendar/EventCalendar.tsx (1)
96-96
: Consider adding test coverage for edge cases.
The removed comment about testing complexity suggests a need for comprehensive test coverage. Consider adding test cases for various user roles and event visibility scenarios.
src/components/Advertisements/Advertisements.test.tsx (2)
464-464
: LGTM! The date array index change fixes the test logic.
The change from date[1]
to date[0]
correctly tests the first advertisement's end date which is in the past ('2023-01-01'), making the test assertion valid.
Line range hint 654-654
: ```diff
- console.log('after scroll', moreiconbtn);
</details>
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
@palisadoes , this time I am merging from merge-develop but still it is failing the test [PR Workflow / Check Target Branch (pull_request)] |
@NishantSinghhhhh Okay, keep working to fix those failed tests. You can ask the slack group for help too. |
Can you please tell me how can I pass the test, of same branch name My branch name is develop-merge which is not same as develop , but still my test is failing |
59b0879
into
PalisadoesFoundation:develop
What kind of change does this PR introduce?
Merge develop-postgres branch into develop branch.
Issue Number:
Fixes: #2667
Did you add tests for your changes?
Yes. Verified that all existing and new tests pass.
Snapshots/Videos:
Screencast.from.2024-12-16.21-44-07.webm
Screencast.from.2024-12-16.21-42-48.webm
Summary
This PR merges the latest changes from the develop-postgres branch into the develop branch. It resolves all merge conflicts while preserving the new functionality introduced in the develop-postgres branch. The goal is to align the develop branch with the updates and enhancements made in develop-postgres.
Does this PR introduce a breaking change?
No. All conflicts have been resolved, and tests confirm the integrity of the codebase.
Other information
Ensured that all tests pass after merging.
Fixed merge conflicts in critical files, including package-lock.json and package.json.
Verified compatibility between develop-postgres and develop.
Summary by CodeRabbit
New Features
Bug Fixes
Style
Tests
Chores