testaro 72.3.3 → 72.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "72.3.3",
3
+ "version": "72.4.4",
4
4
  "description": "Run 1300 web accessibility tests from 10 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/testaro/linkUl.js CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  /*
11
11
  linkUl
12
- This test reports failures to underline inline links. Underlining and color are the traditional style properties that identify links. Lists of links containing only links may be recognizable without underlines, but other links are difficult or impossible to distinguish visually from surrounding text if not underlined. Underlining adjacent links only on hover provides an indicator valuable only to mouse users, and even they must traverse the text with a mouse merely to discover which passages are links.
12
+ This test reports failures to underline links that have adjacent text. Underlining and color are the traditional style properties that identify links. A link whose text is the entire text of its block may be recognizable without underlining, but otherwise links are difficult or impossible to distinguish visually from surrounding text if not underlined. Underlining links only on hover provides an indicator valuable only to mouse users, and even they must traverse the text with a mouse merely to discover which passages are links.
13
13
  */
14
14
 
15
15
  // IMPORTS
@@ -21,24 +21,28 @@ const {doTest} = require('../procs/testaro');
21
21
  // Runs the test and returns the result.
22
22
  exports.reporter = async (page, catalog, withItems) => {
23
23
  const getBadWhat = element => {
24
- const liAncestor = element.closest('li');
25
- // If the element is not the only link inside a list item:
26
- if (! (liAncestor && liAncestor.getElementsByTagName('a').length === 1)) {
27
- const styleDec = window.getComputedStyle(element);
28
- const {textDecoration} = styleDec;
29
- // If the element text is not underlined:
30
- if (! textDecoration.includes('underline')) {
31
- const styleDec = window.getComputedStyle(element);
32
- const {display} = styleDec;
33
- // If the element has does not have a block display style:
34
- if (display !== 'block') {
35
- // Return a violation description.
36
- return 'Element is not a list item but is not underlined';
37
- }
24
+ let {display, textDecorationLine} = window.getComputedStyle(element);
25
+ // If the element is not underlined:
26
+ if (! textDecorationLine.includes('underline')) {
27
+ let ancestor = element;
28
+ // Get its closest non-inline ancestor.
29
+ while (display === 'inline') {
30
+ ancestor = ancestor.parentElement;
31
+ display = ancestor ? window.getComputedStyle(ancestor).display : null;
32
+ }
33
+ // Removes superfluous whitespace from a string.
34
+ const compact = string => string?.replace(/\s+/g, ' ')?.trim();
35
+ // If the rendered compacted text of that ancestor includes more than that of the element:
36
+ if (
37
+ compact(element.textContent) !== compact(ancestor?.textContent)
38
+ && compact(element.innerText) !== compact(ancestor?.innerText)
39
+ ) {
40
+ // Return a violation description.
41
+ return 'Element has adjacent text but is not underlined';
38
42
  }
39
43
  }
40
44
  };
41
- const whats = 'Links that are not list items are not underlined';
45
+ const whats = 'Links with adjacent text are not underlined';
42
46
  return await doTest(
43
47
  page, catalog, withItems, 'linkUl', 'body a', whats, 1, getBadWhat.toString()
44
48
  );
package/tests/testaro.js CHANGED
@@ -504,9 +504,14 @@ exports.reporter = async (page, report, actIndex) => {
504
504
  // Wait 1 second to prevent out-of-order logging with granular reporting.
505
505
  await wait(1000);
506
506
  // Get the rules to be tested for and their execution order.
507
+ // 'y' = include-list: run exactly the rules in ruleSpec.slice(1).
508
+ // 'n' = exclude-list: run all defaultOn rules EXCEPT those in ruleSpec.slice(1).
509
+ const excludeIDs = ruleSpec.slice(1);
507
510
  const jobRuleIDs = ruleSpec[0] === 'y'
508
- ? ruleSpec.slice(1)
509
- : allRules.filter(rule => rule.defaultOn && ! allRuleIDs.includes(rule.id));
511
+ ? excludeIDs
512
+ : allRules
513
+ .filter(rule => rule.defaultOn && ! excludeIDs.includes(rule.id))
514
+ .map(rule => rule.id);
510
515
  const jobRules = allRules.filter(rule => jobRuleIDs.includes(rule.id));
511
516
  let justPrevented = false;
512
517
  // For each rule to be tested for: