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

Tests break when ActionList item prop is active #11871

Open
nattydodd opened this issue Apr 9, 2024 · 1 comment
Open

Tests break when ActionList item prop is active #11871

nattydodd opened this issue Apr 9, 2024 · 1 comment
Labels
Bug Something is broken and not working as intended in the system. untriaged

Comments

@nattydodd
Copy link

nattydodd commented Apr 9, 2024

Summary

We've noticed an error in our tests of a component that is using ActionList (see screenshot). It seems to be attributed to this line of code.
It fails any time one of our ActionList items has {active: true}

ActionList-error

Expected behavior

Tests should not fail

Actual behavior

Test fails with error scrollArea.current?.scrollTo is not a function

Steps to reproduce

  1. Create a component that uses an ActionList
  2. In the items prop, define one of the items as {active: true}
  3. Write a test for the component, and trigger the ActionList to open
  4. See error in the test: scrollArea.current?.scrollTo is not a function

Are you using React components?

None

Polaris version number

^12.23.0

Browser

N/A

Device

N/A

@nattydodd nattydodd added Bug Something is broken and not working as intended in the system. untriaged labels Apr 9, 2024
@nattydodd
Copy link
Author

Update - it seems that adding the following fixes the tests:

beforeEach(() => {
    if (!('scrollTo' in Element.prototype)) {
      (Element.prototype as Element).scrollTo = () => {};
    }
  });

I did have to do quite some digging to figure that out. If its not possible to prevent this issue, maybe the test workaround could be documented somewhere so its easier for others to find :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken and not working as intended in the system. untriaged
Projects
None yet
Development

No branches or pull requests

1 participant