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

Is uniqueId in TableHeader for aria-describedby and id necessary? #7721

Closed
tanoargie opened this issue Feb 2, 2021 · 3 comments · Fixed by #7730
Closed

Is uniqueId in TableHeader for aria-describedby and id necessary? #7721

tanoargie opened this issue Feb 2, 2021 · 3 comments · Fixed by #7730
Assignees

Comments

@tanoargie
Copy link

tanoargie commented Feb 2, 2021

Hi,
First of all, let me apologize if this is neither the place nor the issue type or label for this kind of thing. I tried to place this question in the Discord server but I think this is not available yet.

Whenever you test a snapshot of a mounted component and that component has TableHeader as a child, the test will failed as there is a Math.random() call in TableHeader.js for some props, specifically id and aria-describedby. Obviously you can mock Math.random() and the tests will passed (that's also why I wouldn't consider this a bug), but I wonder if we could add some props for these fields.
The code in question in TableHeader.js is the following:

Screen Shot 2021-02-02 at 15 10 23

Thanks in advance!

@joshblack
Copy link
Contributor

Hi there @francoserio! 👋 Thanks so much for taking the time to make this issue.

I went ahead and opened up a PR for this at #7730. Unfortunately, we do need to generate unique ids for this part of the component but the usage of Math.random is definitely something we can avoid. I went ahead and updated the component to use a more stable identifier, while it still will auto-generate ids it should allow snapshots to stay consistent more easily than Math.random which would trigger them to be out-of-date each time the test is run.

Hope this helps!

@daka1510
Copy link

daka1510 commented Feb 5, 2021

Thanks for bringing this up, @francoserio and the quick action, @joshblack. Because the generated ids are not deterministic and cannot be overriden by the consumer, it is also breaking our snapshot tests and thus the adoption of the latest carbon version.

My understanding of the fix in #7730 is that it will guarantee that the unique ids will stay consistent across different test runs. Will try it when the updated version is released.

@tanoargie
Copy link
Author

tanoargie commented Feb 5, 2021

Awesome @joshblack! (what a quick response). Glad I could be of help @daka1510!
I will update my upstream as soon this is merged!
Thanks to both of you!

@kodiakhq kodiakhq bot closed this as completed in #7730 Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants