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

[A11y] Render aria-label as text in the icon testenv file #5709

Merged
merged 6 commits into from
Mar 14, 2022

Conversation

yuliacech
Copy link
Contributor

@yuliacech yuliacech commented Mar 10, 2022

Summary

Similar to #5702 , this PR updates the testenv file for EuiIcon that renders a mock version of EuiIcon. The current mock attaches aria-label as attribute to a span element that is rendered instead of an icon. This causes a11y violations in Kibana (see elastic/kibana#127185). I'm suggesting rendering aria-label as text if present.

Checklist

I don't think any of the items in the checklist are applicable because this PR only touches the mock file.

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in Chrome, Safari, Edge, and Firefox
- [ ] Props have proper autodocs and playground toggles
- [ ] Added documentation
- [ ] Checked Code Sandbox works for any docs examples
- [ ] Added or updated jest and cypress tests
- [ ] Checked for breaking changes and labeled appropriately
- [ ] Checked for accessibility including keyboard-only and screenreader modes

  • A changelog entry exists and is marked appropriately

@yuliacech yuliacech marked this pull request as ready for review March 10, 2022 17:36
@yuliacech yuliacech changed the title Testenv icon aria label [A11y] Render aria-label as text in the icon testenv file Mar 10, 2022
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5709/

Copy link
Member

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

LGTM! Cool solution for this test mock (rendering the label as text)!

@cee-chen
Copy link
Member

Re: CI failures - it looks like you'll want to run yarn test-unit -u to update all our various snapshots. It shouldn't take super long to run all our Jest tests, fingers crossed

@yuliacech
Copy link
Contributor Author

Thanks a lot for the review, @constancecchen! And for the snaphots update tip 🎉

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5709/

@yuliacech yuliacech merged commit c7b8818 into elastic:main Mar 14, 2022
breehall added a commit to elastic/kibana that referenced this pull request Mar 24, 2022
…ing for strict text equality to account for text coming from the EuiScreenReaderOnly component. Also updated tests to account for EuiIcon text that is now rendered when the icon is imported from .testenv (PR 5709 - elastic/eui#5709).
@thompsongl
Copy link
Contributor

@yuliacech What's the axe violation this was solving?

@cee-chen
Copy link
Member

This is the error:

aria-label attribute is not well supported on a span with no valid role attribute.

So one very easy alternative (if this is causing too much downstream Kibana snapshot churn) to this PR would be to add role="img" to our testenv mock instead of rendering the ariaLabel as text.

@thompsongl
Copy link
Contributor

thompsongl commented Mar 28, 2022

That seems like a better solution. The real component would render <img> or <svg> so that's closer to reality than a <span> with coerced text (probably should've been that way when the .testenv. file was first created)

@yuliacech
Copy link
Contributor Author

@thompsongl @constancecchen Yes, the violation was about having an aria-label on a span element. An img element might be a better alternative, but the change would still cause Kibana snapshot updates 😓

@thompsongl
Copy link
Contributor

Thanks, @yuliacech

This is less immediate now, but I'm going to plan on exploring the role="img" change. You're right about the snapshot churn; I was more concerned with the type of tests that inspect the rendered text and assert equality. Those are now finding "Info" and "External link" text that is misleading when compared to real environments.

tylersmalley pushed a commit to elastic/kibana that referenced this pull request Mar 29, 2022
* Updgraded EUI packages in package.json and src/dev/license_checker/config.js

* Resolved Jest test failures for Jest test suites 1 and 2. Updated snapshots, and updated equality conditions for specific test cases

* Resolve Jest test cases for Jest test suite 3. Updated snapshots for required tests

* type fixes

* Resolved failing Jest test cases in Jest suite 3. Updated tests checking for strict text equality to account for text coming from the EuiScreenReaderOnly component. Also updated tests to account for EuiIcon text that is now rendered when the icon is imported from .testenv (PR 5709 - elastic/eui#5709).

* eui to 52.2.0

* Resolved test cases for Jest test suites 1 and 2. Updated required snapshots.
Updated tests using getAllByLabelText and getByLabelText to getAllByText and getByText respectively as the former have been deprecated

* Updated Jest tests for Jest test suites 5 and 6. Updated required snapshots. Updated instances of getByLabelText and getAllByLabelText to getByText and getAllByText as the former are now deprecated.

* Updated Jest tests for Jest test suite 7. Updated required snapshots.

* Completed test case revisions for Jest test suites 1, 3, 6, 7, and 8. Updated required snapshots. Updated various tests to account for text rendering of the EuiIcon text.

* eui back to v52.2.0

* removed unused test utils

* use .contains for euiicon content

* storyshots updates

* linting

Co-authored-by: Greg Thompson <thompson.glowe@gmail.com>
cee-chen pushed a commit to cee-chen/kibana that referenced this pull request Mar 29, 2022
…ing for strict text equality to account for text coming from the EuiScreenReaderOnly component. Also updated tests to account for EuiIcon text that is now rendered when the icon is imported from .testenv (PR 5709 - elastic/eui#5709).
@cee-chen
Copy link
Member

cee-chen commented Mar 29, 2022

Mentioning for recordkeeping, another example in Kibana of unintentional Jest churn based on tests looking for text content: elastic/kibana@d9fc2a1 - the test failed because it was looking for 1 instance of the passed text in the document and received 2 instead.

We should revert the above commit if we also decide to revert this and use role="img" instead

tylersmalley pushed a commit to elastic/kibana that referenced this pull request Mar 30, 2022
* Updgraded EUI packages in package.json and src/dev/license_checker/config.js

* Resolved Jest test failures for Jest test suites 1 and 2. Updated snapshots, and updated equality conditions for specific test cases

* Resolve Jest test cases for Jest test suite 3. Updated snapshots for required tests

* Resolved failing Jest test cases in Jest suite 3. Updated tests checking for strict text equality to account for text coming from the EuiScreenReaderOnly component. Also updated tests to account for EuiIcon text that is now rendered when the icon is imported from .testenv (PR 5709 - elastic/eui#5709).

* type fixes

* eui to 52.2.0

* Resolved test cases for Jest test suites 1 and 2. Updated required snapshots.
Updated tests using getAllByLabelText and getByLabelText to getAllByText and getByText respectively as the former have been deprecated

* Updated Jest tests for Jest test suites 5 and 6. Updated required snapshots. Updated instances of getByLabelText and getAllByLabelText to getByText and getAllByText as the former are now deprecated.

* Updated Jest tests for Jest test suite 7. Updated required snapshots.

* Completed test case revisions for Jest test suites 1, 3, 6, 7, and 8. Updated required snapshots. Updated various tests to account for text rendering of the EuiIcon text.

* removed unused test utils

* use .contains for euiicon content

* storyshots updates

* linting

* Fix failing a11y violations tests

* Fix Jest failures caused by #eui/5709

- these changes should be reverted if we opt to revert the above PR

Co-authored-by: Bree Hall <briannajdhall@gmail.com>
Co-authored-by: Greg Thompson <thompson.glowe@gmail.com>
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