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

[risk=low][RW-9199] Upgrade React to v17 #7167

Merged
merged 99 commits into from
Jan 20, 2023
Merged

[risk=low][RW-9199] Upgrade React to v17 #7167

merged 99 commits into from
Jan 20, 2023

Conversation

jmthibault79
Copy link
Collaborator

@jmthibault79 jmthibault79 commented Nov 16, 2022

Updated to React 17.
React 17 makes changes to how event delegation works.
This change to event delegation necessitated that we upgrade to at least Prime React 7, because this is the earliest version that handles event delegation in a way that is compatible with React 17.

Updating our version of PrimeReact involved updating the Growl component to the Toast Component, changing how dropdown's attach their options to the dom, and adjusting many tests to account for selector discrepancies.


PR checklist

  • This PR meets the Acceptance Criteria in the JIRA story
  • The JIRA story has been moved to Dev Review
  • This PR includes appropriate unit tests
  • I have added explanatory comments where the logic is not obvious
  • I have run and tested this change locally, and my testing process is described here
  • If this includes a new feature flag, I have created and linked new JIRA tickets to (a) turn on the feature flag and (b) remove it later
  • If this includes an API change, I have run the E2E tests on this change against my local server with yarn test-local because this PR won't be covered by the CircleCI tests
  • If this includes a UI change, I have taken screen recordings or screenshots of the new behavior and notified the PO and UX designer in Slack
  • If this change impacts deployment safety (e.g. removing/altering APIs which are in use) I have documented these in the description
  • If this includes an API change, I have updated the appropriate Swagger definitions and updated the appropriate API consumers

@jmthibault79 jmthibault79 marked this pull request as ready for review November 16, 2022 22:06
ui/yarn.lock Outdated Show resolved Hide resolved
@jmthibault79
Copy link
Collaborator Author

e2e failures make me suspicious that the react-switch change is the problem. I'll try reverting.

Peter-Lavigne
Peter-Lavigne previously approved these changes Nov 17, 2022
@jmthibault79
Copy link
Collaborator Author

our original version of react-switch (4.1.0) continues to work fine here, so hopefully this resolves the e2e failures.

@jmthibault79
Copy link
Collaborator Author

6 e2e failures... trying again but not feeling confident

@jmthibault79
Copy link
Collaborator Author

jmthibault79 commented Nov 17, 2022

4 e2e failures:

3 of

TimeoutError: waiting for XPath `//*[contains(concat(" ", normalize-space(@class), " "), " p-tieredmenu ") or
contains(concat(" ", normalize-space(@class), " "), " p-menu ")][contains(concat(" ", normalize-space(@class), " "), " 
p-menu-overlay-visible ")][.//*[@role="menuitem"]]` failed: timeout 60000ms exceeded

and 1 similar error:

Error: TimeoutError: waiting for XPath `//*[contains(concat(" ", normalize-space(@class), " "), " p-tieredmenu ") or
contains(concat(" ", normalize-space(@class), " "), " p-menu ")][contains(concat(" ", normalize-space(@class), " "), " 
p-menu-overlay-visible ")][.//*[@role="menuitem"]]//*[not(contains(concat(" ", normalize-space(@class), " "), " menuitem-header "))]/*[@role="menuitem" and normalize-space()="Save as"]` failed: timeout 10000ms exceeded

I'm assuming these are real errors, and reverting to Draft

@jmthibault79 jmthibault79 marked this pull request as draft November 17, 2022 17:02
@jmthibault79 jmthibault79 changed the title [risk=low][no ticket] Upgrade React to v17 [risk=low][RW-9199] Upgrade React to v17 Nov 18, 2022
@jmthibault79
Copy link
Collaborator Author

The e2e tests have caught a product failure: the Add Criteria button no longer works with this upgrade.

From some brief debugging, I see that cohort-criteria-menu's onClickOutside() is getting triggered, and this closes the menu immediately after opening it. Why?

@jmthibault79
Copy link
Collaborator Author

@jmthibault79 jmthibault79 mentioned this pull request Dec 2, 2022
10 tasks
@evrii evrii marked this pull request as ready for review January 13, 2023 20:52
* */
await applicationListDropdown.evaluate(b => b.click())
const applicationListDropdown = await page.waitForSelector('#application-list-dropdown')
await applicationListDropdown.click()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is this change applicable elsewhere in e2ev2?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, I do not believe so. It seems like the user-create-test was doing something similar. I ended up switching this to the approach that I found there, and it worked. Keeping that change for consistency.

Copy link
Collaborator Author

@jmthibault79 jmthibault79 left a comment

Choose a reason for hiding this comment

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

Github won't let me Approve because I'm still the author of this PR :)

But everything I've seen makes sense. Thanks for putting in all this work!

When making side-by-side comparisons I do still see some styling differences (though some are improvements) and I have some ideas about how to proceed there, but it's a longer discussion. I would prefer not to merge just yet.

version "16.9.14"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.14.tgz#674b8f116645fe5266b40b525777fc6bb8eb3bcd"
integrity sha512-FIX2AVmPTGP30OUJ+0vadeIFJJ07Mh1m+U0rxfgyW34p3rTlXI+nlenvAxNn4BP36YyI9IJ/+UJ7Wu22N1pI7A==
"@types/react-dom@^17":
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these resolutions are looking much better, thanks

@Peter-Lavigne Peter-Lavigne removed their request for review January 19, 2023 15:33
@jmthibault79 jmthibault79 dismissed Peter-Lavigne’s stale review January 19, 2023 15:44

Peter asked me to do so

Copy link
Contributor

@dmohs dmohs left a comment

Choose a reason for hiding this comment

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

Solid.

@@ -31,8 +31,7 @@ set +e
export FAILED_TESTS_LOG=failed-tests.txt
# This should do the right thing. If $FAILED_TESTS is empty, nothing is specified, so Jest runs
# all tests.
yarn test $FAILED_TESTS \
--reporters=jest-silent-reporter --reporters=./src/failure-reporter.js
Copy link
Contributor

Choose a reason for hiding this comment

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

Failure reporter is needed to ensure re-runs don't run every test again. I think you should revert this and we can isolate it into its own PR.

Comment on lines 42 to 45
await page.waitForFunction(() =>
document.querySelector('[role="button"][aria-label="Next"]').style.cursor !== 'not-allowed')

await page.click( '[role="button"][aria-label="Next"]')
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider:

Suggested change
await page.waitForFunction(() =>
document.querySelector('[role="button"][aria-label="Next"]').style.cursor !== 'not-allowed')
await page.click( '[role="button"][aria-label="Next"]')
await Promise.resolve('[role="button"][aria-label="Next"]').then(sel => {
page.waitForFunction(sel => document.querySelector(sel).style.cursor !== 'not-allowed', sel)
return sel
}).then(sel => page.click(sel))

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like it. Thanks.

@@ -133,6 +133,8 @@ it('should reset role value & options when institution is selected', async () =>
originalEvent: undefined,
value: 'Broad',
target: { name: '', id: '', value: 'Broad' },
stopPropagation: () => {},
preventDefault: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider something like:

const eventDefaults = {stopPropagation: () => undefined, preventDefault: () => undefined}
// ...
institutionDropdown.props.onChange({...eventDefaults,
  originalEvent: undefined,
  value: 'Broad',
  target: { name: '', id: '', value: 'Broad' },
})

@evrii evrii merged commit 1b9d704 into main Jan 20, 2023
@evrii evrii deleted the react-17 branch January 20, 2023 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants