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

[core] Replace toBeAriaHidden matcher with toBeInaccessible in tests #43870

Conversation

ZeeshanTamboli
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli commented Sep 24, 2024

toBeAriaHidden is marked as deprecated, so replaced it with toBeInaccessible. This change makes sense since toBeInaccessible checks more than just the aria-hidden attribute — it also accounts for other factors that determine if an element should be excluded from the accessibility tree. It uses the DOM Testing Library's isInaccessible method internally.

Additionally, toBeAriaHidden has been removed from the matchers list since it is not used in MUI X, Toolpad, or Pigment CSS.

@mui-bot
Copy link

mui-bot commented Sep 24, 2024

Netlify deploy preview

https://deploy-preview-43870--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 89451e8

@ZeeshanTamboli ZeeshanTamboli deleted the replace-toBeAriaHidden-with-toBeInaccessible branch September 24, 2024 08:27
@ZeeshanTamboli ZeeshanTamboli restored the replace-toBeAriaHidden-with-toBeInaccessible branch September 27, 2024 04:34
@ZeeshanTamboli ZeeshanTamboli changed the title WIP: Replace toBeAriaHidden with toBeInaccessible [core] Replace toBeAriaHidden matcher with toBeInaccessible Sep 27, 2024
@ZeeshanTamboli ZeeshanTamboli added the core Infrastructure work going on behind the scenes label Sep 27, 2024
@ZeeshanTamboli ZeeshanTamboli marked this pull request as ready for review September 27, 2024 06:01
@ZeeshanTamboli ZeeshanTamboli changed the title [core] Replace toBeAriaHidden matcher with toBeInaccessible [core] Replace toBeAriaHidden matcher with toBeInaccessible in tests Sep 27, 2024
for (let i = 1; i < numberOfChildren; i += 1) {
expect(container2.children[i]).not.toBeAriaHidden();
expect(container2.children[i].getAttribute('aria-hidden')).to.equal(null);
Copy link
Member Author

Choose a reason for hiding this comment

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

Unique case where we cannot use .not.toBeInaccessible assertion. Some elements in the forbidden list like <template>, <script>, <style>, <noscript> etc are implicitly inaccessible in the accessibility tree due to display: 'none' being applied implicitly. Other elements like <map>, <col>, <colgroup> etc are accessible.

Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Makes sense to me 👍

Copy link
Member

@aarongarciah aarongarciah left a comment

Choose a reason for hiding this comment

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

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants