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

feat: update react & react-dom to v17 #758

Merged
merged 19 commits into from
Oct 3, 2023

Conversation

BilalQamar95
Copy link
Contributor

@BilalQamar95 BilalQamar95 commented Jun 9, 2023

Ticket

Upgrade React JS to v17

Description

  • Updated react & react-dom to v17 along with react-test-renderer, react-helmet & @testing-library/react to respective compatible versions
  • Since Enzyme does not provide support React 17 (enzymejs/enzyme#2429) or 18 (enzymejs/enzyme#2524) itself we switched to community-supported project that aim to provide compatibility between Enzyme and React 17, replacing enzyme-adapter-react-16 with @wojtekmaj/enzyme-adapter-react-17
  • Updated edx packages @edx/frontend-platform, @edx/frontend-build, @edx/frontend-enterprise
  • Replaced react-truncate with react-lines-ellipsis Paragon's Truncate due to dependency issues with react v17

With react-truncate

Screenshot 2023-07-12 at 3 12 11 PM

With Paragon's Truncate

Screenshot 2023-07-12 at 3 12 55 PM

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Attention: 66 lines in your changes are missing coverage. Please review.

Comparison is base (d36b78a) 84.87% compared to head (1f74a39) 85.05%.
Report is 65 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #758      +/-   ##
==========================================
+ Coverage   84.87%   85.05%   +0.18%     
==========================================
  Files         320      324       +4     
  Lines        6399     6698     +299     
  Branches     1552     1623      +71     
==========================================
+ Hits         5431     5697     +266     
- Misses        941      970      +29     
- Partials       27       31       +4     
Files Coverage Δ
src/components/course/CourseContextProvider.jsx 100.00% <100.00%> (ø)
src/components/course/CourseMainContent.jsx 100.00% <ø> (ø)
src/components/course/CoursePage.jsx 93.75% <100.00%> (ø)
src/components/course/CourseRecommendationCard.jsx 96.00% <100.00%> (+0.16%) ⬆️
src/components/course/CourseSidebar.jsx 100.00% <100.00%> (ø)
src/components/course/CourseSidebarListItem.jsx 100.00% <ø> (ø)
src/components/course/EnrollModal.jsx 93.54% <100.00%> (ø)
src/components/course/VerifiedCertPitch.jsx 100.00% <ø> (ø)
...c/components/course/course-header/CourseHeader.jsx 100.00% <100.00%> (ø)
.../components/course/course-header/CourseRunCard.jsx 100.00% <100.00%> (ø)
... and 107 more

... and 3 files with indirect coverage changes

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

@BilalQamar95 BilalQamar95 changed the title Bilalqamar95/react upgrade to v17 feat: update react & react-dom to v17 Jul 25, 2023
@BilalQamar95 BilalQamar95 marked this pull request as ready for review July 25, 2023 09:48
package.json Outdated
"react-instantsearch-dom": "6.38.1",
"react-lines-ellipsis": "0.15.3",
Copy link
Member

Choose a reason for hiding this comment

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

Would recommend trying to use Paragon's Truncate component, if possible, rather than relying on a new third-party library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure that's better, I have replaced it with Paragon's Truncate

@@ -81,7 +77,7 @@ describe('<SearchProgramCard />', () => {
const { container } = renderWithRouter(<SearchProgramCardWithAppContext {...defaultProps} />);

expect(screen.getByText(PROGRAM_TITLE)).toBeInTheDocument();
expect(screen.getByText(PROGRAM_AUTHOR_ORG.key)).toBeInTheDocument();
expect(screen.getAllByText(PROGRAM_AUTHOR_ORG.key).length).toBeGreaterThan(0);
Copy link
Member

Choose a reason for hiding this comment

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

[curious] Can you explain the rationale for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test was failing after switch to react-lines-ellipsis, as the text within the "LinesEllipsis" component is being broken into multiple parts and being rendered multiple times in the view. This is no longer an issue after switch to Paragon Truncate & I have reverted the change.

Explanation: react-lines-ellipsis employs multiple hidden nodes to calculate which parts of the text to show or hide. It breaks down the text into smaller units uses this to determine the ellipsis effect. This was resulting in multiple parts of the DOM containing the same text string, which is why getByText was throwing an error as it was finding multiple instances of the expected text.

@@ -145,7 +140,7 @@ describe('<SearchProgramCard />', () => {

expect(screen.getByText(PROGRAM_TITLE)).toBeInTheDocument();
expect(screen.getByAltText(PROGRAM_AUTHOR_ORG.name)).toBeInTheDocument();
expect(screen.getByText(PROGRAM_AUTHOR_ORG.name)).toBeInTheDocument();
expect(screen.getAllByText(PROGRAM_AUTHOR_ORG.name).length).toBeGreaterThan(0);
Copy link
Member

Choose a reason for hiding this comment

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

[curious] Can you explain the rationale for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test was failing after switch to react-lines-ellipsis, as the text within the "LinesEllipsis" component is being broken into multiple parts and being rendered multiple times in the view. This is no longer an issue after switch to Paragon Truncate & I have reverted the change.

Explanation: react-lines-ellipsis employs multiple hidden nodes to calculate which parts of the text to show or hide. It breaks down the text into smaller units uses this to determine the ellipsis effect. This was resulting in multiple parts of the DOM containing the same text string, which is why getByText was throwing an error as it was finding multiple instances of the expected text.

Copy link
Contributor

@katrinan029 katrinan029 left a comment

Choose a reason for hiding this comment

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

LGTM! Checked out your branch and ran the app locally and it's working as expected. Just a couple of nits but nothing blocking.
[nit]: The description is showing the UI with react-truncate -- can we replace that with Paragon's Truncate component instead?
[nit]: I think we can also remove @fortawesome/react-fontawesome from the description since we're no longer using that dependency.

@BilalQamar95 BilalQamar95 merged commit 548a4c5 into master Oct 3, 2023
5 checks passed
@BilalQamar95 BilalQamar95 deleted the bilalqamar95/react-upgrade-to-v17 branch October 3, 2023 06:20
@jmbowman jmbowman mentioned this pull request Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants