Skip to content
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

test(SideNav): #17491 increased unit test coverage #17869

Merged
merged 14 commits into from
Dec 6, 2024

Conversation

ashna000
Copy link
Contributor

Closes #17491

This PR adds unit tests for the SideNav component to ensure its proper rendering and functionality. These tests ensure that this component renders with the appropriate class names, accommodates custom class names, and correctly applies additional props.

Changelog
Changed

  • Added Unit test file for SideNav.

Testing / Reviewing

  • Run the test suite to ensure that all new tests pass.
  • Review the tests for clarity and coverage.

Additional Notes
Please let me know if any further modifications are needed or if you have any questions regarding the changes.

@ashna000 ashna000 requested a review from a team as a code owner October 24, 2024 12:12
@ashna000 ashna000 requested review from kennylam and guidari October 24, 2024 12:12
Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 0486836
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/6753267b4a00d50008581e42
😎 Deploy Preview https://deploy-preview-17869--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 0486836
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/6753267ba1aa840008cd05ad
😎 Deploy Preview https://deploy-preview-17869--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 0486836
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/6753267b0dadfc00088605d8
😎 Deploy Preview https://deploy-preview-17869--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.06%. Comparing base (5c44a20) to head (0486836).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17869      +/-   ##
==========================================
+ Coverage   83.73%   84.06%   +0.33%     
==========================================
  Files         404      404              
  Lines       14350    14350              
  Branches     4599     4599              
==========================================
+ Hits        12016    12064      +48     
+ Misses       2172     2124      -48     
  Partials      162      162              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ashna000
Copy link
Contributor Author

@kennylam , @guidari Please review this PR

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀
I see that there are couple line that weren't tested, but I guess those lines are not possible to be tested, right?
https://app.codecov.io/gh/carbon-design-system/carbon/pull/17869/blob/packages/react/src/components/UIShell/SideNav.tsx

@ashna000 ashna000 reopened this Oct 30, 2024
@ashna000
Copy link
Contributor Author

@kennylam Please review this PR

@ashna000
Copy link
Contributor Author

ashna000 commented Nov 1, 2024

@alisonjoseph Please review this PR

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ashna000
Looks like the Files changetestd is missing the test file for some reason. Maybe got lost in a commit.

@ashna000
Copy link
Contributor Author

ashna000 commented Nov 8, 2024

Hey @ashna000 Looks like the Files changetestd is missing the test file for some reason. Maybe got lost in a commit.

@guidari @kennylam It seems while updating the branch the test changes got missed. I have updated the tests. Please review.

@guidari
Copy link
Contributor

guidari commented Nov 8, 2024

Hey @ashna000 Do you think you could test the onMouseLeave and onMouseEnter as well?

Example in carbon:

await act(() => {
fireEvent.mouseLeave(
screen.getByRole('menuitem', { name: 'Submenu Submenu' })
);
jest.runOnlyPendingTimers();
});

Example in Stack Overflow: https://stackoverflow.com/questions/75952818/how-to-write-jest-test-case-for-moveover-and-mouseleave-for-functional-component#:~:text=simulate(%27-,mouseleave,-%27)%3B%0A%20%20%20%20expect

Screenshot 2024-11-08 at 16 19 15

Copy link
Member

@ariellalgilmore ariellalgilmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding additional test cases like @guidari suggested

@guidari
Copy link
Contributor

guidari commented Dec 5, 2024

Thanks for adding that @ariellalgilmore 🚀

@2nikhiltom 2nikhiltom disabled auto-merge December 6, 2024 16:14
@2nikhiltom 2nikhiltom enabled auto-merge December 6, 2024 16:43
@2nikhiltom 2nikhiltom added this pull request to the merge queue Dec 6, 2024
Merged via the queue into carbon-design-system:main with commit 224b1e6 Dec 6, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants