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

fix: updated existing enzyme tests to use react testing library #36303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jciasenza
Copy link
Contributor

@jciasenza jciasenza commented Feb 26, 2025

Description

This PR replaces Enzyme with React Testing Library (RTL) to improve test reliability and ensure compatibility with React 18. Enzyme is deprecated and no longer recommended for testing React applications.

Changes Made
1 - Replaced Enzyme with RTL – Aligns with modern testing practices.
2 - Mocked BlockBrowserContainer – Improves test isolation by removing external dependencies.
3 - Rendered Main inside a Redux provider – Simulates the application state with mock props.
4 - Added reportDownloadEndpoint prop – Ensures the component receives all necessary props.
5 - Updated dropdown interaction tests:

  • Loading course blocks: Verified fetchCourseBlocksMock is called with courseId and excludedBlockTypes.
  • Dropdown menu visibility: Ensured it appears when clicked and disappears when clicked again.

Other information

Dependencies

  • Added (RTL)
    @testing-library/react@12.1.5
    @testing-library/jest-dom@6.6.3
    @testing-library/user-event@12.8.3

  • Removed (Enzyme)
    enzyme@3.11.0
    react-16-enzyme-adapter@1.15.8
    jest-enzyme@7.1.2

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Feb 26, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @jciasenza!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@brian-smith-tcril
Copy link
Contributor

After reading through the description of this PR, I noticed it only describes the difference between using enzyme and react testing library and a description of what the tests that have been updated are testing.

In my opinion, everything mentioned in the PR description would be covered by simply saying "updated existing enzyme tests to use react testing library."

The code changes in this PR, however, include changes that don't fall into that category - and the PR description does not mention those changes

For example:

  • BlockBrowserContainer is no longer being imported, and instead MockedBlockBrowserContainer is being used.
  • reportDownloadEndpoint is being set and used when it wasn't before.

Would you be able to update the description on this PR to explain why changes like the examples I provided are being made?

There is no need to explain the differences between RTL and enzyme, or why RTL is being used. As a project, we know we want to use RTL so no additional justification is needed.

@jciasenza jciasenza changed the title fix: enzyme testing replaced by react tester fix: updated existing enzyme tests to use react testing library Feb 26, 2025
@jciasenza
Copy link
Contributor Author

@brian-smith-tcril:
I am going over to explain well the steps I have taken so that it is clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: Waiting on Author
Development

Successfully merging this pull request may close these issues.

3 participants