-
-
Notifications
You must be signed in to change notification settings - Fork 803
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
fixed:#2072 Upgraded package @testing-library/user-event from 12.8.3 to 14.5.2 #3252
base: develop-postgres
Are you sure you want to change the base?
fixed:#2072 Upgraded package @testing-library/user-event from 12.8.3 to 14.5.2 #3252
Conversation
WalkthroughThis pull request focuses on upgrading testing-related dependencies in the project. Specifically, the Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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 (1)
src/components/UpdateSession/UpdateSession.spec.tsx (1)
110-110
: Consider removing @ts-expect-error commentsMultiple instances of
@ts-expect-error
are used to suppress TypeScript errors. Instead of suppressing these errors, consider properly typing the test events:-// @ts-expect-error: Explanation for why this error is ignored +const mockMouseEvent = new MouseEvent('click', { + clientX: -999, // or other values +}) as unknown as React.MouseEvent;Also applies to: 131-131, 152-152
📜 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 (2)
package.json
(1 hunks)src/components/UpdateSession/UpdateSession.spec.tsx
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Test Application
- GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (1)
src/components/UpdateSession/UpdateSession.spec.tsx (1)
Line range hint
1-500
: Well-structured and comprehensive test suite!The test suite demonstrates excellent coverage with:
- Proper error handling
- Edge case testing
- Input validation
- Null checks
- Event handling verification
i am still working on this issue |
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: 12
🔭 Outside diff range comments (9)
src/components/Pagination/Pagination.spec.tsx (1)
Line range hint
1-63
: Consider adding assertions to verify component behaviorThe tests currently only verify that clicks don't throw errors, but they don't assert any expected behavior changes.
Consider adding assertions to verify that:
- The page number changes after clicking next/previous
- The navigation buttons are disabled at boundaries
- The correct page content is displayed
Example:
it('Component should be rendered properly', async () => { const onPageChange = vi.fn(); const props = { count: 15, page: 2, rowsPerPage: 5, onPageChange, }; render( <BrowserRouter> <Provider store={store}> <Pagination {...props} /> </Provider> </BrowserRouter> ); await userEvent.click(screen.getByTestId(/nextPage/i)); expect(onPageChange).toHaveBeenCalledWith(3); await userEvent.click(screen.getByTestId(/previousPage/i)); expect(onPageChange).toHaveBeenCalledWith(1); });src/components/UserPortal/Register/Register.spec.tsx (1)
Line range hint
5-5
: Add userEvent setup for v14 compatibilityThe upgrade to @testing-library/user-event v14 requires explicit setup. Initialize userEvent before tests:
import userEvent from '@testing-library/user-event'; + +const user = userEvent.setup();Then replace all
userEvent
calls withuser
. This is required for proper functionality with v14+.src/components/MemberRequestCard/MemberRequestCard.spec.tsx (1)
Multiple non-awaited userEvent calls found across test files
All userEvent methods return promises in v14.5.2 and must be awaited. Found multiple test files with synchronous calls that need to be updated:
- Form interactions in
src/components/OrgSettings/General/OrgUpdate/OrgUpdate.spec.tsx
- Search operations in
src/screens/Users/Users.spec.tsx
- File uploads in
src/screens/UserPortal/Posts/Posts.spec.tsx
- Settings forms in
src/screens/UserPortal/Settings/Settings.spec.tsx
- And 40+ other instances across the codebase
Update all userEvent method calls to use the
await
keyword:// Before userEvent.selectOptions(countryCode, value); // After await userEvent.selectOptions(countryCode, value);🔗 Analysis chain
Line range hint
1-124
: Verify consistent usage of async user events across the codebase.Let's ensure all
userEvent
calls are properly awaited after the upgrade to v14.5.2.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potentially missed async userEvent calls # Find potentially problematic userEvent calls that aren't awaited echo "Checking for non-awaited userEvent calls..." rg "userEvent\.(click|type|keyboard|paste|clear|selectOptions|deselectOptions|upload|hover|tab|keyboard)" -g "*.{ts,tsx,js,jsx}" | grep -v "await.*userEvent" # Find test files that might need updates echo -e "\nChecking for test files that might need review..." rg "@testing-library/user-event" -l -g "*.{spec,test}.{ts,tsx,js,jsx}"Length of output: 10896
src/screens/UserPortal/Events/Events.spec.tsx (1)
Add error scenario test coverage
The test suite lacks error handling scenarios. Consider adding tests for:
- GraphQL mutation errors during event creation
- Form validation errors (empty required fields)
- Invalid date/time combinations (end before start)
- Network errors and timeout scenarios
Example mock for error case:
{ request: { query: CREATE_EVENT_MUTATION, variables: { /* ... */ } }, result: { errors: [{ message: 'Failed to create event' }] } }🔗 Analysis chain
Line range hint
1-776
: Verify test coverage for error scenarios.While the test coverage for successful scenarios is comprehensive, consider adding tests for error cases such as:
- Invalid date/time combinations
- Server errors during event creation
- Validation errors (e.g., empty required fields)
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check for existing error scenario tests rg -B 2 -A 2 "toast.error" "src/screens/UserPortal/Events/Events.spec.tsx"Length of output: 72
Script:
#!/bin/bash # Check for error-related patterns and mocks rg -B 2 -A 2 "error:|errors:|Error|fail|invalid|reject" "src/screens/UserPortal/Events/Events.spec.tsx" # Check GraphQL mock structure for error cases ast-grep --pattern 'result: { errors: $_ }'Length of output: 258
src/components/LeftDrawer/LeftDrawer.spec.tsx (1)
Line range hint
92-94
: Migrate remaining click events to userEvent.For consistency with @testing-library/user-event v14+, replace direct
.click()
calls withawait userEvent.click()
.- orgsBtn.click(); + await userEvent.click(orgsBtn);Also applies to: 170-172, 189-191
src/screens/CommunityProfile/CommunityProfile.spec.tsx (1)
Line range hint
231-259
: Add missingawait
statement for userEvent.upload call.The
userEvent.upload()
call on line 241 is missing the requiredawait
:Apply this diff to fix the missing await statement:
await userEvent.type(reddit, profileVariables.socialUrl); await userEvent.type(slack, profileVariables.socialUrl); - userEvent.upload(logo, profileVariables.logo); + await userEvent.upload(logo, profileVariables.logo); await wait();src/components/TagActions/TagActions.test.tsx (1)
Line range hint
30-36
: Consider replacing fixed timeouts with more deterministic approaches.While the
wait
function withsetTimeout
works, it's better to use more deterministic approaches likewaitFor
with specific conditions.Example refactor:
// Instead of async function wait(ms = 500): Promise<void> { await act(() => { return new Promise((resolve) => { setTimeout(resolve, ms); }); }); } // Use const waitForCondition = async (condition: () => boolean) => { await waitFor(() => { expect(condition()).toBe(true); }); };src/screens/OrganizationPeople/OrganizationPeople.spec.tsx (1)
Line range hint
1787-1789
: Replace setTimeout with waitFor for more reliable tests.Using
setTimeout
in tests can lead to flaky tests. Instead, usewaitFor
from@testing-library/react
which provides better handling of asynchronous operations.Replace the Promise timeout with waitFor:
- await new Promise((resolve) => setTimeout(resolve, 100)); + await waitFor(() => { + expect(screen.getByTestId('role')).toBeInTheDocument(); + });Also applies to: 1803-1805
src/screens/LoginPage/LoginPage.spec.tsx (1)
Add error scenario test coverage
The test file needs additional test cases for error handling:
- Add GraphQL mutation error scenarios:
- Server validation errors in login/registration
- Network failures during mutations
- Rate limiting responses
- Token expiration handling
Example mock for a failed login:
{ request: { query: LOGIN_MUTATION, variables: { email: "test@test.com", password: "password" } }, error: new Error('Invalid credentials') }🔗 Analysis chain
Line range hint
1-1147
: Add missing test cases for error scenariosConsider adding test cases for:
- Network errors during login/registration
- Server validation errors
- Rate limiting scenarios
- Token expiration handling
Let's verify the current test coverage:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for error handling test cases rg -l "error|fail|reject|throw" src/screens/LoginPage/LoginPage.spec.tsxLength of output: 115
Script:
#!/bin/bash # Search for specific error scenarios with context echo "=== Network Error Tests ===" rg -B2 -A2 "Network error" src/screens/LoginPage/LoginPage.spec.tsx echo -e "\n=== Validation Error Tests ===" rg -B2 -A2 "validation|invalid" src/screens/LoginPage/LoginPage.spec.tsx echo -e "\n=== Rate Limit Tests ===" rg -B2 -A2 "rate|limit" src/screens/LoginPage/LoginPage.spec.tsx echo -e "\n=== Token Tests ===" rg -B2 -A2 "token.*expir|expir.*token" src/screens/LoginPage/LoginPage.spec.tsx echo -e "\n=== Error Handling in Mock Responses ===" rg -B2 -A2 "errors?.*:.*{" src/screens/LoginPage/LoginPage.spec.tsxLength of output: 1138
Script:
#!/bin/bash # Search for GraphQL error handling and UI error states echo "=== GraphQL Error Handling ===" rg -B5 -A2 "result: {" src/screens/LoginPage/LoginPage.spec.tsx echo -e "\n=== Error UI Tests ===" rg -B2 -A2 "toast\.(error|warn)" src/screens/LoginPage/LoginPage.spec.tsx echo -e "\n=== Error State Tests ===" rg -B2 -A2 "test\(.*error.*\)" src/screens/LoginPage/LoginPage.spec.tsx # Fix the previous regex for error handling in responses echo -e "\n=== Error Response Handling ===" rg -B2 -A2 '"errors?":\s*[{\[]' src/screens/LoginPage/LoginPage.spec.tsxLength of output: 650
Script:
#!/bin/bash # Search with fixed regex patterns echo "=== GraphQL Mock Results ===" rg -B2 -A5 'result:' src/screens/LoginPage/LoginPage.spec.tsx echo -e "\n=== Error Related Tests ===" rg -B2 -A2 'it\(.*error.*\)' src/screens/LoginPage/LoginPage.spec.tsx echo -e "\n=== Toast Mock Setup ===" rg -B2 -A5 'mock.*toast' src/screens/LoginPage/LoginPage.spec.tsx echo -e "\n=== Error Handling Setup ===" rg -B2 -A2 'error:|errors:' src/screens/LoginPage/LoginPage.spec.tsxLength of output: 2552
🧹 Nitpick comments (62)
src/components/UserPortal/UserNavbar/UserNavbar.spec.tsx (1)
Line range hint
1-258
: Consider adding cleanup after each test.While the changes look good, it would be beneficial to add cleanup after each test to ensure a clean state. This is especially important when dealing with cookies and localStorage.
Add this to your test suite:
describe('Testing UserNavbar Component [User Portal]', () => { + afterEach(() => { + cookies.remove('i18next'); + localStorage.clear(); + }); + afterEach(async () => { await act(async () => { await i18nForTest.changeLanguage('en'); }); });src/components/EventListCard/EventListCard.spec.tsx (2)
Line range hint
1-960
: Consider enhancing test coverage and maintainability.While the async operations are now properly handled, consider these improvements:
- Add error cases for user interactions
- Test form validation scenarios
- Group related test cases using
describe
blocks- Add cleanup between tests to prevent state leakage
339-347
: Replace multiple fireEvent+userEvent combinations with single userEvent calls.The pattern of clearing input with
fireEvent.change
followed byuserEvent.type
can be simplified. TheuserEvent.type
method already handles clearing input.- fireEvent.change(eventTitle, { target: { value: '' } }); - await userEvent.type(eventTitle, updateData.title); + await userEvent.clear(eventTitle); + await userEvent.type(eventTitle, updateData.title);Also applies to: 382-390, 435-443, 680-688
src/components/UserListCard/UserListCard.spec.tsx (2)
Line range hint
33-59
: Consider reducing test duplication.Both test cases appear to be performing identical actions despite having different descriptions. Consider:
- Consolidating the duplicate test setup into a reusable helper function
- Clarifying the distinct test scenarios in the descriptions
- Adding unique assertions for each test case
Example refactor:
describe('Testing User List Card', () => { const renderUserListCard = (props: any) => { return render( <MockedProvider addTypename={false} link={link}> <BrowserRouter> <I18nextProvider i18n={i18nForTest}> <UserListCard key={123} {...props} /> </I18nextProvider> </BrowserRouter> </MockedProvider> ); }; beforeEach(() => { vi.spyOn(global, 'alert').mockImplementation(() => {}); }); it('Should handle admin promotion when user has required permissions', async () => { renderUserListCard({ id: '456', hasPermission: true }); await wait(); await userEvent.click(screen.getByText(/Add Admin/i)); // Add assertions specific to this scenario }); it('Should handle admin promotion when user lacks permissions', async () => { renderUserListCard({ id: '456', hasPermission: false }); await wait(); await userEvent.click(screen.getByText(/Add Admin/i)); // Add assertions specific to this scenario }); });Also applies to: 61-78
Line range hint
33-36
: Consider using a more precise wait mechanism.Instead of using a fixed timeout with
wait
, consider usingwaitFor
orfindBy
queries from Testing Library to wait for specific conditions.Example:
import { waitFor } from '@testing-library/react'; // Replace wait() with specific conditions await waitFor(() => { expect(screen.getByText(/Add Admin/i)).toBeInTheDocument(); });src/components/Pagination/Pagination.spec.tsx (2)
30-31
: LGTM! Correctly updated for @testing-library/user-event v14The addition of
await
operators is correct and necessary for the upgraded version of @testing-library/user-event.However, consider removing the outer
act
wrapper as it's redundant when using modern versions of @testing-library/user-event:- await act(async () => { - await userEvent.click(screen.getByTestId(/nextPage/i)); - await userEvent.click(screen.getByTestId(/previousPage/i)); - }); + await userEvent.click(screen.getByTestId(/nextPage/i)); + await userEvent.click(screen.getByTestId(/previousPage/i));
62-63
: LGTM! Correctly updated for @testing-library/user-event v14The addition of
await
operators is correct and necessary for the upgraded version of @testing-library/user-event.Similarly to the previous test, consider removing the redundant
act
wrapper:- await act(async () => { - await userEvent.click(screen.getByTestId(/nextPage/i)); - await userEvent.click(screen.getByTestId(/previousPage/i)); - }); + await userEvent.click(screen.getByTestId(/nextPage/i)); + await userEvent.click(screen.getByTestId(/previousPage/i));src/screens/UserPortal/Donate/Donate.spec.tsx (1)
Line range hint
1-948
: Consider adding tests for concurrent user interactions.While the current test coverage is comprehensive for sequential operations, consider adding tests that verify the component's behavior during concurrent user interactions, such as:
- Rapidly switching currencies while a donation is being processed
- Submitting multiple donations in quick succession
- Typing in the amount field while currency is being switched
This would help ensure the component handles race conditions correctly with the new async user events.
src/components/OrgSettings/ActionItemCategories/CategoryModal.spec.tsx (1)
Line range hint
102-102
: Consider replacing fireEvent with userEvent for consistencyFor better test reliability, consider replacing
fireEvent.change()
withuserEvent.type()
in thefillFormAndSubmit
function. This would make all user interactions consistent with the @testing-library/user-event v14 approach.Example change:
- fireEvent.change(nameInput, { target: { value: name } }); + await userEvent.type(nameInput, name);src/components/UserPortal/PostCard/PostCard.spec.tsx (2)
350-357
: Consider consolidating related assertions.While the
await
keywords are correctly added, the test could be more robust by awaiting theclear
operation as well.await userEvent.click(screen.getByTestId('dropdown')); await userEvent.click(screen.getByTestId('editPost')); await wait(); expect(screen.getByTestId('editPostModalTitle')).toBeInTheDocument(); - userEvent.clear(screen.getByTestId('postInput')); + await userEvent.clear(screen.getByTestId('postInput')); await userEvent.type(screen.getByTestId('postInput'), 'Edited Post'); await userEvent.click(screen.getByTestId('editPostBtn'));
879-879
: Consider adding assertion wait time.While the view post interaction is correctly awaited, the assertion might need to wait for the comments to be rendered.
await userEvent.click(screen.getByTestId('viewPostBtn')); - expect(screen.findAllByText('Comments')).not.toBeNull(); + await wait(); + const comments = await screen.findAllByText('Comments'); + expect(comments).not.toBeNull();src/components/EventManagement/EventAttendance/EventStatistics.spec.tsx (3)
334-339
: Consider adding assertions for pagination effectsWhile the async implementation is correct, consider adding assertions to verify that the pagination actually changed the displayed data. This would make the test more meaningful.
Example addition:
await waitFor(async () => { const nextButton = screen.getByAltText('right-arrow'); const prevButton = screen.getByAltText('left-arrow'); await userEvent.click(nextButton); // Add assertion for next page data expect(screen.getByText('Test Event 2')).toBeInTheDocument(); await userEvent.click(prevButton); // Add assertion for previous page data expect(screen.getByText('Test Event 1')).toBeInTheDocument(); });
357-361
: Consider adding assertion for modal visibilityWhile the handleClose callback verification is good, consider adding an assertion to verify that the modal is no longer visible in the DOM after closing.
Example addition:
await waitFor(async () => { const closeButton = screen.getByTestId('close-button'); await userEvent.click(closeButton); expect(handleClose).toHaveBeenCalled(); // Add assertion for modal visibility expect(screen.queryByTestId('attendance-modal')).not.toBeInTheDocument(); });
Line range hint
1-363
: Consider enhancing test coverageThe async implementations are correct, but consider adding the following improvements:
- Test error scenarios (e.g., failed data exports)
- Verify chart rendering and data accuracy
- Add test cases for keyboard interactions
- Add test cases for accessibility features
These additions would make the test suite more comprehensive.
Would you like me to provide examples of these additional test cases?
src/components/UserPortal/Register/Register.spec.tsx (2)
121-121
: LGTM! Consider reducing test boilerplateThe addition of
await
to all userEvent calls is correct and necessary for v14 compatibility. The changes are consistent across all test cases.Consider reducing boilerplate by creating a helper function for common form interactions:
const fillFormFields = async (user: UserEvent, fields: Partial<typeof formData>) => { if (fields.email) { await user.type(screen.getByTestId('emailInput'), fields.email); } if (fields.password) { await user.type(screen.getByTestId('passwordInput'), fields.password); } // ... other fields }; // Usage in tests await fillFormFields(user, { email: formData.email, password: formData.password });Also applies to: 141-141, 161-162, 182-185, 187-187, 189-189, 209-212, 214-214, 216-219, 221-221, 241-244, 246-246, 248-251, 253-256, 258-258, 280-283, 285-287, 290-290, 292-295, 297-300, 302-302
Line range hint
57-63
: Consider removing manual wait timeoutsThe
wait
helper function with fixed timeouts can lead to flaky tests. With @testing-library/user-event v14, the setup provides better timing guarantees.Consider using
@testing-library/react
's built-in utilities:import { waitFor } from '@testing-library/react'; // Replace wait() calls with await waitFor(() => { expect(/* your assertion */); });src/screens/EventVolunteers/VolunteerGroups/VolunteerGroups.spec.tsx (3)
157-163
: LGTM! Correctly updated userEvent calls to be async.The addition of
await
keywords to userEvent methods aligns with the v14 upgrade requirements and ensures reliable test execution.Consider extracting common test setup steps into helper functions to reduce duplication between "Search by Groups" and "Search by Leader" tests:
const openSearchByOption = async (optionTestId: string): Promise<void> => { const searchToggle = await screen.findByTestId('searchByToggle'); await userEvent.click(searchToggle); const searchOption = await screen.findByTestId(optionTestId); await userEvent.click(searchOption); };Also applies to: 178-185
216-221
: LGTM! Modal interaction tests properly updated for async userEvent.The changes correctly implement async user interactions for modal operations.
Consider extracting the modal open/close pattern into a reusable test helper to reduce code duplication:
const testModalOpenClose = async ( buttonTestId: string, modalTitleText: string, index = 0 ): Promise<void> => { const button = await screen.findAllByTestId(buttonTestId); await userEvent.click(button[index]); expect(await screen.findByText(modalTitleText)).toBeInTheDocument(); await userEvent.click(await screen.findByTestId('modalCloseBtn')); };Also applies to: 229-232, 240-243, 251-254
Line range hint
1-254
: Consider migrating all fireEvent calls to userEvent for consistency.The file currently mixes
fireEvent
anduserEvent
. Since we're upgrading to@testing-library/user-event
v14, consider migrating the remainingfireEvent
calls (in the sorting functionality tests) touserEvent
for more accurate simulation of user interactions and better consistency across the test file.Example change for the sorting test:
- fireEvent.click(sortBtn); - fireEvent.click(volunteersDESC); + await userEvent.click(sortBtn); + await userEvent.click(volunteersDESC);src/components/UserPortal/StartPostModal/StartPostModal.spec.tsx (1)
255-256
: LGTM! Async handling added for error case testingThe user interactions are properly awaited. However, consider adding a specific error message assertion to verify the exact error being displayed to users.
await wait(); - expect(toast.error).toHaveBeenCalled(); + expect(toast.error).toHaveBeenCalledWith('Failed to create post');src/components/ProfileDropdown/ProfileDropdown.spec.tsx (1)
Line range hint
1-295
: Consider setting up userEvent instance once for better performance.With
@testing-library/user-event
v14, it's recommended to set up the user instance once and reuse it across tests for better performance.Consider refactoring the tests to use a shared user instance:
import { vi } from 'vitest'; const { setItem } = useLocalStorage(); +const user = userEvent.setup(); const mockNavigate = vi.fn();
Then update the test cases to use this instance:
-await userEvent.click(screen.getByTestId('togDrop')); +await user.click(screen.getByTestId('togDrop'));src/components/RequestsTableItem/RequestsTableItem.spec.tsx (1)
Line range hint
1-208
: Consider adding assertions after user interactions.While the async handling is correct, the test cases would be more robust with assertions after the click events to verify the expected outcomes.
For example, in the "Accept MembershipRequest Button works properly" test, consider adding assertions to verify:
- The success toast was shown
- The resetAndRefetch mock was called
- The UI was updated appropriately
await userEvent.click(screen.getByTestId('acceptMembershipRequestBtn123')); +expect(resetAndRefetchMock).toHaveBeenCalled(); +// Add more assertions as neededsrc/components/UserPortal/OrganizationNavbar/OrganizationNavbar.spec.tsx (1)
Line range hint
1-571
: Consider extracting common test setup to a utility functionThe test file has multiple test cases with similar setup code. Consider creating a utility function to reduce duplication and improve maintainability:
function renderOrganizationNavbar(options = {}) { const { mockProvider = link, useRouter = true, history = createMemoryHistory() } = options; const wrapper = render( <MockedProvider addTypename={false} link={mockProvider}> {useRouter ? ( <Router location={history.location} navigator={history}> <Provider store={store}> <I18nextProvider i18n={i18nForTest}> <OrganizationNavbar {...navbarProps} /> </I18nextProvider> </Provider> </Router> ) : ( <BrowserRouter> <Provider store={store}> <I18nextProvider i18n={i18nForTest}> <OrganizationNavbar {...navbarProps} /> </I18nextProvider> </Provider> </BrowserRouter> )} </MockedProvider> ); return { ...wrapper, history }; }This would simplify your test cases and make them more maintainable.
src/components/UserPortal/ContactCard/ContactCard.spec.tsx (1)
Line range hint
29-37
: Consider using modern testing practices for async operations.Instead of using a custom
wait
function with setTimeout, consider using more modern approaches:-async function wait(ms = 100): Promise<void> { - await act(() => { - return new Promise((resolve) => { - setTimeout(resolve, ms); - }); - }); -} // Replace wait() calls with either: // 1. waitFor from @testing-library/react // 2. findBy* queries instead of getBy* // 3. Modern async utilities from @testing-library/user-eventThis would make the tests more reliable and follow current best practices for handling async operations in React tests.
src/components/MemberRequestCard/MemberRequestCard.spec.tsx (1)
83-84
: LGTM! Consider enhancing test coverage.The addition of
await
for user events is correct and necessary for the upgraded@testing-library/user-event@14.5.2
.Consider enhancing the test by:
- Verifying the mutation results after the Accept/Reject actions
- Removing the custom
wait
function as it may be unnecessary with proper event awaitingsrc/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx (1)
140-146
: Simplify multiple wait calls.While the
await userEvent.click()
is correctly added, there are unnecessarywait()
calls between interactions that can be simplified.await userEvent.click(getByTestId('language-dropdown-btn')); - await wait(); const changeLanguageBtn = getByTestId(`change-language-btn-fr`); - await wait(); expect(changeLanguageBtn).toBeInTheDocument(); - await wait(); await userEvent.click(changeLanguageBtn);src/screens/EventVolunteers/Volunteers/Volunteers.spec.tsx (1)
Line range hint
1-296
: Well-structured test suite with proper async handlingThe test suite demonstrates excellent organization with:
- Consistent use of test-ids for reliable element selection
- Proper mock setup and teardown
- Clear test case organization
- Consistent async handling patterns
The upgrade changes have been properly implemented while maintaining the existing test structure integrity.
src/screens/UserPortal/Events/Events.spec.tsx (1)
652-653
: Consider removing commented-out code.These lines appear to be commented-out test code. Either implement the test or remove the commented lines to maintain clean code.
- // await userEvent.click(screen.getByTestId('modeChangeBtn')); - // await userEvent.click(screen.getByTestId('modeBtn1'));src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.spec.tsx (1)
Line range hint
220-230
: Consider consolidating wait calls for better test performance.While the async handling is correct, multiple consecutive
wait()
calls could be consolidated to improve test performance.- await userEvent.click(screen.getByTestId('saveChangesBtn')); - await wait(); - expect( - screen.queryByText('Failed to add custom field'), - ).toBeInTheDocument(); - await wait(); - await userEvent.type(screen.getByTestId('customFieldInput'), 'Age{enter}'); - await wait(); + await userEvent.click(screen.getByTestId('saveChangesBtn')); + await wait(); + expect( + screen.queryByText('Failed to add custom field'), + ).toBeInTheDocument(); + await userEvent.type(screen.getByTestId('customFieldInput'), 'Age{enter}'); + await wait();src/screens/Requests/Requests.spec.tsx (1)
215-218
: Simplify the async act wrapperThe
act
wrapper with async/await is redundant here since @testing-library/user-event already handles this internally.Simplify to:
- await act( - async () => - await userEvent.type(screen.getByTestId(/searchByName/i), search), - ); + await userEvent.type(screen.getByTestId(/searchByName/i), search);src/components/EditCustomFieldDropDown/EditCustomFieldDropDown.spec.tsx (1)
52-54
: Remove unnecessaryact
wrapper arounduserEvent.click
The
act
wrapper is redundant here asuserEvent
methods already wrap operations inact()
internally.- act(async () => { - await userEvent.click(getByTestId('toggleBtn')); - }); + await userEvent.click(getByTestId('toggleBtn'));src/screens/EventVolunteers/Volunteers/VolunteerCreateModal.spec.tsx (1)
Line range hint
89-91
: Consider using userEvent consistently instead of mixing with fireEventFor consistency and better simulation of real user interactions, consider using userEvent for all interactions instead of mixing fireEvent and userEvent.
- fireEvent.mouseDown(volunteerInputField); - const volunteerOption = await screen.findByText('John Doe'); - fireEvent.click(volunteerOption); + await userEvent.click(volunteerInputField); + const volunteerOption = await screen.findByText('John Doe'); + await userEvent.click(volunteerOption);Also applies to: 114-116
src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupDeleteModal.spec.tsx (1)
114-114
: Changes align with @testing-library/user-event v14+ requirements!The addition of
await
touserEvent.click()
calls is correct and necessary for the v14+ upgrade. In v14, all user event methods return promises and must be awaited.Consider adding a helper function to standardize user interactions across test files, for example:
const clickElement = async (element: HTMLElement): Promise<void> => { await userEvent.click(element); };Also applies to: 129-129, 142-142
src/components/EventManagement/EventAttendance/EventAttendance.spec.tsx (1)
106-106
: Test modifications follow best practices!The changes correctly implement async user events while maintaining good test organization with proper use of
waitFor
for assertions.Consider grouping related test scenarios into describe blocks for better organization:
describe('sorting functionality', () => { it('changes attendee order', async () => { // Your existing test }); }); describe('filtering functionality', () => { // Your existing test });Also applies to: 109-109, 124-124, 127-127, 141-141, 148-148
src/components/UserPasswordUpdate/UserPasswordUpdate.spec.tsx (1)
Line range hint
21-27
: Consider removing custom wait function!With
@testing-library/user-event
v14+, the customwait
function might be unnecessary as the library handles timing internally.You can likely remove the custom wait function and rely on
waitFor
from @testing-library/react for explicit waits:// Instead of: await wait(); // Use: await waitFor(() => { // your assertions });src/components/EventManagement/EventAgendaItems/EventAgendaItems.spec.tsx (1)
Line range hint
141-203
: LGTM! Comprehensive async handling of user interactions.The changes correctly await all userEvent operations, including clicks and type events.
Consider adding explicit assertions after modal interactions to verify the modal's state:
await userEvent.click(screen.getByTestId('createAgendaItemBtn')); expect(screen.getByRole('dialog')).toBeVisible(); await userEvent.click(screen.getByTestId('createAgendaItemModalCloseBtn')); expect(screen.queryByRole('dialog')).not.toBeInTheDocument();src/components/OrgSettings/AgendaItemCategories/AgendaCategoryUpdateModal.spec.tsx (1)
Line range hint
121-134
: Migrate form interactions from fireEvent to userEvent.For better simulation of real user interactions, replace fireEvent with userEvent for form operations.
- fireEvent.change(nameInput, { - target: { value: 'New name' }, - }); + await userEvent.type(nameInput, 'New name'); - fireEvent.change(descriptionInput, { - target: { value: 'New description' }, - }); + await userEvent.type(descriptionInput, 'New description');src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx (2)
145-145
: LGTM! The changes correctly handle async user events.The addition of
await
touserEvent
calls aligns with the breaking changes introduced in @testing-library/user-event v13+.Consider replacing
fireEvent
calls withuserEvent
for consistency, asuserEvent
better simulates real user interactions. For example:-fireEvent.click(sortBtn); -fireEvent.click(screen.getByTestId('endDate_DESC')); +await userEvent.click(sortBtn); +await userEvent.click(screen.getByTestId('endDate_DESC'));Also applies to: 150-150, 166-166, 173-173
Line range hint
1-1000
: Overall assessment of the @testing-library/user-event upgrade changesThe changes correctly implement the breaking changes introduced in @testing-library/user-event v13+, where all user events became asynchronous. The consistent addition of
await
to userEvent calls is necessary and well-executed.For better maintainability and consistency across the test suite, consider:
- Replacing remaining
fireEvent
calls withuserEvent
where applicable- Adding a lint rule to enforce
await
withuserEvent
calls- Adding comments in the test setup files about the async nature of userEvent v13+
src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx (1)
185-188
: Consider enhancing test coverage with error scenarios.The async handling of user interactions is correct for the upgraded package. However, consider adding test cases for error scenarios, such as:
- Click events that fail or are interrupted
- Multiple rapid clicks
- Click events during loading states
Example test case:
it('handles failed click events gracefully', async () => { vi.mocked(useParams).mockReturnValue({ orgId: 'orgId' }); renderOrganizationDashboard(link1); const membersBtn = await screen.findByText(t.members); // Simulate a loading state membersBtn.setAttribute('disabled', 'true'); await userEvent.click(membersBtn); await waitFor(() => { expect(screen.queryByTestId('orgpeople')).not.toBeInTheDocument(); }); });Also applies to: 205-209, 217-221, 229-233, 241-245, 253-257, 265-269, 277-281, 289-293
src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupModal.spec.tsx (1)
199-201
: Standardize event handling approach.While the async handling is correct, the test file mixes
userEvent
andfireEvent
. For consistency and better real-world simulation, preferuserEvent
overfireEvent
.Example refactor:
// Instead of fireEvent.change(nameInput, { target: { value: 'Group 1' } }); // Use await userEvent.type(nameInput, 'Group 1');Also applies to: 249-251, 277-281, 307-309
src/screens/UserPortal/Pledges/Pledge.test.tsx (1)
146-150
: Improve organization of sequential async operations.While the async handling is correct, consider using test helpers to improve readability of sequential operations.
Example refactor:
// Helper function const clickFilterAndOption = async (optionTestId: string) => { await userEvent.click(screen.getByTestId('filter')); await waitFor(() => { expect(screen.getByTestId(optionTestId)).toBeInTheDocument(); }); await userEvent.click(screen.getByTestId(optionTestId)); }; // Usage in test it('Sort the Pledges list by Lowest Amount', async () => { renderMyPledges(link1); await screen.findByTestId('searchPledges'); await clickFilterAndOption('amount_ASC'); // ... rest of the test });Also applies to: 168-172, 190-194, 212-216
src/components/TagActions/TagActions.test.tsx (1)
258-273
: Improve organization of tag selection test cases.The test has multiple sequential operations that could be better organized using test helpers.
Example refactor:
const selectAndVerifyTag = async (tagId: string) => { await waitFor(() => { expect(screen.getByTestId(`checkTag${tagId}`)).toBeInTheDocument(); }); await userEvent.click(screen.getByTestId(`checkTag${tagId}`)); }; it('Selects and deselects tags', async () => { renderTagActionsModal(props[0], link); await selectAndVerifyTag('1'); await selectAndVerifyTag('2'); // ... rest of the test });src/screens/FundCampaignPledge/FundCampaignPledge.spec.tsx (2)
Line range hint
183-185
: Consider replacing fireEvent with userEvent for consistency.For better consistency with the rest of the test suite, consider replacing
fireEvent
calls withuserEvent
. TheuserEvent
library more closely simulates real user interactions and provides better defaults.Example replacement:
- fireEvent.change(searchPledger, { - target: { value: 'John' }, - }); + await userEvent.type(searchPledger, 'John');Also applies to: 295-297, 315-317
Line range hint
1-1
: Overall changes look good with room for further improvements.The changes correctly implement the async requirements of @testing-library/user-event v14. For future maintenance:
- Consider establishing a team-wide convention to use
userEvent
exclusively overfireEvent
for better consistency and more realistic user interaction simulation.- Consider adding an ESLint rule to enforce awaiting userEvent calls to prevent similar issues in future.
src/screens/UserPortal/Posts/Posts.spec.tsx (1)
374-376
: Consider adding error handling for delete operation.The delete operation test should include error handling scenarios to ensure robust testing.
await userEvent.click(dropdowns[1]); const deleteButton = await screen.findByTestId('deletePost'); await userEvent.click(deleteButton); +await waitFor(() => { + expect(screen.queryByText('post two')).not.toBeInTheDocument(); +});src/components/AgendaCategory/AgendaCategoryContainer.spec.tsx (1)
Line range hint
119-434
: Consider reducing test duplication using shared setup functions.The test file has repeated patterns for modal interactions. Consider extracting common patterns into helper functions.
// Helper function example async function openAndCloseModal(openButtonTestId: string, closeButtonTestId: string): Promise<void> { await userEvent.click(screen.getAllByTestId(openButtonTestId)[0]); await waitFor(() => { return expect(screen.findByTestId(closeButtonTestId)).resolves.toBeInTheDocument(); }); await userEvent.click(screen.getByTestId(closeButtonTestId)); await waitForElementToBeRemoved(() => screen.queryByTestId(closeButtonTestId)); }src/components/AgendaItems/AgendaItemsContainer.spec.tsx (1)
Line range hint
441-441
: Implement missing drag and drop tests.The TODO comment indicates missing test coverage for drag and drop functionality.
Would you like me to help implement the drag and drop tests? I can provide a comprehensive test implementation that covers:
- Dragging items between different positions
- Validation of the new order
- Error scenarios during drag operations
src/screens/OrganizationEvents/OrganizationEvents.spec.tsx (1)
372-375
: Consider usingwaitFor
for checkbox state verification.After clicking checkboxes, it's recommended to verify their state changes within a
waitFor
block to ensure the state has been updated before proceeding.await userEvent.click(screen.getByTestId('alldayCheck')); - await userEvent.click(screen.getByTestId('recurringCheck')); - await userEvent.click(screen.getByTestId('ispublicCheck')); - await userEvent.click(screen.getByTestId('registrableCheck')); + await waitFor(() => { + expect(screen.getByTestId('alldayCheck')).not.toBeChecked(); + }); + await userEvent.click(screen.getByTestId('recurringCheck')); + await waitFor(() => { + expect(screen.getByTestId('recurringCheck')).toBeChecked(); + });src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx (1)
250-253
: Consider adding assertions for tab state.After switching tabs, it would be beneficial to verify the active tab state.
await userEvent.click(screen.getByText('Installed')); + await waitFor(() => { + expect(screen.getByText('Installed')).toHaveAttribute('aria-selected', 'true'); + }); await wait(); await userEvent.click(screen.getByText('Available')); + await waitFor(() => { + expect(screen.getByText('Available')).toHaveAttribute('aria-selected', 'true'); + });src/screens/ManageTag/ManageTag.spec.tsx (1)
154-161
: Consider adding error handling assertions for modal operations.For modal operations, it would be beneficial to verify error states and handle potential failure scenarios.
await userEvent.click(screen.getAllByTestId('unassignTagBtn')[0]); + // Verify modal error state + await waitFor(() => { + expect(screen.queryByText(/error/i)).not.toBeInTheDocument(); + }); await waitFor(() => { return expect( screen.findByTestId('unassignTagModalCloseBtn'), ).resolves.toBeInTheDocument(); });src/screens/UserPortal/Settings/Settings.spec.tsx (1)
286-286
: Consider awaiting file upload event.The file upload interaction should also be awaited for consistency:
await userEvent.click(screen.getByTestId('uploadImageBtn')); await wait(); const imageFile = new File(['(⌐□_□)'], 'profile-image.jpg', { type: 'image/jpeg', }); const files = [imageFile]; - userEvent.upload(fileInp, files); + await userEvent.upload(fileInp, files);Also applies to: 290-290, 291-291, 292-292, 293-293, 294-294
src/screens/OrgList/OrgList.spec.tsx (1)
Line range hint
262-262
: Inconsistent handling of select interactions.Some
userEvent.selectOptions
calls are not awaited while other user interactions are. For consistency:- userEvent.selectOptions( + await userEvent.selectOptions( screen.getByTestId('countrycode'), formData.address.countryCode, );Also applies to: 263-263, 264-264, 265-265, 266-266, 267-267, 268-268, 269-269, 270-270, 371-371, 372-372, 373-373, 374-374
src/components/OrgPostCard/OrgPostCard.spec.tsx (2)
Line range hint
201-206
: Consider using userEvent consistently instead of mixing with fireEvent.For consistency and better simulation of real user interactions, consider using
userEvent
instead offireEvent
.userEvent
provides better simulation of actual browser behavior.Example change:
- fireEvent.click(toggleButton); - expect(toggleButton).toHaveTextContent('hide'); - fireEvent.click(toggleButton); + await userEvent.click(toggleButton); + expect(toggleButton).toHaveTextContent('hide'); + await userEvent.click(toggleButton);Also applies to: 451-454
219-226
: Consider removing redundant wait calls.The test has a redundant
wait()
call before user interactions. SinceuserEvent
methods are already awaited, the additional wait is unnecessary.- await wait(); await userEvent.click(screen.getByAltText('image')); await userEvent.click(screen.getByTestId('moreiconbtn')); await userEvent.click(screen.getByTestId('editPostModalBtn'));
src/screens/OrganizationTags/OrganizationTags.spec.tsx (1)
211-211
: Consider grouping related sort interactionsWhile the async handling is correct, consider extracting the sort-related interactions into a helper function to improve test readability and maintainability.
const selectSortOption = async (option: 'oldest' | 'latest'): Promise<void> => { await userEvent.click(screen.getByTestId('sortTags')); await waitFor(() => { expect(screen.getByTestId(option)).toBeInTheDocument(); }); await userEvent.click(screen.getByTestId(option)); };Also applies to: 216-216
src/screens/OrganizationPeople/OrganizationPeople.spec.tsx (1)
Line range hint
1319-1321
: Replace fireEvent with userEvent for consistency.Since we're upgrading to
@testing-library/user-event@14.5.2
, we should consistently useuserEvent
instead offireEvent
for form interactions. This aligns with the library's best practices asuserEvent
provides better simulation of real user interactions.Replace instances of
fireEvent.change()
withuserEvent.type()
. For example:- fireEvent.change(screen.getByTestId('firstNameInput'), { - target: { value: 'Disha' }, - }); + await userEvent.type(screen.getByTestId('firstNameInput'), 'Disha');Also applies to: 1394-1397, 1461-1464, 1471-1474
src/screens/OrgPost/OrgPost.test.tsx (1)
Line range hint
411-420
: Replace fireEvent with userEvent for consistencyFor consistency with the upgraded @testing-library/user-event package, replace fireEvent with userEvent for form interactions.
- fireEvent.change(postTitleInput, { target: { value: 'Test Post' } }); + await userEvent.type(postTitleInput, 'Test Post'); - fireEvent.change(postInfoTextarea, { - target: { value: 'Test post information' }, - }); + await userEvent.type(postInfoTextarea, 'Test post information'); - fireEvent.click(createPostBtn); + await userEvent.click(createPostBtn);src/screens/LoginPage/LoginPage.spec.tsx (4)
384-402
: Consider reducing test code duplicationThere's significant duplication in form filling logic across multiple test cases. Consider extracting common form filling logic into helper functions to improve maintainability.
Example refactor:
async function fillRegistrationForm(formData: { firstName: string; lastName: string; email: string; password: string; confirmPassword: string; }) { await userEvent.type( screen.getByPlaceholderText(/First Name/i), formData.firstName ); await userEvent.type( screen.getByPlaceholderText(/Last Name/i), formData.lastName ); await userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); await userEvent.type( screen.getByPlaceholderText('Password'), formData.password ); await userEvent.type( screen.getByPlaceholderText('Confirm Password'), formData.confirmPassword ); }Also applies to: 432-449, 477-495, 523-541, 568-586, 673-691, 859-862, 891-894, 925-928, 959-962
637-643
: Consider extracting login form filling logicSimilar to registration form, login form filling logic is duplicated. Consider extracting it into a helper function.
Example refactor:
async function fillLoginForm(formData: { email: string; password: string }) { await userEvent.type(screen.getByTestId(/loginEmail/i), formData.email); await userEvent.type( screen.getByPlaceholderText(/Enter Password/i), formData.password ); }Also applies to: 718-724
751-754
: Consider consolidating password visibility toggle testsThe password visibility toggle tests for login, register, and confirm password fields follow the same pattern. Consider using a test.each to reduce code duplication.
Example refactor:
test.each([ ['login password', 'password', 'showLoginPassword'], ['register password', 'passwordField', 'showPassword'], ['confirm password', 'cpassword', 'showPasswordCon'] ])('Testing password preview feature for %s', async (name, inputId, toggleId) => { // ... setup code ... const input = screen.getByTestId(inputId) as HTMLInputElement; const toggleText = screen.getByTestId(toggleId); expect(input.type).toBe('password'); await userEvent.click(toggleText); expect(input.type).toBe('text'); await userEvent.click(toggleText); expect(input.type).toBe('password'); });Also applies to: 782-785, 813-816
857-862
: Consider consolidating password validation testsThe password validation tests have similar setup and assertions but vary in password length. Consider using test.each to make the tests more maintainable.
Example refactor:
test.each([ ['less than 8 characters', '7', true], ['greater than or equal to 8 characters', '12345678', false] ])('password error warning when password is %s', async (_, password, shouldShow) => { // ... setup code ... await userEvent.type(screen.getByPlaceholderText('Password'), password); if (shouldShow) { expect(screen.queryByTestId('passwordCheck')).toBeInTheDocument(); } else { expect(screen.queryByTestId('passwordCheck')).toBeNull(); } });Also applies to: 889-894, 921-928, 953-962
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (82)
src/components/AddOn/core/AddOnRegister/AddOnRegister.spec.tsx
(3 hunks)src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx
(2 hunks)src/components/AddPeopleToTag/AddPeopleToTag.spec.tsx
(3 hunks)src/components/Advertisements/Advertisements.spec.tsx
(3 hunks)src/components/AgendaCategory/AgendaCategoryContainer.spec.tsx
(11 hunks)src/components/AgendaItems/AgendaItemsContainer.spec.tsx
(11 hunks)src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx
(2 hunks)src/components/DynamicDropDown/DynamicDropDown.spec.tsx
(3 hunks)src/components/EditCustomFieldDropDown/EditCustomFieldDropDown.spec.tsx
(1 hunks)src/components/EventListCard/EventListCard.spec.tsx
(38 hunks)src/components/EventManagement/EventAgendaItems/EventAgendaItems.spec.tsx
(2 hunks)src/components/EventManagement/EventAttendance/EventAttendance.spec.tsx
(3 hunks)src/components/EventManagement/EventAttendance/EventStatistics.spec.tsx
(3 hunks)src/components/EventRegistrantsModal/AddOnSpotAttendee.spec.tsx
(4 hunks)src/components/LeftDrawer/LeftDrawer.spec.tsx
(2 hunks)src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx
(2 hunks)src/components/MemberRequestCard/MemberRequestCard.spec.tsx
(2 hunks)src/components/OrgAdminListCard/OrgAdminListCard.spec.tsx
(1 hunks)src/components/OrgPostCard/OrgPostCard.spec.tsx
(28 hunks)src/components/OrgSettings/ActionItemCategories/CategoryModal.spec.tsx
(3 hunks)src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.spec.tsx
(5 hunks)src/components/OrgSettings/AgendaItemCategories/AgendaCategoryUpdateModal.spec.tsx
(2 hunks)src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategory.spec.tsx
(7 hunks)src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.spec.tsx
(5 hunks)src/components/OrgSettings/General/OrgUpdate/OrgUpdate.spec.tsx
(2 hunks)src/components/Pagination/Pagination.spec.tsx
(2 hunks)src/components/ProfileDropdown/ProfileDropdown.spec.tsx
(6 hunks)src/components/RecurrenceOptions/CustomRecurrence.spec.tsx
(17 hunks)src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx
(13 hunks)src/components/RequestsTableItem/RequestsTableItem.spec.tsx
(4 hunks)src/components/TagActions/TagActions.test.tsx
(8 hunks)src/components/UpdateSession/UpdateSession.spec.tsx
(6 hunks)src/components/UserListCard/UserListCard.spec.tsx
(2 hunks)src/components/UserPasswordUpdate/UserPasswordUpdate.spec.tsx
(5 hunks)src/components/UserPortal/CommentCard/CommentCard.spec.tsx
(10 hunks)src/components/UserPortal/ContactCard/ContactCard.spec.tsx
(2 hunks)src/components/UserPortal/EventCard/EventCard.spec.tsx
(1 hunks)src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.spec.tsx
(8 hunks)src/components/UserPortal/PostCard/PostCard.spec.tsx
(9 hunks)src/components/UserPortal/Register/Register.spec.tsx
(7 hunks)src/components/UserPortal/StartPostModal/StartPostModal.spec.tsx
(5 hunks)src/components/UserPortal/UserNavbar/UserNavbar.spec.tsx
(8 hunks)src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.spec.tsx
(2 hunks)src/screens/BlockUser/BlockUser.spec.tsx
(6 hunks)src/screens/CommunityProfile/CommunityProfile.spec.tsx
(3 hunks)src/screens/EventManagement/EventManagement.spec.tsx
(7 hunks)src/screens/EventVolunteers/Requests/Requests.spec.tsx
(4 hunks)src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupDeleteModal.spec.tsx
(3 hunks)src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupModal.spec.tsx
(6 hunks)src/screens/EventVolunteers/VolunteerGroups/VolunteerGroups.spec.tsx
(3 hunks)src/screens/EventVolunteers/Volunteers/VolunteerCreateModal.spec.tsx
(2 hunks)src/screens/EventVolunteers/Volunteers/VolunteerDeleteModal.spec.tsx
(3 hunks)src/screens/EventVolunteers/Volunteers/Volunteers.spec.tsx
(4 hunks)src/screens/ForgotPassword/ForgotPassword.spec.tsx
(8 hunks)src/screens/FundCampaignPledge/FundCampaignPledge.spec.tsx
(6 hunks)src/screens/Leaderboard/Leaderboard.spec.tsx
(2 hunks)src/screens/LoginPage/LoginPage.spec.tsx
(19 hunks)src/screens/ManageTag/ManageTag.spec.tsx
(16 hunks)src/screens/MemberDetail/MemberDetail.spec.tsx
(6 hunks)src/screens/OrgList/OrgList.spec.tsx
(10 hunks)src/screens/OrgPost/OrgPost.test.tsx
(10 hunks)src/screens/OrgSettings/OrgSettings.spec.tsx
(3 hunks)src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx
(7 hunks)src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx
(9 hunks)src/screens/OrganizationEvents/OrganizationEvents.spec.tsx
(10 hunks)src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx
(2 hunks)src/screens/OrganizationFunds/OrganizationFunds.spec.tsx
(2 hunks)src/screens/OrganizationPeople/OrganizationPeople.spec.tsx
(28 hunks)src/screens/OrganizationTags/OrganizationTags.spec.tsx
(6 hunks)src/screens/Requests/Requests.spec.tsx
(2 hunks)src/screens/SubTags/SubTags.spec.tsx
(9 hunks)src/screens/UserPortal/Campaigns/Campaigns.spec.tsx
(6 hunks)src/screens/UserPortal/Donate/Donate.spec.tsx
(15 hunks)src/screens/UserPortal/Events/Events.spec.tsx
(7 hunks)src/screens/UserPortal/Organizations/Organizations.spec.tsx
(5 hunks)src/screens/UserPortal/People/People.spec.tsx
(3 hunks)src/screens/UserPortal/Pledges/Pledge.test.tsx
(9 hunks)src/screens/UserPortal/Posts/Posts.spec.tsx
(4 hunks)src/screens/UserPortal/Settings/Settings.spec.tsx
(4 hunks)src/screens/UserPortal/Volunteer/Actions/Actions.spec.tsx
(3 hunks)src/screens/UserPortal/Volunteer/Groups/GroupModal.spec.tsx
(11 hunks)src/screens/UserPortal/Volunteer/Groups/Groups.spec.tsx
(4 hunks)
⛔ Files not processed due to max files limit (4)
- src/screens/UserPortal/Volunteer/Invitations/Invitations.spec.tsx
- src/screens/UserPortal/Volunteer/UpcomingEvents/UpcomingEvents.spec.tsx
- src/screens/UserPortal/Volunteer/VolunteerManagement.spec.tsx
- src/screens/Users/Users.spec.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/UpdateSession/UpdateSession.spec.tsx
🧰 Additional context used
📓 Learnings (3)
src/components/TagActions/TagActions.test.tsx (1)
Learnt from: meetulr
PR: PalisadoesFoundation/talawa-admin#2362
File: src/components/TagActions/TagActions.test.tsx:30-36
Timestamp: 2024-11-12T10:40:58.655Z
Learning: In our unit tests (e.g., `TagActions.test.tsx`), we use `setTimeout` with `act` to wait for asynchronous operations, as it provides a consistent wait time and is our standard practice.
src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx (2)
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.
Learnt from: bitbard3
PR: PalisadoesFoundation/talawa-admin#2588
File: src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx:155-162
Timestamp: 2024-12-03T05:52:37.888Z
Learning: In the `ChangeLanguageDropdown` component (`src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.tsx`), error handling has not been implemented. Therefore, test cases in `src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx` do not cover error scenarios related to error handling.
src/screens/OrganizationPeople/OrganizationPeople.spec.tsx (1)
Learnt from: meetulr
PR: PalisadoesFoundation/talawa-admin#2425
File: src/screens/MemberDetail/MemberDetail.test.tsx:100-100
Timestamp: 2024-11-12T10:40:58.654Z
Learning: In `src/screens/MemberDetail/MemberDetail.test.tsx`, using `await wait();` is acceptable to wait for the render to complete.
🔇 Additional comments (133)
src/components/UserPortal/UserNavbar/UserNavbar.spec.tsx (4)
89-91
: LGTM! Properly awaiting language switching interactions.The changes correctly implement the required
await
keyword for user interactions, which is necessary for the upgraded@testing-library/user-event
v14+. This ensures proper handling of asynchronous click events in the language switching tests.Also applies to: 113-115, 137-139, 161-163, 185-187
209-209
: LGTM! Properly awaiting dropdown menu interaction.The dropdown menu interaction test has been correctly updated to await the click event.
229-230
: LGTM! Properly awaiting settings navigation interactions.The settings navigation test correctly awaits both the dropdown click and the settings link click events.
250-251
: LGTM! Properly awaiting logout interactions.The logout test correctly awaits both the dropdown click and the logout button click events.
src/components/EventListCard/EventListCard.spec.tsx (1)
118-123
: LGTM! Proper handling of async user events.The changes correctly add
await
before alluserEvent
interactions, which is necessary for compatibility with@testing-library/user-event
v14+. The modifications are systematic and maintain test reliability.Also applies to: 179-192, 205-215, 228-236, 253-262, 279-288, 300-306, 318-324, 335-362, 378-415, 431-459, 475-493, 510-525, 546-577, 609-660, 672-704, 724-776, 792-815, 827-837, 859-879, 918-920, 932-937, 955-955
src/components/UserListCard/UserListCard.spec.tsx (1)
58-58
: LGTM! Correctly updated user-event calls to be async.The changes properly align with @testing-library/user-event v14's requirement to await all user interactions. This prevents potential race conditions and makes tests more reliable.
Also applies to: 77-77
src/screens/UserPortal/Donate/Donate.spec.tsx (5)
443-445
: LGTM! Properly awaiting currency switching events.The changes correctly implement async/await for currency switching tests, which is required for the upgraded @testing-library/user-event version.
Also applies to: 466-468, 488-490
530-531
: LGTM! Properly awaiting donation submission events.The changes correctly implement async/await for donation submission test.
550-551
: LGTM! Properly awaiting validation test events.The changes correctly implement async/await for all validation test cases, including minimum amount, maximum amount, empty amount, and non-numeric amount scenarios.
Also applies to: 575-576, 600-600, 624-625
653-654
: LGTM! Properly awaiting whitespace handling test events.The changes correctly implement async/await for whitespace handling test.
731-731
: LGTM! Properly awaiting error handling test events.The changes correctly implement async/await for all error handling test cases, including empty amount, non-numeric amount, amount validation, and GraphQL error scenarios.
Also applies to: 797-798, 820-821, 843-844, 893-894, 947-948
src/components/OrgSettings/ActionItemCategories/CategoryModal.spec.tsx (3)
107-107
: LGTM! Proper async handling added for user interactionsThe addition of
await
touserEvent.click()
calls aligns with the requirements of @testing-library/user-event v14, ensuring proper handling of asynchronous user interactions.Also applies to: 109-109
137-137
: LGTM! Async handling added for switch toggleThe addition of
await
ensures proper handling of the switch toggle interaction in the test case.
214-214
: LGTM! Async handling added for form submissionThe addition of
await
ensures proper handling of the form submission interaction in the error test case.src/components/UserPortal/PostCard/PostCard.spec.tsx (6)
301-301
: LGTM! Correctly awaited dropdown interaction.The
userEvent.click
is properly awaited, which is required for the new version of@testing-library/user-event
.
406-407
: LGTM! Correctly awaited delete post interactions.The sequential user interactions are properly awaited.
510-511
: LGTM! Correctly awaited like/unlike post interactions.Both test cases properly await the user interactions for viewing and liking/unliking posts.
Also applies to: 563-564
656-656
: LGTM! Correctly awaited comment creation interactions.The sequence of viewing post, typing comment, and creating comment is properly awaited.
Also applies to: 658-659
740-740
: LGTM! Correctly awaited like comment interactions.The view post and like comment interactions are properly awaited.
Also applies to: 742-742
827-827
: LGTM! Correctly awaited unlike comment interactions.The view post and unlike comment interactions are properly awaited.
Also applies to: 829-829
src/components/EventManagement/EventAttendance/EventStatistics.spec.tsx (1)
180-191
: LGTM! Correct implementation of async user eventsThe changes properly implement the async user events pattern required by @testing-library/user-event v14. The test correctly awaits user interactions and verifies the UI state changes.
src/components/UserPortal/StartPostModal/StartPostModal.spec.tsx (5)
133-133
: LGTM! Proper async handling added for user interactionThe addition of
await
for the click event is correct and aligns with the requirements of@testing-library/user-event
v14.
144-147
: LGTM! Correct async handling for multiple user interactionsThe sequential user interactions (type and click) are properly awaited, ensuring reliable test execution.
180-183
: LGTM! Async operations properly handled for modal interactionThe type and click events are correctly awaited before checking the modal state.
224-225
: LGTM! Proper async handling for post creation flowThe user interactions are correctly awaited, and the subsequent wait ensures the mutation completes before assertions.
Line range hint
1-272
: Great job updating the test file for @testing-library/user-event v14!The changes consistently apply the async/await pattern required by the new version. The test coverage is comprehensive, covering both success and error scenarios. The modifications improve test reliability by properly handling asynchronous user interactions.
src/components/ProfileDropdown/ProfileDropdown.spec.tsx (6)
135-138
: LGTM! Proper async handling of user events.The changes correctly await the user interactions, which is required for
@testing-library/user-event
v14.
159-163
: LGTM! Proper async handling of user events in routing test.The changes correctly await the user interactions and are properly wrapped in
act()
.
195-200
: LGTM! Proper async handling in error test case.The changes correctly await the user interactions and maintain proper error handling test flow.
231-235
: LGTM! Proper async handling in navigation test.The changes correctly await the user interactions and maintain proper navigation test flow.
259-263
: LGTM! Proper async handling in non-user role navigation test.The changes correctly await the user interactions and maintain proper navigation test flow.
287-291
: LGTM! Proper async handling in non-user role navigation test with orgId.The changes correctly await the user interactions and maintain proper navigation test flow.
src/screens/UserPortal/Volunteer/Actions/Actions.spec.tsx (5)
182-182
: LGTM! Correctly addedawait
for userEvent callsThe changes properly handle async user interactions as required by @testing-library/user-event v14.
Also applies to: 186-186, 188-188
206-206
: LGTM! Correctly addedawait
for userEvent callsThe changes properly handle async user interactions as required by @testing-library/user-event v14.
Also applies to: 210-210, 212-212
243-243
: LGTM! Correctly addedawait
for userEvent callsThe changes properly handle async user interactions as required by @testing-library/user-event v14.
Also applies to: 249-249
256-256
: LGTM! Correctly addedawait
for userEvent callsThe changes properly handle async user interactions as required by @testing-library/user-event v14.
Also applies to: 262-262
Line range hint
1-264
: Verify all userEvent calls are properly awaitedLet's ensure no userEvent calls were missed in the upgrade.
✅ Verification successful
All userEvent calls in Actions.spec.tsx are properly awaited
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any non-awaited userEvent calls that might have been missed rg "userEvent\.(click|type|keyboard|tab|hover|clear|selectOptions|deselectOptions|upload|paste|clear)" -g "*.{ts,tsx,js,jsx}" | grep -v "await"Length of output: 5168
src/components/RequestsTableItem/RequestsTableItem.spec.tsx (2)
112-112
: LGTM! Properly awaited user interaction.The addition of
await
beforeuserEvent.click
is correct and necessary for version 14.x of @testing-library/user-event.
144-144
: LGTM! Consistent handling of async user interactions.The
await
keyword has been correctly added to alluserEvent.click
calls, ensuring proper handling of asynchronous interactions across all test cases.Let's verify that all userEvent calls in this file are properly awaited:
Also applies to: 176-176, 208-208
✅ Verification successful
All userEvent calls are properly awaited
All userEvent.click() calls in RequestsTableItem.spec.tsx are correctly prefixed with the 'await' keyword, ensuring proper handling of asynchronous interactions.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any userEvent calls that might be missing await rg "userEvent\.(click|type|keyboard|paste|clear|selectOptions|deselectOptions|upload|hover|tab|keyboard)" src/components/RequestsTableItem/RequestsTableItem.spec.tsx | rg -v "await"Length of output: 181
Script:
#!/bin/bash # First verify the file exists echo "Checking file existence:" ls src/components/RequestsTableItem/RequestsTableItem.spec.tsx echo -e "\nAll userEvent calls:" rg "userEvent\." src/components/RequestsTableItem/RequestsTableItem.spec.tsx echo -e "\nChecking for non-awaited userEvent calls:" rg "userEvent\." src/components/RequestsTableItem/RequestsTableItem.spec.tsx | rg -v "await"Length of output: 827
src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.spec.tsx (7)
264-264
: LGTM! Properly awaited user interactionThe
await
keyword has been correctly added to handle the asynchronoususerEvent.click()
in version 14.
285-287
: LGTM! Multiple user interactions properly awaitedBoth language selector clicks are correctly awaited, maintaining proper test flow.
315-317
: LGTM! Language switch interactions properly awaitedThe French language selection clicks are correctly awaited.
339-341
: LGTM! Hindi language selection properly handledThe Hindi language selection clicks are correctly awaited.
363-365
: LGTM! Spanish language selection properly handledThe Spanish language selection clicks are correctly awaited.
387-389
: LGTM! Chinese language selection properly handledThe Chinese language selection clicks are correctly awaited.
517-518
: LGTM! Logout and navigation interactions properly handledThe logout sequence and home navigation clicks are correctly awaited.
Also applies to: 540-540
src/components/UserPortal/ContactCard/ContactCard.spec.tsx (1)
Line range hint
1-32
: Well-structured test setup with comprehensive documentation!The test file has excellent documentation explaining the component's functionality and test coverage. The setup with necessary providers and mocks is also well organized.
src/screens/BlockUser/BlockUser.spec.tsx (5)
355-362
: LGTM! Correctly updated userEvent calls to be asyncThe changes properly handle the async nature of userEvent in v14 by adding
await
to the click interactions.
385-393
: LGTM! Proper async handling of user interactionsThe userEvent calls are correctly awaited, maintaining consistency with the v14 API.
417-436
: LGTM! Comprehensive async handling of user interactionsAll userEvent interactions (click and type) are properly awaited, including the complex scenario with enter key press.
510-518
: LGTM! Proper async handling in error scenariosThe userEvent interactions are correctly awaited, and the error handling using waitFor is appropriate.
Line range hint
1-524
: LGTM! Comprehensive test coverageThe test suite thoroughly covers all major functionality including:
- Block/unblock user operations
- Name filtering (first name and last name)
- Error handling
- UI state verification
The assertions are well-structured and verify both positive and negative cases.
src/components/MemberRequestCard/MemberRequestCard.spec.tsx (1)
113-114
: LGTM! Changes are consistent.The addition of
await
for user events matches the pattern in the first test case, maintaining consistency throughout the file.src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx (2)
75-75
: LGTM! Properly awaited user interaction.The change correctly adds
await
touserEvent.click()
, which is required for the new version of@testing-library/user-event
.
150-156
: Simplify error case test wait calls.Similar to the previous segment, there are unnecessary
wait()
calls that can be simplified. Additionally, this error case test could be enhanced to verify the error handling.await userEvent.click(getByTestId('language-dropdown-btn')); - await wait(); const changeLanguageBtnHi = getByTestId(`change-language-btn-hi`); - await wait(); expect(changeLanguageBtnHi).toBeInTheDocument(); - await wait(); await userEvent.click(changeLanguageBtnHi); + // Add error case verification + expect(/* error state or message */).toBeInTheDocument();Let's verify if error handling has been implemented in the component:
src/screens/EventVolunteers/Volunteers/Volunteers.spec.tsx (3)
224-224
: LGTM! Proper async handling for user inputThe addition of
await
foruserEvent.type()
correctly handles the asynchronous nature of user interactions in v14, and the subsequentdebounceWait
ensures reliable testing of debounced search functionality.
264-267
: LGTM! Correct async handling for modal interactionsThe addition of
await
for both click operations ensures proper sequencing of modal interactions in the upgraded library version.
278-281
: LGTM! Consistent async handling for delete modalThe changes maintain consistency with the modal interaction pattern and properly implement v14's async requirements.
src/screens/UserPortal/Events/Events.spec.tsx (3)
542-578
: LGTM! Proper async handling for user interactions.The changes correctly implement the required
await
keywords for userEvent interactions, which is necessary for the upgraded @testing-library/user-event v14+. This ensures reliable test execution by properly waiting for each interaction to complete.
605-624
: LGTM! Proper async handling for all-day event creation test.The changes correctly implement the required
await
keywords for userEvent interactions in the all-day event creation test.
679-679
: LGTM! Proper async handling for DatePicker and TimePicker tests.The changes correctly implement the required
await
keywords for userEvent interactions in the date/time picker tests.Also applies to: 713-713, 751-751, 763-763
src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.spec.tsx (5)
205-207
: LGTM! Proper async handling for user interaction.The addition of
await
foruserEvent.click
is correct and necessary for the new version of@testing-library/user-event
.
245-246
: LGTM! Proper async handling for text input.The addition of
await
foruserEvent.type
is correct and necessary for the new version.
Line range hint
270-275
: LGTM! Proper async handling for remove button click.The async handling for the remove operation is implemented correctly.
288-291
: LGTM! Proper async handling with toast spy verification.The async handling in the failure case is correct, with proper error toast verification.
Line range hint
1-292
: Consider initializing userEvent instance.With
@testing-library/user-event
v14+, it's recommended to initialize a user instance before tests.Add this setup at the beginning of each test:
+ const user = userEvent.setup(); - await userEvent.click(screen.getByTestId('saveChangesBtn')); + await user.click(screen.getByTestId('saveChangesBtn'));This ensures proper cleanup and consistent behavior across tests.
Let me verify if other test files in the codebase follow this pattern:
src/screens/Requests/Requests.spec.tsx (3)
182-182
: LGTM! Good test coverageThe test properly simulates realistic user typing behavior including corrections using backspace.
186-186
: LGTM! Comprehensive input testingGood coverage of complex user input patterns with multiple corrections.
189-189
: LGTM! Good edge case coverageTest effectively covers additional input patterns.
src/components/OrgAdminListCard/OrgAdminListCard.spec.tsx (1)
92-92
: LGTM! Proper async handlingThe async/await usage with userEvent.click is correct and follows best practices.
src/screens/EventVolunteers/Volunteers/VolunteerDeleteModal.spec.tsx (1)
102-102
: LGTM! Consistent async handling across test casesThe async/await usage with userEvent.click is consistent and correct across all test cases, properly integrated with waitFor assertions.
Also applies to: 117-117, 130-130
src/screens/EventVolunteers/Volunteers/VolunteerCreateModal.spec.tsx (1)
98-98
: LGTM! Proper async handling for form submissionThe async/await usage with userEvent.click for form submission is correct and properly integrated with waitFor assertions.
Also applies to: 123-123
src/components/UserPasswordUpdate/UserPasswordUpdate.spec.tsx (1)
51-62
: Form interaction changes follow best practices!The changes correctly implement async user events for form interactions while maintaining proper test structure.
Also applies to: 84-84, 101-113, 134-146, 164-176
src/components/LeftDrawer/LeftDrawer.spec.tsx (1)
105-105
: LGTM! Proper async handling of user interactions.The changes correctly await the userEvent.click operations, which is required for @testing-library/user-event v14+.
Also applies to: 111-111, 218-218
src/screens/OrgSettings/OrgSettings.spec.tsx (2)
116-127
: LGTM! Proper async handling of tab interactions.The changes correctly await the userEvent.click operations for tab switching.
Line range hint
136-179
: Address commented-out test case.Either implement the dropdown test case or remove it to maintain clean code. The commented code contains proper async handling but is currently inactive.
Would you like me to help implement this test case or should it be removed?
src/components/OrgSettings/AgendaItemCategories/AgendaCategoryUpdateModal.spec.tsx (1)
68-68
: LGTM! Proper async handling of modal close.The changes correctly await the userEvent.click operation for the close button.
Also applies to: 90-92
src/components/AddOn/core/AddOnRegister/AddOnRegister.spec.tsx (3)
123-127
: LGTM! Proper async handling for user interactions.The addition of
await
for userEvent calls ensures reliable test execution by properly waiting for the completion of user interactions.
157-160
: LGTM! Consistent async handling in test cases.The test properly awaits all user interactions, including clicking buttons and typing into input fields. This ensures that the test waits for each action to complete before proceeding.
Also applies to: 161-168, 169-169
194-197
: LGTM! Well-structured async test flow.The test case properly handles the asynchronous nature of user interactions and maintains a clear sequence of operations.
Also applies to: 198-205, 206-206
src/screens/UserPortal/People/People.spec.tsx (3)
186-186
: LGTM! Proper async handling for search input.The addition of
await
ensures that the typing operation is completed before the test continues.
208-212
: LGTM! Well-structured search button test.The test properly awaits both the typing and click operations, ensuring reliable test execution.
234-236
: LGTM! Proper async handling for mode changes.The test correctly awaits the mode change operations, ensuring that the UI updates are completed before assertions.
src/screens/EventVolunteers/Requests/Requests.spec.tsx (2)
161-161
: LGTM! Proper async handling for search input.The test correctly awaits the typing operation before proceeding with the debounce wait.
197-197
: LGTM! Consistent async handling across request actions.The tests properly await the click operations for accept and reject actions, ensuring reliable test execution.
Also applies to: 214-214, 231-231
src/screens/EventManagement/EventManagement.spec.tsx (2)
86-86
: LGTM! Proper async handling for navigation tests.The tests correctly await the back button click operations before checking navigation results.
Also applies to: 100-100, 115-115
160-160
: LGTM! Proper async handling for tab switching.The test correctly awaits the tab button click operations.
src/components/EventRegistrantsModal/AddOnSpotAttendee.spec.tsx (1)
134-137
: LGTM! Changes align with @testing-library/user-event v13+ requirements.The addition of
await
beforeuserEvent
calls is correct and necessary. Starting from v13, all user event methods return promises and must be awaited. This change improves test reliability by properly handling the asynchronous nature of simulated user interactions.Also applies to: 165-168, 186-189, 239-240
src/screens/OrganizationFunds/OrganizationFunds.spec.tsx (1)
126-126
: LGTM! Proper handling of asynchronous user events.The addition of
await
beforeuserEvent.click
calls is correct and necessary for compatibility with @testing-library/user-event v13+.Also applies to: 131-131, 147-147, 154-154
src/screens/UserPortal/Volunteer/Groups/Groups.spec.tsx (1)
191-191
: LGTM! Well-structured async event handling with debounce.The changes correctly implement:
- Awaiting user events for v13+ compatibility
- Proper combination of async user events with debounce utility
- Consistent error handling pattern
Also applies to: 195-195, 197-197, 214-214, 218-218, 221-221, 258-258, 261-263, 273-273, 276-276
src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.spec.tsx (2)
173-173
: LGTM! Proper async event handling implementation.The changes correctly implement awaiting user events for compatibility with @testing-library/user-event v13+.
Also applies to: 176-178, 191-191, 196-198, 212-213, 227-227, 241-241
Line range hint
1-50
: Excellent test documentation!The comprehensive JSDoc documentation at the start of the file is a great practice. It clearly outlines the test coverage areas and helps other developers understand the test suite's scope.
src/components/AddPeopleToTag/AddPeopleToTag.spec.tsx (1)
164-164
: LGTM! The changes correctly handle async user events.The addition of
await
touserEvent
calls aligns with the breaking changes introduced in @testing-library/user-event v13+, where all user events became asynchronous.Also applies to: 169-169, 176-176, 181-181, 287-287, 303-303, 308-308, 313-313, 315-315
src/screens/UserPortal/Volunteer/Groups/GroupModal.spec.tsx (1)
148-148
: LGTM! The changes correctly handle async user events.The addition of
await
touserEvent
calls aligns with the breaking changes introduced in @testing-library/user-event v13+, where all user events became asynchronous.Also applies to: 157-157, 169-169, 178-178, 190-190, 194-194, 218-218, 248-248, 261-261, 270-270, 289-289, 312-312
src/screens/Leaderboard/Leaderboard.spec.tsx (1)
257-257
: LGTM! The changes correctly handle async user events and debouncing.The addition of
await
touserEvent
calls aligns with the breaking changes introduced in @testing-library/user-event v13+. The use ofdebounceWait
after the type event is a good practice for handling search input debouncing.Also applies to: 274-274
src/screens/SubTags/SubTags.spec.tsx (1)
Line range hint
149-360
: LGTM! Changes align with @testing-library/user-event v14 requirements.All
userEvent
method calls have been correctly updated to useawait
, which is required after upgrading to @testing-library/user-event v14 where these methods became asynchronous.src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategory.spec.tsx (1)
Line range hint
149-345
: LGTM! All userEvent calls are properly awaited.The changes correctly implement the asynchronous nature of userEvent methods in v14.
src/screens/CommunityProfile/CommunityProfile.spec.tsx (1)
Line range hint
1-1
: Summary of Review FindingsThe changes are part of upgrading @testing-library/user-event from v12.8.3 to v14.5.2, where all user event methods became asynchronous. While most changes correctly add the required
await
statements, a few instances were missed:
- In
src/components/OrgSettings/General/OrgUpdate/OrgUpdate.spec.tsx
:
- Missing
await
foruserEvent.selectOptions()
anduserEvent.upload()
in two test cases- In
src/screens/CommunityProfile/CommunityProfile.spec.tsx
:
- Missing
await
foruserEvent.upload()
Please add the missing
await
statements to ensure all asynchronous user event methods are properly handled.References:
src/screens/ForgotPassword/ForgotPassword.spec.tsx (1)
181-186
: LGTM! Changes align with @testing-library/user-event v14 requirements.The addition of
await
to all userEvent calls is correct and necessary. Starting from v13, all user interactions in @testing-library/user-event became asynchronous and must be awaited. This change improves test reliability by ensuring proper sequencing of events.Also applies to: 214-235, 261-282, 308-329, 351-356, 374-374, 398-402, 434-454
src/screens/UserPortal/Campaigns/Campaigns.spec.tsx (1)
220-224
: LGTM! Proper handling of asynchronous user interactions.The addition of
await
to userEvent.click calls ensures proper test execution order and aligns with @testing-library/user-event v14's asynchronous API.Also applies to: 246-250, 272-276, 298-302
src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.spec.tsx (1)
330-330
: LGTM! Proper async handling in navigation tests.The addition of
await
to userEvent.click calls in navigation tests ensures proper sequencing and aligns with @testing-library/user-event v14's asynchronous API.Also applies to: 352-352
src/screens/FundCampaignPledge/FundCampaignPledge.spec.tsx (1)
138-143
: LGTM! Proper async handling in pledge management tests.The addition of
await
to userEvent.click calls ensures proper test execution order and aligns with @testing-library/user-event v14's asynchronous API.Also applies to: 154-159, 170-175, 244-257, 274-281
src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx (1)
371-371
: LGTM! Changes align with @testing-library/user-event v14 requirements.The addition of
await
touserEvent.click()
calls is correct, as all user event methods became asynchronous in v14.Also applies to: 394-394
src/screens/UserPortal/Posts/Posts.spec.tsx (1)
312-312
: LGTM! Proper handling of async user events.The addition of
await
to alluserEvent
method calls is correct and necessary for v14 compatibility.Also applies to: 330-330, 334-334, 343-343, 374-374, 376-376
src/components/AgendaCategory/AgendaCategoryContainer.spec.tsx (1)
119-121
: LGTM! Comprehensive async handling for user events.The changes correctly implement async handling for all userEvent methods as required by v14.
Also applies to: 128-130, 157-159, 166-168, 195-197, 210-210, 217-217, 228-230, 237-239, 268-270, 276-276, 279-279, 284-284, 315-317, 325-326, 331-331, 360-362, 375-375, 383-383, 412-414, 427-427, 434-434
src/components/AgendaItems/AgendaItemsContainer.spec.tsx (1)
125-125
: LGTM! Proper async handling implemented.The changes correctly implement async handling for all userEvent methods as required by v14.
Also applies to: 132-132, 159-161, 168-168, 195-197, 210-212, 219-219, 230-232, 239-239, 268-268, 276-276, 279-279, 284-284, 313-313, 321-322, 327-327, 356-358, 371-373, 381-381, 410-412, 425-427, 434-434
src/screens/MemberDetail/MemberDetail.spec.tsx (1)
168-204
: LGTM! Proper handling of async user interactions.The changes correctly add
await
to alluserEvent
method calls, which is required for @testing-library/user-event v14+. This ensures that user interactions (typing, clicking) are properly awaited before proceeding with subsequent assertions.Also applies to: 206-211, 271-274, 382-389, 404-406
src/screens/OrganizationEvents/OrganizationEvents.spec.tsx (1)
217-225
: LGTM! Proper async handling in modal interactions.The changes correctly add
await
to alluserEvent
interactions, ensuring proper handling of modal operations and form submissions.Also applies to: 257-275, 287-290, 304-305, 387-392
src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx (1)
250-253
: LGTM! Proper async handling in tab switching.The changes correctly add
await
touserEvent
interactions for tab switching operations.Also applies to: 274-274
src/screens/ManageTag/ManageTag.spec.tsx (1)
131-137
: LGTM! Comprehensive async handling in modal and navigation operations.The changes correctly add
await
to alluserEvent
interactions, ensuring proper handling of modal operations, navigation, and form submissions.Also applies to: 154-161, 177-185, 202-210, 226-233, 248-255, 270-270, 285-285, 302-302, 317-317, 370-375, 387-392, 441-443, 460-473, 490-492
src/components/UserPortal/CommentCard/CommentCard.spec.tsx (1)
226-226
: LGTM! Proper handling of async user events.The addition of
await
beforeuserEvent.click()
calls aligns with the @testing-library/user-event v14 API, where all user event methods return promises. This change ensures proper test execution by waiting for the click events to complete before proceeding.Also applies to: 272-272, 305-305, 338-338, 378-378, 419-419, 460-460, 504-504, 544-544, 587-587
src/screens/UserPortal/Organizations/Organizations.spec.tsx (1)
383-383
: LGTM! Proper async handling in user interaction tests.The addition of
await
beforeuserEvent
methods ensures proper handling of asynchronous user interactions in the test cases, aligning with @testing-library/user-event v14's promise-based API.Also applies to: 389-389, 412-412, 414-414, 439-439, 441-441, 486-486, 488-488, 568-568
src/screens/UserPortal/Settings/Settings.spec.tsx (1)
257-257
: LGTM! Proper async handling in form interaction tests.The addition of
await
beforeuserEvent
methods ensures proper handling of asynchronous form interactions, aligning with @testing-library/user-event v14's promise-based API.Also applies to: 259-259, 263-263, 271-271, 273-273, 286-286, 313-313, 315-315, 346-346, 348-348, 350-391, 421-421, 433-433, 434-434
src/screens/OrgList/OrgList.spec.tsx (1)
119-119
: LGTM! Proper async handling in organization management tests.The addition of
await
beforeuserEvent
methods ensures proper handling of asynchronous interactions in the test cases, aligning with @testing-library/user-event v14's promise-based API.Also applies to: 141-141, 240-284, 315-315, 348-391, 421-421, 433-433, 434-434, 455-455, 456-456, 480-480, 481-481
src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx (1)
Line range hint
106-732
: LGTM! Properly awaited all user events.The changes correctly implement the async/await pattern required by @testing-library/user-event v14.x. All userEvent.click() and userEvent.type() calls are properly awaited, ensuring reliable test execution.
src/components/Advertisements/Advertisements.spec.tsx (1)
414-414
:⚠️ Potential issueAdd await before userEvent.selectOptions call.
For consistency with @testing-library/user-event v14.x, the selectOptions call should be awaited:
- userEvent.selectOptions( + await userEvent.selectOptions( screen.getByLabelText('Select type of Advertisement'), 'POPUP', );Likely invalid or redundant comment.
src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx (1)
Line range hint
356-598
: LGTM! Properly awaited all user events.The changes correctly implement the async/await pattern required by @testing-library/user-event v14.x. All userEvent interactions are properly awaited.
src/components/RecurrenceOptions/CustomRecurrence.spec.tsx (1)
Line range hint
103-732
: LGTM! All other user events are properly awaited.Apart from the forEach loops, all other changes correctly implement the async/await pattern required by @testing-library/user-event v14.x.
src/components/OrgPostCard/OrgPostCard.spec.tsx (1)
Line range hint
167-754
: LGTM! Proper handling of async user events.The addition of
await
touserEvent.click
calls is correct, asuserEvent
methods return promises in v14+. This change ensures proper handling of asynchronous user interactions in tests.src/components/UserPortal/EventCard/EventCard.spec.tsx (1)
139-139
: LGTM! Proper async handling.The addition of
await
touserEvent.click
is correct and consistent with the rest of the test file's async handling.src/screens/OrganizationTags/OrganizationTags.spec.tsx (7)
122-122
: LGTM! Correctly awaited user interactionsThe addition of
await
for the click events is necessary for the upgraded user-event v14, as all user interactions are now async.Also applies to: 129-129
143-143
: LGTM! Properly handled async navigation testThe click event is correctly awaited and followed by appropriate navigation validation.
158-158
: LGTM! Correctly implemented async navigation testThe click event is properly awaited and followed by appropriate navigation validation.
228-228
: Same improvement applies hereThese sort interactions would benefit from the helper function suggested above.
Also applies to: 233-233
280-280
: LGTM! Proper async handling of form validationThe click events are correctly awaited and the error validation is properly implemented.
Also applies to: 282-282
Line range hint
1-300
: Overall test implementation looks goodThe changes correctly implement async handling for all user interactions as required by @testing-library/user-event v14. The test coverage is comprehensive, though there are some opportunities for minor improvements in code organization and error case coverage.
288-293
: Consider adding error case for duplicate tag namesWhile the success case is well tested, consider adding a test case for duplicate tag names to ensure proper error handling.
✅ Verification successful
Consider adding error case for duplicate tag names
The component already has error handling infrastructure in place through the GraphQL mutation's try-catch block, which displays server-side validation errors. Adding a test case for duplicate tag names would improve test coverage and validate this error handling path.
Relevant locations:
src/screens/OrganizationTags/OrganizationTags.tsx:179-186
: Error handling block that would catch and display duplicate tag errorssrc/screens/OrganizationTags/OrganizationTags.spec.tsx:288-293
: Current test location where duplicate tag test should be added🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if duplicate tag name validation exists in the component rg -A 5 "duplicate.*tag|tag.*duplicate" src/screens/OrganizationTags/Length of output: 71
Script:
#!/bin/bash # Search for error handling in tag creation rg -A 5 "createTag.*catch|handleCreateTag.*error" src/screens/OrganizationTags/ # Search for error toast or messages rg -A 5 "showError.*tag|error.*toast.*tag" src/screens/OrganizationTags/ # Search for validation logic in tag creation ast-grep --pattern 'const handleCreateTag = async $_$ => { $$$ }'Length of output: 226
Script:
#!/bin/bash # Get the component implementation cat src/screens/OrganizationTags/OrganizationTags.tsx # Search for any error handling or toast notifications rg "toast|error|catch" src/screens/OrganizationTags/OrganizationTags.tsxLength of output: 15910
src/screens/OrganizationPeople/OrganizationPeople.spec.tsx (2)
831-832
: The userEvent upgrades look good!The changes correctly implement async/await with userEvent interactions, which is required for the upgrade to
@testing-library/user-event@14.5.2
. This will make the tests more reliable by properly handling the asynchronous nature of user interactions.Also applies to: 836-836, 843-846, 922-925, 928-931, 982-985, 988-991
Line range hint
1231-1235
: Uncomment and fix the table fetching assertions.There's a commented assertion block with a TODO note about table fetching functionality. This suggests incomplete test coverage for an important feature.
Please verify if the table fetching functionality is now fixed and uncomment these assertions:
✅ Verification successful
Uncomment the test assertions - table fetching is implemented
The table fetching functionality appears to be properly implemented using MUI's DataGrid component in
OrganizationPeople.tsx
. The commented test assertions can now be uncommented as the underlying functionality is in place.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check if table fetching functionality is implemented # Look for table-related components and their implementations rg -l "table|Table|Grid" --type ts --type tsxLength of output: 75
Script:
#!/bin/bash # Search for table-related components and implementations rg -t ts -t typescript -l "table|Table|Grid" # Look for similar test patterns in spec files rg -t ts -t typescript "getByText.*toBeInTheDocument" -C 2 "*.spec.ts*" # Check for data fetching implementations rg -t ts -t typescript "fetch.*table|loadTable|getTable" -C 2Length of output: 289
Script:
#!/bin/bash # Find TypeScript files and search for table-related patterns fd -e ts -e tsx | xargs rg "table|Table|Grid" # Look for test assertions in spec files fd -e ts -e tsx -g "*spec*" | xargs rg "getByText.*toBeInTheDocument" -C 2 # Check the specific file for context around the commented code rg -C 5 "table.*fecthing" src/screens/OrganizationPeople/OrganizationPeople.spec.tsxLength of output: 92626
src/screens/OrgPost/OrgPost.test.tsx (3)
231-233
: Well-implemented async user interactionsThe addition of
await
to userEvent operations is correct and aligns with the upgrade to @testing-library/user-event v14. This ensures proper handling of asynchronous user interactions and prevents race conditions in tests.Also applies to: 240-243, 247-247, 270-273, 276-276
Line range hint
603-632
: Good use of act for async operationsThe test case properly wraps async operations in
act
and awaits userEvent operations, which is the correct approach for handling asynchronous state updates in React tests.
Line range hint
382-390
: Add assertions for refetch functionalityThe test "After creating a post, the data should be refetched" is missing assertions to verify that the refetch actually occurred.
Consider adding assertions to verify the refetch operation:
await userEvent.click(screen.getByTestId('createPostBtn')); await wait(); + // Verify that the refetch operation was triggered + expect(refetchMock).toHaveBeenCalledTimes(1); + + // Verify that the new post appears in the list + const posts = screen.getAllByTestId('post-item'); + expect(posts).toHaveLength(MOCKS[0].result.data.organizations[0].posts.edges.length + 1);src/screens/LoginPage/LoginPage.spec.tsx (1)
306-306
: Properly awaited userEvent calls after upgrading to v14The changes correctly add
await
before all userEvent calls, which is required after upgrading to @testing-library/user-event v14. This ensures proper handling of asynchronous user interactions.Also applies to: 380-380, 384-402, 428-428, 432-449, 475-475, 477-495, 521-521, 523-541, 567-567, 568-586, 610-612, 637-643, 671-671, 673-691, 718-724, 751-754, 775-775, 782-785, 806-806, 813-816, 857-862, 889-894, 921-928, 953-962, 994-994, 1084-1084
@@ -101,7 +101,7 @@ describe('Testing ContactCard Component [User Portal]', () => { | |||
|
|||
await wait(); | |||
|
|||
userEvent.click(screen.getByTestId('contactContainer')); | |||
await userEvent.click(screen.getByTestId('contactContainer')); |
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.
💡 Codebase verification
Non-awaited userEvent calls found across test files
The codebase contains multiple instances where userEvent methods are not properly awaited. According to @testing-library/user-event v13+, all user event methods return promises and must be awaited to prevent race conditions and flaky tests.
Key locations requiring fixes:
src/screens/UserPortal/Settings/Settings.spec.tsx
: Multiple non-awaitedselectOptions
andupload
callssrc/screens/OrgPost/OrgPost.test.tsx
: Several non-awaitedupload
callssrc/components/UsersTableItem/UserTableItem.spec.tsx
: Non-awaitedselectOptions
callssrc/screens/MemberDetail/MemberDetail.spec.tsx
: Multiple non-awaitedclear
calls
Each userEvent call should be awaited, for example:
await userEvent.clear(input);
await userEvent.selectOptions(select, value);
await userEvent.upload(input, files);
🔗 Analysis chain
Correctly updated userEvent calls to handle async behavior.
The changes properly adapt to the breaking changes introduced in @testing-library/user-event v13+, where all user event methods return promises that must be awaited.
Let's verify if all userEvent calls across the codebase have been properly awaited:
Also applies to: 129-129
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Find potentially missed async userEvent calls
# Pattern: looking for userEvent calls that aren't awaited
# Search for userEvent calls without await
echo "Searching for non-awaited userEvent calls..."
rg "userEvent\.(click|type|keyboard|paste|clear|selectOptions|deselectOptions|upload|hover|tab|keyboard)" -g "*.{ts,tsx,js,jsx}" | grep -v "await.*userEvent"
Length of output: 5283
await userEvent.type(searchBar, 'Dummy{enter}'); | ||
await wait(); | ||
userEvent.clear(searchBar); | ||
userEvent.type(searchBar, 'Dummy'); | ||
userEvent.click(searchBtn); | ||
await userEvent.type(searchBar, 'Dummy'); | ||
await userEvent.click(searchBtn); | ||
await wait(); | ||
userEvent.clear(searchBar); | ||
userEvent.type(searchBar, ''); | ||
userEvent.click(searchBtn); | ||
await userEvent.type(searchBar, ''); | ||
await userEvent.click(searchBtn); |
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.
Add missing await statements for userEvent.clear()
The clear() method in @testing-library/user-event v14 is async and should be awaited.
Apply this diff to fix the async handling:
await userEvent.type(searchBar, 'Dummy{enter}');
await wait();
- userEvent.clear(searchBar);
+ await userEvent.clear(searchBar);
await userEvent.type(searchBar, 'Dummy');
await userEvent.click(searchBtn);
await wait();
- userEvent.clear(searchBar);
+ await userEvent.clear(searchBar);
await userEvent.type(searchBar, '');
await userEvent.click(searchBtn);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
await userEvent.type(searchBar, 'Dummy{enter}'); | |
await wait(); | |
userEvent.clear(searchBar); | |
userEvent.type(searchBar, 'Dummy'); | |
userEvent.click(searchBtn); | |
await userEvent.type(searchBar, 'Dummy'); | |
await userEvent.click(searchBtn); | |
await wait(); | |
userEvent.clear(searchBar); | |
userEvent.type(searchBar, ''); | |
userEvent.click(searchBtn); | |
await userEvent.type(searchBar, ''); | |
await userEvent.click(searchBtn); | |
await userEvent.type(searchBar, 'Dummy{enter}'); | |
await wait(); | |
await userEvent.clear(searchBar); | |
await userEvent.type(searchBar, 'Dummy'); | |
await userEvent.click(searchBtn); | |
await wait(); | |
await userEvent.clear(searchBar); | |
await userEvent.type(searchBar, ''); | |
await userEvent.click(searchBtn); |
await userEvent.click(addVolunteerBtn); | ||
|
||
expect(await screen.findAllByText(t.addVolunteer)).toHaveLength(2); | ||
userEvent.click(await screen.findByTestId('modalCloseBtn')); | ||
await userEvent.click(await screen.findByTestId('modalCloseBtn')); |
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.
💡 Codebase verification
Missing await
operators for userEvent calls across test suite
Multiple test files contain non-awaited userEvent calls which is required for v14 compatibility. This can lead to race conditions and flaky tests.
Key files requiring updates:
src/components/UsersTableItem/UserTableItem.spec.tsx
src/components/Venues/VenueModal.spec.tsx
src/components/OrgSettings/General/OrgUpdate/OrgUpdate.spec.tsx
src/screens/UserPortal/Settings/Settings.spec.tsx
src/screens/OrgPost/OrgPost.test.tsx
- And several others
All userEvent method calls (click, type, selectOptions, upload, clear, etc.) should be awaited.
🔗 Analysis chain
LGTM! Proper async handling for create modal
The changes correctly implement v14's async requirements while maintaining consistency with other modal tests.
Let's verify if all userEvent calls across the test suite have been properly updated:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining non-awaited userEvent calls
rg "userEvent\.(click|type|keyboard|tab|hover|clear|selectOptions|deselectOptions|upload|paste|clear)" -g "*.{spec,test}.{ts,tsx,js,jsx}" | grep -v "await"
Length of output: 5180
await userEvent.type(screen.getByTestId(/searchByName/i), search5); | ||
userEvent.clear(screen.getByTestId(/searchByName/i)); | ||
userEvent.type(screen.getByTestId(/searchByName/i), ''); | ||
userEvent.click(searchBtn); | ||
await userEvent.type(screen.getByTestId(/searchByName/i), ''); | ||
await userEvent.click(searchBtn); |
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.
Add missing await for userEvent.clear
While most user events are properly awaited, the userEvent.clear()
call on line 193 should also be awaited in @testing-library/user-event v14.
Apply this change:
- userEvent.clear(screen.getByTestId(/searchByName/i));
+ await userEvent.clear(screen.getByTestId(/searchByName/i));
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
await userEvent.type(screen.getByTestId(/searchByName/i), search5); | |
userEvent.clear(screen.getByTestId(/searchByName/i)); | |
userEvent.type(screen.getByTestId(/searchByName/i), ''); | |
userEvent.click(searchBtn); | |
await userEvent.type(screen.getByTestId(/searchByName/i), ''); | |
await userEvent.click(searchBtn); | |
await userEvent.type(screen.getByTestId(/searchByName/i), search5); | |
await userEvent.clear(screen.getByTestId(/searchByName/i)); | |
await userEvent.type(screen.getByTestId(/searchByName/i), ''); | |
await userEvent.click(searchBtn); |
await userEvent.type(screen.getByTestId(/searchByName/i), search1); | ||
await userEvent.click(searchBtn); |
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.
💡 Codebase verification
Missing await
operators on userEvent calls across test files
Multiple test files, including the one under review, have userEvent calls that are not properly awaited. This needs to be fixed as part of the @testing-library/user-event v14 upgrade:
- In
src/screens/Requests/Requests.spec.tsx
: Missing await onuserEvent.clear()
- Similar issues found in 15+ other test files, particularly with
userEvent.clear()
anduserEvent.upload()
🔗 Analysis chain
LGTM! Correctly awaited user events
The addition of await
operators is necessary for the upgraded @testing-library/user-event v14, as all user events are now async.
Let's verify all userEvent calls are properly awaited:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Find any userEvent calls that might be missing await
rg "userEvent\.(type|click|keyboard|clear|hover|tab|paste|upload)" -g "*.{ts,tsx,js,jsx}" | grep -v "await"
Length of output: 3679
@@ -203,7 +203,7 @@ describe('Event Management', () => { | |||
expect(dropdownContainer).toBeInTheDocument(); | |||
|
|||
await act(async () => { | |||
userEvent.click(screen.getByTestId('tabsDropdownToggle')); | |||
await userEvent.click(screen.getByTestId('tabsDropdownToggle')); |
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.
🛠️ Refactor suggestion
Improve act wrapper usage in dropdown tests.
While the async handling is correct, the usage of act
wrapper is inconsistent. Consider refactoring to use a consistent pattern:
- act(async () => {
- await userEvent.click(screen.getByTestId(`${option}DropdownItem`));
- });
+ await act(async () => {
+ await userEvent.click(screen.getByTestId(`${option}DropdownItem`));
+ });
This change ensures that all state updates and effects are properly flushed before continuing with the test.
Also applies to: 229-229, 243-244
await userEvent.type(name, formData.name); | ||
await userEvent.type(des, formData.description); | ||
await userEvent.type(city, formData.address.city); | ||
userEvent.selectOptions(countryCode, formData.address.countryCode); | ||
userEvent.type(line1, formData.address.line1); | ||
userEvent.type(line2, formData.address.line2); | ||
userEvent.type(postalCode, formData.address.postalCode); | ||
userEvent.type(dependentLocality, formData.address.dependentLocality); | ||
userEvent.type(sortingCode, formData.address.sortingCode); | ||
await userEvent.type(line1, formData.address.line1); | ||
await userEvent.type(line2, formData.address.line2); | ||
await userEvent.type(postalCode, formData.address.postalCode); | ||
await userEvent.type(dependentLocality, formData.address.dependentLocality); | ||
await userEvent.type(sortingCode, formData.address.sortingCode); | ||
userEvent.upload(displayImage, formData.displayImage); | ||
userEvent.click(userRegistrationRequired); | ||
userEvent.click(isVisible); | ||
await userEvent.click(userRegistrationRequired); | ||
await userEvent.click(isVisible); | ||
|
||
await wait(); | ||
userEvent.click(saveChangesBtn); | ||
await userEvent.click(saveChangesBtn); |
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.
Add missing await
statements for userEvent calls in error test case.
Similar to the previous test case, two userEvent
method calls are missing the required await
:
userEvent.selectOptions()
on line 241userEvent.upload()
on line 247
Apply this diff to fix the missing await statements:
await userEvent.type(name, formData.name);
await userEvent.type(des, formData.description);
await userEvent.type(city, formData.address.city);
- userEvent.selectOptions(countryCode, formData.address.countryCode);
+ await userEvent.selectOptions(countryCode, formData.address.countryCode);
await userEvent.type(line1, formData.address.line1);
await userEvent.type(line2, formData.address.line2);
await userEvent.type(postalCode, formData.address.postalCode);
await userEvent.type(dependentLocality, formData.address.dependentLocality);
await userEvent.type(sortingCode, formData.address.sortingCode);
- userEvent.upload(displayImage, formData.displayImage);
+ await userEvent.upload(displayImage, formData.displayImage);
await userEvent.click(userRegistrationRequired);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
await userEvent.type(name, formData.name); | |
await userEvent.type(des, formData.description); | |
await userEvent.type(city, formData.address.city); | |
userEvent.selectOptions(countryCode, formData.address.countryCode); | |
userEvent.type(line1, formData.address.line1); | |
userEvent.type(line2, formData.address.line2); | |
userEvent.type(postalCode, formData.address.postalCode); | |
userEvent.type(dependentLocality, formData.address.dependentLocality); | |
userEvent.type(sortingCode, formData.address.sortingCode); | |
await userEvent.type(line1, formData.address.line1); | |
await userEvent.type(line2, formData.address.line2); | |
await userEvent.type(postalCode, formData.address.postalCode); | |
await userEvent.type(dependentLocality, formData.address.dependentLocality); | |
await userEvent.type(sortingCode, formData.address.sortingCode); | |
userEvent.upload(displayImage, formData.displayImage); | |
userEvent.click(userRegistrationRequired); | |
userEvent.click(isVisible); | |
await userEvent.click(userRegistrationRequired); | |
await userEvent.click(isVisible); | |
await wait(); | |
userEvent.click(saveChangesBtn); | |
await userEvent.click(saveChangesBtn); | |
await userEvent.type(name, formData.name); | |
await userEvent.type(des, formData.description); | |
await userEvent.type(city, formData.address.city); | |
await userEvent.selectOptions(countryCode, formData.address.countryCode); | |
await userEvent.type(line1, formData.address.line1); | |
await userEvent.type(line2, formData.address.line2); | |
await userEvent.type(postalCode, formData.address.postalCode); | |
await userEvent.type(dependentLocality, formData.address.dependentLocality); | |
await userEvent.type(sortingCode, formData.address.sortingCode); | |
await userEvent.upload(displayImage, formData.displayImage); | |
await userEvent.click(userRegistrationRequired); | |
await userEvent.click(isVisible); | |
await wait(); | |
await userEvent.click(saveChangesBtn); |
await userEvent.type(name, formData.name); | ||
await userEvent.type(des, formData.description); | ||
await userEvent.type(city, formData.address.city); | ||
userEvent.selectOptions(countryCode, formData.address.countryCode); | ||
userEvent.type(line1, formData.address.line1); | ||
userEvent.type(line2, formData.address.line2); | ||
userEvent.type(postalCode, formData.address.postalCode); | ||
userEvent.type(dependentLocality, formData.address.dependentLocality); | ||
userEvent.type(sortingCode, formData.address.sortingCode); | ||
await userEvent.type(line1, formData.address.line1); | ||
await userEvent.type(line2, formData.address.line2); | ||
await userEvent.type(postalCode, formData.address.postalCode); | ||
await userEvent.type(dependentLocality, formData.address.dependentLocality); | ||
await userEvent.type(sortingCode, formData.address.sortingCode); | ||
userEvent.upload(displayImage, formData.displayImage); | ||
userEvent.click(userRegistrationRequired); | ||
userEvent.click(isVisible); | ||
await userEvent.click(userRegistrationRequired); | ||
await userEvent.click(isVisible); | ||
|
||
await wait(); | ||
userEvent.click(saveChangesBtn); | ||
await userEvent.click(saveChangesBtn); |
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.
Add missing await
statements for userEvent calls.
Two userEvent
method calls are missing the required await
:
userEvent.selectOptions()
on line 154userEvent.upload()
on line 161
These methods are asynchronous in @testing-library/user-event v14 and should be awaited.
Apply this diff to fix the missing await statements:
await userEvent.type(city, formData.address.city);
- userEvent.selectOptions(countryCode, formData.address.countryCode);
+ await userEvent.selectOptions(countryCode, formData.address.countryCode);
await userEvent.type(line1, formData.address.line1);
await userEvent.type(line2, formData.address.line2);
await userEvent.type(postalCode, formData.address.postalCode);
await userEvent.type(dependentLocality, formData.address.dependentLocality);
await userEvent.type(sortingCode, formData.address.sortingCode);
- userEvent.upload(displayImage, formData.displayImage);
+ await userEvent.upload(displayImage, formData.displayImage);
await userEvent.click(userRegistrationRequired);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
await userEvent.type(name, formData.name); | |
await userEvent.type(des, formData.description); | |
await userEvent.type(city, formData.address.city); | |
userEvent.selectOptions(countryCode, formData.address.countryCode); | |
userEvent.type(line1, formData.address.line1); | |
userEvent.type(line2, formData.address.line2); | |
userEvent.type(postalCode, formData.address.postalCode); | |
userEvent.type(dependentLocality, formData.address.dependentLocality); | |
userEvent.type(sortingCode, formData.address.sortingCode); | |
await userEvent.type(line1, formData.address.line1); | |
await userEvent.type(line2, formData.address.line2); | |
await userEvent.type(postalCode, formData.address.postalCode); | |
await userEvent.type(dependentLocality, formData.address.dependentLocality); | |
await userEvent.type(sortingCode, formData.address.sortingCode); | |
userEvent.upload(displayImage, formData.displayImage); | |
userEvent.click(userRegistrationRequired); | |
userEvent.click(isVisible); | |
await userEvent.click(userRegistrationRequired); | |
await userEvent.click(isVisible); | |
await wait(); | |
userEvent.click(saveChangesBtn); | |
await userEvent.click(saveChangesBtn); | |
await userEvent.type(name, formData.name); | |
await userEvent.type(des, formData.description); | |
await userEvent.type(city, formData.address.city); | |
await userEvent.selectOptions(countryCode, formData.address.countryCode); | |
await userEvent.type(line1, formData.address.line1); | |
await userEvent.type(line2, formData.address.line2); | |
await userEvent.type(postalCode, formData.address.postalCode); | |
await userEvent.type(dependentLocality, formData.address.dependentLocality); | |
await userEvent.type(sortingCode, formData.address.sortingCode); | |
await userEvent.upload(displayImage, formData.displayImage); | |
await userEvent.click(userRegistrationRequired); | |
await userEvent.click(isVisible); | |
await wait(); | |
await userEvent.click(saveChangesBtn); |
weekDaysOptions.forEach(async (weekDay) => { | ||
await userEvent.click(weekDay); | ||
}); | ||
|
||
weekDaysOptions.forEach((weekDay) => { | ||
userEvent.click(weekDay); | ||
weekDaysOptions.forEach(async (weekDay) => { | ||
await userEvent.click(weekDay); |
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.
Refactor forEach loops to properly handle async operations.
The current implementation using async/await within forEach might not work as expected. Use Promise.all with map instead:
- weekDaysOptions.forEach(async (weekDay) => {
- await userEvent.click(weekDay);
- });
-
- weekDaysOptions.forEach(async (weekDay) => {
- await userEvent.click(weekDay);
- });
+ await Promise.all(
+ weekDaysOptions.map((weekDay) => userEvent.click(weekDay))
+ );
+
+ await Promise.all(
+ weekDaysOptions.map((weekDay) => userEvent.click(weekDay))
+ );
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
weekDaysOptions.forEach(async (weekDay) => { | |
await userEvent.click(weekDay); | |
}); | |
weekDaysOptions.forEach((weekDay) => { | |
userEvent.click(weekDay); | |
weekDaysOptions.forEach(async (weekDay) => { | |
await userEvent.click(weekDay); | |
await Promise.all( | |
weekDaysOptions.map((weekDay) => userEvent.click(weekDay)) | |
); | |
await Promise.all( | |
weekDaysOptions.map((weekDay) => userEvent.click(weekDay)) | |
); |
await userEvent.type(screen.getByTestId('modalinfo'), formData.postinfo); | ||
userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage); | ||
userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo); | ||
userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage); | ||
userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo); |
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.
🛠️ Refactor suggestion
Add await to userEvent.upload calls
The userEvent.upload operations should be awaited for consistency with other userEvent operations and to ensure proper test execution order.
- userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage);
- userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo);
- userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage);
- userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo);
+ await userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage);
+ await userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo);
+ await userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage);
+ await userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
await userEvent.type(screen.getByTestId('modalinfo'), formData.postinfo); | |
userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage); | |
userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo); | |
userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage); | |
userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo); | |
await userEvent.type(screen.getByTestId('modalinfo'), formData.postinfo); | |
await userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage); | |
await userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo); | |
await userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage); | |
await userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo); |
What kind of change does this PR introduce?
This PR upgrades the @testing-library/user-event package from version 12.8.3 to 14.5.2 to resolve dependency issues, align with the latest features, and improve stability.
Issue Number:
Fixes #2072
Did you add tests for your changes?
Yes, existing tests were updated to comply with the new syntax and methods introduced in the upgraded version. Additional tests were added where necessary.
Snapshots/Videos:
Not applicable as this change primarily involves a dependency upgrade and test adjustments.
If relevant, did you update the documentation?
No updates were necessary for documentation as this is a dependency change that does not impact external documentation.
Summary
Upgraded @testing-library/user-event to 14.5.2.
Updated test cases to reflect new syntax and features.
Verified all tests pass to ensure compatibility.
Removed any redundant imports and resolved circular dependencies as per the release notes.
Does this PR introduce a breaking change?
No, this change does not introduce breaking changes to the application itself. It updates internal testing dependencies, ensuring they function correctly.
Other information
Release notes for 14.5.2 indicate resolved bugs, added named exports, and type improvements that enhance compatibility and developer experience.
Have you read the contributing guide?
Yes, I have reviewed and followed the contributing guidelines.
Summary by CodeRabbit
Summary by CodeRabbit
Based on the comprehensive summary, here are the updated release notes:
Dependencies
@testing-library/user-event
from^12.1.10
to^14.5.2
@testing-library/dom
at version^10.4.0
Testing Improvements
await
touserEvent.click
anduserEvent.type
calls to improve reliability.These changes focus on refining testing libraries and enhancing the accuracy and reliability of the test suite for user interactions.