fix: updated existing enzyme tests to use react testing library #36303
+11,555
−13,875
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Main changes
BlockBrowserContainer is no longer imported and MockedBlockBrowserContainer is used instead.
The Main component is rendered within a Redux Provider.
Mock props are passed to avoid external dependencies.
selectedBlock="some-selected-block": Indicates that there is a block selected by default.
reportDownloadEndpoint is being configured and used when it was not before.
Drop-down interaction tests
This test suite (Dropdown Interactions) checks the behavior of the dropdown menu in the UI when interacting with it. Two main aspects are tested:
Loading course blocks when opening dropdown menu
The main component is rendered.
Simulate a click on the dropdown menu ('Select a section or issue').
The fetchCourseBlocksMock function is expected to be called once with the courseId and excludedBlockTypes parameters.
Appearance and disappearance of the dropdown
The main component is rendered.
It is verified that the dropdown (container-browser-mock-block) is not visible initially.
A click on the dropdown is simulated and expected to appear with the block navigator class.
Click again and verify that the drop-down menu disappears.
Added the following dependencies:
"@testing-library/react": "^12.1.5":
"@testing-library/jest-dom": "^6.6.3":
"@testing-library/user-event": "^12.8.3",
Uninstalled enzyme dependencies:
"enzyme": "3.11.0",
"react-16-enzyme-adapter": "1.15.8",
"jest-enzyme": "7.1.2",