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

chore(compass-components): update LeafyGreen packages, update table usage COMPASS-7046 #5400

Merged
merged 44 commits into from
Mar 27, 2024

Conversation

Anemy
Copy link
Member

@Anemy Anemy commented Jan 30, 2024

COMPASS-7046

This pr updates our LeafyGreen dependencies to latest. The bulk of the changes are in the new table adoption, mostly for indexes.

The only visual changes here are in the Indexes tab where we've removed the card. The new table has a few smaller visual changes too.

before after
Screenshot 2024-01-30 at 4 56 33 PM Screenshot 2024-01-30 at 4 38 38 PM

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need to maintain our fork?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a good question, I'm not sure currently. If it's alright with you I'd like to do that (if an investigation shows we can remove it) as a follow up pr. I don't think it impacts these changes so it should be something we can handle independently.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think it's fine to keep it for the update in this PR, but would be really really nice to figure out if we can finally remove it, not the best thing to maintain on our own in the repo 😅

@Anemy
Copy link
Member Author

Anemy commented Mar 4, 2024

Going to freeze this for the time being. The main remaining issue is a matter of fixing or working around how tabbable interacts with elements in jsdom in our tests so they pass, then we're good to merge once we fix any leftover e2e tests that might need updated selectors.

The issue with tabbable is that when we upgrade our LeafyGreen dependencies we get a new version of focus-trap-react and focus-trap which use a new version of tabbable. This newer version of tabbable fails to tab to a focusable element in our mocha tests because of lack of jsdom support. The line that errors is here: https://github.com/focus-trap/focus-trap/blob/0881d9ea9a087fd3ecc97f32e406926c69aaabaf/index.js#L397

The issue is described in tabbable's README: https://github.com/focus-trap/tabbable?tab=readme-ov-file#testing-in-jsdom

There are some workarounds we could do, we could:
Skip our GuideQueue tests and FeedbackPopover test that use the focus trap and rely on e2e tests to cover them. Seems like the easiest and most viable.
Somehow fix it upstream and then wait for that to be released and update it in our dependencies and LeafyGreen (would be cool but probably impractical). There are a number of GitHub issues that mention this issue like focus-trap/tabbable#664
Two we probably don't want to do:
Do something similar to the global overwrite suggested in the tabbable README link above for our unit test environments. I'd like to avoid this if possible, it's hacky.
Override the tabbable dependency version to an older one with something like overrides although I don't know how to do this with our lerna package configuration. Also hacky and could lead to issues down the line with dependency management.

Maybe I'm missing something and there's some other fix we can do.

Some other notes:

Looks like the LeafyGreen team also ran into this which caused them to downgrade their focus-trap in the GuideQueue:
https://github.com/mongodb/leafygreen-ui/blob/main/packages/guide-cue/CHANGELOG.md#major-changes

We already workaround this issue in our own FocusTrap usage here:

// Tests fail without a fallback. (https://github.com/focus-trap/focus-trap-react/issues/91)

Interestingly these errors also starts happening locally when I upgrade to node 20+. I'm thinking maybe because something is resolved differently in our dependencies which brings in the newer tabbable version but I'm not sure. So this may become a blocker down the line in more than one way if we don't fix it now.

@Anemy Anemy added the wip label Mar 4, 2024
@Anemy Anemy changed the title chore(compass-components): update LeafyGreen dependencies, update table usage COMPASS-7046 deps(compass-components): update LeafyGreen packages, update table usage COMPASS-7046 Mar 6, 2024
@gribnoysup
Copy link
Collaborator

The only e2e test issue left is that selectbox / combobox is now again unusable in CI for whatever reason, investigating...

@@ -300,6 +300,7 @@ function Connection({
/>
<H3
className={connectionTitleStyles}
as="h3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Question, in which cases do we want to set this as prop? How is it different from just using <H3></H3>?

await browser.clickVisible(
Selectors.createCollectionCustomCollationFieldButton(key)
);
const menu = await browser.$(
const menu = browser.$(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we don't await here anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

browser.$() just wraps the selector into an object you can then chain. so things that actually check things or perform some action on that element only really need the await. But we're not consistent about it at all. See below in this same file where he does const button = await browser.$( 😄

The documentation uses await, so that's probably better: https://webdriver.io/docs/api/browser/$

Copy link
Collaborator

Choose a reason for hiding this comment

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

From the docs:

Note: only use these element objects if you are certain they still exist on the page, e.g. using the isExisting command. WebdriverIO is unable to refetch them given that there are no selector information available.

This script does a bunch of async steps, some of which are happening in a loop with waitUntil, I'd prefer webdriver to always fetch the element before running operations on it instead of failing unexpectedly with "element doesn't exist". This was the flaky part of the test, so I want to make sure it's more stable than before. Other parts of the script here didn't fail, so they are not changed. I don't want to pull more unneccessary changes to this PR. Would you be okay with having a ticket to refactor this later?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not actually sure if you do:

const menuChainablesomething = browser.$(menuSelector)
const menuElement = await menuChainablesomething;

Is the element now cached on menuChainablesomething or only on menuElement? Just thinking out load. This kind of ambiguity (menuChainablesomething is both a promise and.. something?) is why I usually try and not keep that object around. But I don't think I've been very consistent about it. We definitely cache element objects in various places where we shouldn't. I've tried to reuse a selector before or wrap getting the menuElement (or that other intermediate promise-like object) in a get function. Maybe not necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

side-note: I don't find their documentation very clear here. There are two types in play: ChainablePromiseElement<WebdriverIO.Element> and WebdriverIO.Element and I think it could be clearer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to make sure the context didn't get lost in private messages, I did a test and indeed stuff changed over time and the chainable caches the values after initial call. The wdio documentation still suggests to not await on element before using commands, but for different reasons: mostly just due to this being unneccessary

…re tab state hooks is better adapted for testing env
@gribnoysup gribnoysup force-pushed the COMPASS-7046-lg-bump branch from 2ca98e2 to 560d55f Compare March 26, 2024 09:39
@gribnoysup gribnoysup merged commit 833f22d into main Mar 27, 2024
16 checks passed
@gribnoysup gribnoysup deleted the COMPASS-7046-lg-bump branch March 27, 2024 11:29
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