phetsims / a11y-research

a repository to track PhETs research into accessibility, or "a11y" for short
MIT License
3 stars 0 forks source link

Add unit tests for generating PDOM #98

Closed samreid closed 6 years ago

samreid commented 6 years ago

There are a few other issues for automated a11y testing, such as #96 and its related issues, however, I did not see any issues about unit tests for the generated PDOM. For example, the a11y documentation has this example:

        var a11yNode = new scenery.Rectangle( 0, 0, 64, 64, {
          fill: 'blue',

          // a11y
          tagName: 'p',
          innerContent: 'I am a beautiful, blue rectangle.'
        } );
        scene.addChild( a11yNode );
        display.updateOnRequestAnimationFrame();

and says it should yield this PDOM

<div class="accessibility">
<p tabindex="-1" id="2-11">I am a beautiful, blue rectangle.
</p>
</div>

For any parts of this that are non-transient, such as the tagName and innerContent, it would be nice to capture the desired behavior in qunit tests that run automatically on Bayes CT. This would be applicable to the main part, description, label, container, and for more complex trees.

These tests will help us identify/guarantee correct behavior, help us safely refactor, catch problems earlier, etc.

Assigned to @jessegreenberg for discussion.

jessegreenberg commented 6 years ago

Sorry I couldn't find an issue either @samreid, but we do have tests like this already. Behavior of the Accessibility trait is verified with AccessibilityTests.js, and is run as part of Bayes CT. There are tests for PDOM output, setting of a11y attributes, focus management, a11y input listeners, and so on. Is this what you had in mind?

samreid commented 6 years ago

That looks perfect, thanks!