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

Test a few React components #2614

Merged
merged 11 commits into from
Sep 19, 2024
Merged

Conversation

robintown
Copy link
Member

Since so much of this code base is made up React components, we do need to test them, and I wanted to see how easy it would be to get some automated accessibility tests with axe up and running. Along the way I discovered the reason why we were seeing funny errors in our tests (it was because I had turned off Vitest's test isolation option), and the tests I wrote also caught a real accessibility issue in Compound Web.

I had experimented with turning this off in order to improve test performance, and apparently that ended up being merged. Now if we're to do component testing, we'll be changing things globally on the document, so isolation is very much necessary.
This patch release fixes a bug where tooltips would label non-interactive triggers in an inaccessible way.
vitest.config.js Show resolved Hide resolved
src/Modal.tsx Show resolved Hide resolved
Comment on lines 52 to 55
expect(await axe(container)).toHaveNoViolations();
// Name should be visible
screen.getByText("Alice");
},
Copy link
Contributor

Choose a reason for hiding this comment

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

We could add a lot more expectations here:

  • avatar url
  • expanded
  • indicators
    ...

Copy link
Member Author

@robintown robintown Sep 10, 2024

Choose a reason for hiding this comment

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

Right, I've added some more expectations now. I wasn't able to test the specific avatar URL, as that requires a full Matrix client setup, and the indicators are (intentionally, IIRC?) excluded from the accessibility tree. But, there were still some useful things to test, and I actually caught a couple more accessibility issues this way!

src/utils/test.ts Show resolved Hide resolved
Catching two accessibility issues along the way: we were putting the wrong accessible labels on the 'expand' button, and even the off-screen pages of the spotlight tile were being exposed to accessibility technologies rather than hidden.
@robintown robintown mentioned this pull request Sep 12, 2024
@robintown robintown merged commit d12a01b into element-hq:livekit Sep 19, 2024
6 checks passed
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.

2 participants