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

Add options for testing aria-live announcements #431

Open
Paul-Hebert opened this issue Mar 8, 2022 · 2 comments
Open

Add options for testing aria-live announcements #431

Paul-Hebert opened this issue Mar 8, 2022 · 2 comments
Labels

Comments

@Paul-Hebert
Copy link
Member

Assistive technologies use aria-live regions to announce important content changes to their users.

It would be great if Pleasantest exposed tools to help test aria live announcements. There are two approaches that could work:

Adding a new assertion

Something along these lines:

await expect('Preparing Learning Path').toBeAnnounced();

Adding more info to getAccessibilityTree

Another option would be to expose aria live regions in the accessibility tree. Perhaps by adding (aria-live) after the role or something?

Then in your tests you could check the aria-live region before and after an action and see that the text had changed (And presume it had been announced)

If we went this way should we probably provide info about whether the mode is polite or assertive. In follow-up cards we could also look into supporting aria-atomic, aria-relevant, aria-busy, etc.


I'm not sure which of these I'd prefer from a test writing perspective. It would be awesome to have both options, but that obviously adds complexity. Either one could solve for this use case.

@calebeby
Copy link
Member

calebeby commented Mar 8, 2022

@Paul-Hebert Would this assertion:

await expect('Preparing Learning Path').toBeAnnounced();

pass only if the element with aria-live had just been changed (so that it would be announced)? Or would it pass as long as it has aria-live set?

Maybe another way of asking, if you did this:

await expect('Preparing Learning Path').toBeAnnounced();
await expect('Preparing Learning Path').toBeAnnounced();

Would it only pass if it had been announced twice, or would it pass even if it hadn't been announced (just if it has aria-live)?

@Paul-Hebert
Copy link
Member Author

Or would it pass as long as it has aria-live set?

This seems like it could be misleading to me.

Sometimes UIs need to announce the same message multiple times in a row. This is tricky to do, and it would be nice to be able to confirm it was actually re-announced, and not just still populated with the same text.

Ideally it would only pass if it just changed.

Maybe this could be handled with a spy syntax somehow? (I'm not super familiar with these but have used these to listen for events before. Perhaps we could listen for the content changing?)


Revisiting the a11y tree option: It would be interesting to be able to show whether the value changed recently in tree output. e.g. (aria-live: polite | changed) (or something)

Perhaps the changed attribute could show if the value had changed:

  • Since the last time you checked the a11y tree
  • If you haven't checked the a11y tree yet, then if it has changed since the content first rendered?

(I don't have a sense of how or if this would work in the codebase. Just brainstorming what could be helpful from a dev perspective)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants