Problem/Motivation

When Simpletest module is enabled, the big list of tests (at admin/config/development/testing) offers a text input to filter tests by name. When using this, the list shrinks dynamically. The change is easily noted visually, but is not conveyed to users with screen readers.

Proposed resolution

Use Drupal.announce() to convey a short message about the number of tests now present in the filtered list.

We already make such use of Drupal.announce() in similar filter UIs. Follow the approach found in:

  • The modules list (see core/modules/system/js/system.modules.js)
  • The block list (see core/modules/block/js/block.admin.js)

Note: a debounce() is required to prevent too many updates and decrease the amount of announcements to a minimum.

Remaining tasks

This is basically a repeat of the approach we took in #2805205: Provide screen-reader feedback when filtering by block name..

  • Devise the announcement string(s). Suggested: "6 tests are available in the modified list."
  • Update simpletest.js and simpletest.es6.js to use Drupal.announce(), handling singular/plural results with Drupal.formatPlural().
  • Update simpletest.libraries.yml. This needs a dependency on core/Drupal.announce().
  • Manual testing:
    • Use browser developer tools (e.g. firebug) to watch the content of div#drupal-live-announce. It lives near the bottom of the HTML document, just before the closing body tag. A screenshot of the HTML with the correct message would be useful evidence of testing.
    • Alternatively, use the Devel accessibility module, which logs Drupal.announce() messages to the browser's dev tools console. Again, this is good for a screenshot.
    • Testing with an actual screen reader is also recommended. Some screen readers have a visible caption window (e.g. macOS VoiceOver calls this the caption panel). This also makes good screenshot evidence.
  • Automated tests (FunctionalJavascript):
    • Confirm the updated content of div#drupal-live-announce with JavascriptTestBase, for zero, singular, and plural result counts.
    • Follow the approach in /core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php.

User interface changes

  • No visible changes intended.
  • Add a screen reader announcement to convey updates which are currently only apparent visually.
  • Introduces a new translatable string for Drupal.announce().

API changes

None expected.

Data model changes

None expected.

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

Issue tags: +Novice

I think this would be OK for a novice. Mostly it's a copy-paste job of what we did in #2805205: Provide screen-reader feedback when filtering by block name..

If you want a mentor, get in touch via the contact form tab on my user profile, or say hello in the #accessibility channel of Drupal Slack community, or just say so here.

andrewmacpherson’s picture

Issue summary: View changes

Minor updates to the plan.

andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

Issue summary: View changes
erik.erskine’s picture

Assigned: Unassigned » erik.erskine

Going to take a look at this today. Some mentoring would be appreciated - thanks!

erik.erskine’s picture

Status: Active » Needs review
FileSize
6.25 KB
171.89 KB

I've attached a patch that follows the approach suggested. Using the Devel accessibility module, the results are shown in the browser's console (see screenshot).

Yet to verify this with VoiceOver.

The test takes a very long time to complete (15 min compared to 1 min for an empty test). I think that's down to the number of rows in the table - around 3000. Does that matter?

andrewmacpherson’s picture

Thanks for the patch Erik. This looks like it's doing the right thing from the screenshot. I'll give it a detailed look myself, and run tests locally.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

+1 nice to have accessibility and also nice to have any kind of test on the filtering.

The test is taking a reeeely long time, so we have to figure out how to fix that. It's ~20-30 seconds per request to render that form...

time says: 546.77 real 52.01 user 4.34 sys

Also we have a deprecation roadmap for simpletest: #2866082: [plan] Roadmap for Simpletest

andrewmacpherson’s picture

Version: 8.5.x-dev » 8.4.x-dev
Assigned: erik.erskine » Unassigned
Category: Feature request » Bug report
Issue tags: +wcag, +wcag21

Since we're now actively pursuing WCAG 2.1, I'm reclassifying this as a bug report.

It relates to the new WCAG 2.1 "Change of Content" success criterion. Under WCAG 2.0 the announcement was a nice-to-have, but under WCAG 2.1 it becomes a must-have. For a longer explanation, see #2864791-33: Implement new Success Criteria from WCAG 2.1.

andrewmacpherson’s picture

andrewmacpherson’s picture

Issue tags: -Novice

Removing the novice tag; the test time quirk sounds tricky.

mgifford’s picture

This looks good to me. You have to install the Testing module first, but after that it gives the expected results at the bottom of the search results.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

drpal’s picture

Version: 8.5.x-dev » 8.6.x-dev
+++ b/core/modules/simpletest/simpletest.es6.js
@@ -99,6 +99,16 @@
+        function announceTableLength() {
+          Drupal.announce(
+            Drupal.formatPlural(
+              $table.find('tr:visible').length - 1,
+              '1 test is available in the modified list.',
+              '@count tests are available in the modified list.'
+            )
+          );
+        }

Missing trailing comma.

drpal’s picture

Status: Needs review » Needs work
Mile23’s picture

See also: #2893117: Improve HTML caching of Simpletest UI test form which can help with test run time (and general performance).

Mile23’s picture

+++ b/core/modules/simpletest/tests/src/FunctionalJavascript/SimpletestFilterTest.php
@@ -0,0 +1,95 @@
+  protected function setUp() {

This test could mock the test_discovery service to return a known set of results. Mock TestDiscovery::getTestClasses(). The benefits would be no file scan, and no dependency on the number or names of tests displayed.