testaro 18.12.0 → 18.13.1

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/README.md CHANGED
@@ -59,20 +59,20 @@ Some of the rules tested by Testaro are based on rules of the [BBC Accessibility
59
59
 
60
60
  ## Rules
61
61
 
62
- Each tool accessed with Testaro defines _rules_ and tests _targets_ for compliance with its rules. The counts of the rules range from about 30, for Testaro itself, to about 270, for Continuum Community Edition. In total, the ten tools define about 1350 rules. Some of the tools are under active development, and their rule counts change over time.
62
+ Each tool accessed with Testaro defines _rules_ and tests _targets_ for compliance with its rules. The counts of the rules range from about 40, for Testaro itself, to about 270, for Continuum Community Edition. In total, the nine tools define about 920 rules. Some of the tools are under active development, and their rule counts change over time.
63
63
 
64
64
  When you ask Testaro to run tests of a tool, you may specify a subset of the rules of that tool, and the report will give you the results of only the tests for those rules. These tools will perform only those tests:
65
- - alfa
66
- - axe
67
- - continuum
68
- - htmlcs
69
- - qualWeb
70
- - testaro
65
+ - `alfa`
66
+ - `axe`
67
+ - `continuum`
68
+ - `htmlcs`
69
+ - `qualWeb`
70
+ - `testaro`
71
71
 
72
72
  These tools always perform a fixed set of tests, and Testaro disregards irrelevant results when you specify a set of rules:
73
- - ibm
74
- - nuVal
75
- - wave
73
+ - `ibm`
74
+ - `nuVal`
75
+ - `wave`
76
76
 
77
77
  ## Job data
78
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "18.12.0",
3
+ "version": "18.13.1",
4
4
  "description": "Run 920 web accessibility tests from 9 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/testaro/zIndex.js CHANGED
@@ -10,68 +10,32 @@
10
10
 
11
11
  // ########## IMPORTS
12
12
 
13
- // Module to get locator data.
14
- const {getLocatorData} = require('../procs/getLocatorData');
13
+ // Module to perform common operations.
14
+ const {init, report} = require('../procs/testaro');
15
15
 
16
16
  // ########## FUNCTIONS
17
17
 
18
+ // Runs the test and returns the result.
18
19
  exports.reporter = async (page, withItems) => {
19
- // Initialize the result.
20
- const data = {};
21
- const totals = [0, 0, 0, 0];
22
- const standardInstances = [];
23
- // Get locators for all eligible elements.
24
- const locAll = page.locator('body *');
25
- const locsAll = await locAll.all();
26
- // For each of them:
27
- for (const loc of locsAll) {
28
- // Get its Z index.
29
- const zIndex = await loc.evaluate(element => {
30
- const styleDec = window.getComputedStyle(element);
31
- return styleDec.zIndex;
20
+ // Initialize the locators and result.
21
+ const all = await init(page, 'body *');
22
+ // For each locator:
23
+ for (const loc of all.allLocs) {
24
+ // Get whether its element violates the rule.
25
+ const badZ = await loc.evaluate(el => {
26
+ const styleDec = window.getComputedStyle(el);
27
+ const {zIndex} = styleDec;
28
+ return zIndex !== 'auto' ? zIndex : null;
32
29
  });
33
- // If it is not auto:
34
- if (zIndex !== 'auto') {
35
- // Add to the totals.
36
- totals[0]++;
37
- // If itemization is required:
38
- if (withItems) {
39
- // Get data on the element.
40
- const elData = await getLocatorData(loc);
41
- // Add an instance to the result.
42
- standardInstances.push({
43
- ruleID: 'zIndex',
44
- what: `Element has a non-default Z index (${zIndex})`,
45
- ordinalSeverity: 0,
46
- tagName: elData.tagName,
47
- id: elData.id,
48
- location: elData.location,
49
- excerpt: elData.excerpt
50
- });
51
- }
30
+ // If it does:
31
+ if (badZ) {
32
+ // Add the locator to the array of violators.
33
+ all.locs.push([loc, badZ]);
52
34
  }
53
35
  }
54
- // If itemization is not required:
55
- if (! withItems) {
56
- // Add a summary instance to the result.
57
- standardInstances.push({
58
- ruleID: 'zIndex',
59
- what: 'Elements have non-default Z indexes',
60
- count: totals[0],
61
- ordinalSeverity: 0,
62
- tagName: '',
63
- id: '',
64
- location: {
65
- doc: '',
66
- type: '',
67
- spec: ''
68
- },
69
- excerpt: ''
70
- });
71
- }
72
- return {
73
- data,
74
- totals,
75
- standardInstances
76
- };
36
+ // Populate and return the result.
37
+ const whats = [
38
+ 'Element has a non-default Z index (__param__)', 'Elements have non-default Z indexes'
39
+ ];
40
+ return await report(withItems, all, 'zIndex', whats, 0);
77
41
  };