-
Notifications
You must be signed in to change notification settings - Fork 6
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
562 2 tests #563
base: main
Are you sure you want to change the base?
562 2 tests #563
Conversation
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.
Hey @el-riber, I assume this is the QA testing, I tested your branch and came across the mock error at first in your edit-user-role-page.test.tsx
file like you encountered as well but that error is happening because both of your test.tsx files are at the root level like in this image:
then your edit-user-role-page.test.tsx
file would look like this with the proper fix:
You should put these files in the test/unit directory like in the first image and follow the format, also I'm not sure why there's two form-page.test.tsx
files. they're both the same file so I think you should delete the one at the root level and keep the one in the test directory. You should put the edit-user-role-page.test.tsx
file under the test directory too and follow the format for the other files (by putting each test.tsx
file in their own directory).
once you make these changes you may have to double check the edit-user-role-page.test.tsx file again and correct those two lines again (in the second image) with the proper import format though if you didn't change them then it should be fine.
I will approve once these changes are made, thanks for the work @el-riber
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
|
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.
Good job on utilizing mocks in these tests. I will approve once Ozzie's changes have been addressed. Great catch! @Asfand00 |
This is a pull request!
Subject: Test Implementation for FormPage Component
Test Goals for FormPage:
The goal of these tests was to verify the functionality and behavior of the FormPage component, ensuring a smooth and reliable user experience. The following objectives were targeted:
Rendering Validation:
Confirm that all essential elements of the form (e.g., input fields for Name, Gender, Email, Size, and the Submit button) render correctly and are visible to the user.
User Interaction Testing:
Simulate user input into all form fields to ensure that data is captured correctly.
Validate that the form submission works as expected by checking if the submitted data is logged correctly in the console (mocked for the test).
These tests help ensure that the FormPage works as intended and provides a solid foundation for further development or enhancements.
Let me know if you need further details or improvements!
test:
npm test form-page.test.tsx
Subject: Test Goals for EditUserRolePage Component
Objective: The purpose of the tests for the EditUserRolePage component is to ensure its core functionality works as intended and that different user roles are handled correctly. This includes testing the behavior of the page for admin users and non-admin users, as well as verifying the data flow and error handling.
Test Goals:
Admin User Access:
Verify that admin users can access the EditUserRolePage.
Ensure the UserCard components are correctly displayed with user data fetched from the API.
Non-Admin User Restriction:
Ensure that non-admin users see an UnauthorizedPageMessage and cannot access the admin functionality.
Data Fetching:
Mock the API response to confirm that the user data is fetched and displayed correctly.
Test how the component handles errors or missing tokens during the data-fetching process.
Error Handling:
Ensure the page gracefully handles missing or invalid tokens by rendering the appropriate error message.
Component Integration:
Verify the integration of child components like UserCard and UnauthorizedPageMessage using mocks.
npm test edit-user-role-page.test.tsx
ps: We implemented unit tests for two untested pages:
FormPage
andEditUserRolePage
. The tests focused on ensuring key functionalities worked as expected. ForFormPage
, we tested the rendering of form fields, handling of user inputs, and form submission behavior. ForEditUserRolePage
, we tested role-based access control, verifying that admin users could view and interact with user data while non-admin users were shown an unauthorized message. Challenges included resolving path alias issues for mocking components, which required updates totsconfig.json
andjest.config.js
. Dynamic routing inEditUserRolePage
also posed difficulties, which we addressed by mocking API calls and router behavior. Despite these challenges, the tests were successfully implemented and verified through a detailed pull request, ensuring the functionality of these pages is now well-covered.