testaro 21.0.0 → 23.0.0

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/testaro/bulk.js CHANGED
@@ -19,15 +19,18 @@ exports.reporter = async page => {
19
19
  const visiblesLoc = await page.locator('body :visible');
20
20
  const visibleLocs = await visiblesLoc.all();
21
21
  data.visibleElements = visibleLocs.length;
22
- const count = Math.round(data.visibleElements / 400);
22
+ const severity = Math.min(4, Math.round(data.visibleElements / 400));
23
+ const totals = [0, 0, 0, 0];
24
+ if (severity) {
25
+ totals[severity - 1] = 1;
26
+ }
23
27
  return {
24
28
  data,
25
- totals: [count, 0, 0, 0],
29
+ totals,
26
30
  standardInstances: data.visibleElements < 200 ? [] : [{
27
31
  ruleID: 'bulk',
28
32
  what: 'Page contains a large number of visible elements',
29
- count,
30
- ordinalSeverity: 0,
33
+ ordinalSeverity: severity - 1,
31
34
  tagName: 'HTML',
32
35
  id: '',
33
36
  location: {
package/testaro/hover.js CHANGED
@@ -2,7 +2,7 @@
2
2
  hover
3
3
  This test reports unexpected impacts of hovering on the visible page. Impacts are measured by
4
4
  pixel changes outside the hovered element and by unhoverability.
5
-
5
+
6
6
  The elements that are subjected to hovering (called “triggers”) are the Playwright-visible
7
7
  elements that have 'A', 'BUTTON', or (if not with role=menuitem) 'LI' tag names or have
8
8
  'onmouseenter' or 'onmouseover' attributes.
@@ -24,8 +24,8 @@
24
24
  action on the location where the center of the element is, rather than some other element with a
25
25
  higher zIndex value in the same location being the target.
26
26
 
27
- WARNING: This test uses the Playwright page.screenshot method, which is not implemented for the
28
- firefox browser type.
27
+ WARNING: This test uses the procs/visChange module. See the warning in that module about browser
28
+ types.
29
29
  */
30
30
 
31
31
  // IMPORTS
@@ -54,7 +54,7 @@ exports.reporter = async (page, withItems, sampleSize = 20) => {
54
54
  const psRatio = Math.max(1, locsAll.length / sampleSize);
55
55
  // Get a sample of the triggers.
56
56
  const sampleIndexes = getSample(locsAll, sampleSize);
57
- const sample = locsAll.filter((loc, index) => sampleIndexes.includes(index));
57
+ const sample = sampleIndexes.map(index => locsAll[index]);
58
58
  // For each trigger in the sample:
59
59
  for (const loc of sample) {
60
60
  // Hover over it and get the fractional pixel change.
package/testaro/motion.js CHANGED
@@ -7,9 +7,9 @@
7
7
  test compares two screen shots of the viewport 2 seconds and 6 seconds after page load. It
8
8
  reports a rule violation if any pixels change. The larger the change fraction, the greater the
9
9
  ordinal severity.
10
-
11
- WARNING: This test uses the Playwright page.screenshot method, which is not implemented for the
12
- firefox browser type.
10
+
11
+ WARNING: This test uses the procs/visChange module. See the warning in that module about browser
12
+ types.
13
13
  */
14
14
 
15
15
  // IMPORTS
package/tests/testaro.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  testaro
3
- This test implements the Testaro evaluative ruleset for accessibility.
3
+ This test implements the Testaro evaluative rules.
4
4
  */
5
5
 
6
- // CONSTANTS
6
+ // ######## CONSTANTS
7
7
 
8
8
  const evalRules = {
9
9
  allCaps: 'leaf elements with entirely upper-case text longer than 7 characters',
@@ -54,7 +54,7 @@ const etcRules = {
54
54
 
55
55
  // FUNCTIONS
56
56
 
57
- // Conducts and reports a Testaro test.
57
+ // Conducts and reports Testaro tests.
58
58
  exports.reporter = async (page, options) => {
59
59
  const {withItems, stopOnFail, args} = options;
60
60
  const argRules = args ? Object.keys(args) : null;
@@ -62,7 +62,8 @@ exports.reporter = async (page, options) => {
62
62
  // Initialize the data.
63
63
  const data = {
64
64
  rules: {},
65
- preventions: []
65
+ preventions: [],
66
+ testTimes: {}
66
67
  };
67
68
  // If the rule specification is valid:
68
69
  if (
@@ -71,10 +72,11 @@ exports.reporter = async (page, options) => {
71
72
  && rules.slice(1).every(rule => evalRules[rule] || etcRules[rule])
72
73
  ) {
73
74
  // For each rule invoked:
74
- const realRules = rules[0] === 'y'
75
+ const calledRules = rules[0] === 'y'
75
76
  ? rules.slice(1)
76
77
  : Object.keys(evalRules).filter(ruleID => ! rules.slice(1).includes(ruleID));
77
- for (const rule of realRules) {
78
+ const testTimes = [];
79
+ for (const rule of calledRules) {
78
80
  // Initialize an argument array.
79
81
  const ruleArgs = [page, withItems];
80
82
  // If the rule has extra arguments:
@@ -90,12 +92,20 @@ exports.reporter = async (page, options) => {
90
92
  data.rules[rule].what = what;
91
93
  console.log(`>>>>>> ${rule} (${what})`);
92
94
  try {
93
- const report = await require(`../testaro/${rule}`).reporter(... ruleArgs);
94
- Object.keys(report).forEach(key => {
95
- data.rules[rule][key] = report[key];
95
+ const startTime = Date.now();
96
+ const ruleReport = await require(`../testaro/${rule}`).reporter(... ruleArgs);
97
+ // Add data from the test to the result.
98
+ const endTime = Date.now();
99
+ testTimes.push([rule, Math.round((endTime - startTime) / 1000)]);
100
+ Object.keys(ruleReport).forEach(key => {
101
+ data.rules[rule][key] = ruleReport[key];
102
+ data.rules[rule].totals = data.rules[rule].totals.map(total => Math.round(total));
103
+ if (ruleReport.prevented) {
104
+ data.preventions.push(rule);
105
+ }
96
106
  });
97
107
  // If testing is to stop after a failure and the page failed the test:
98
- if (stopOnFail && report.totals.some(total => total)) {
108
+ if (stopOnFail && ruleReport.totals.some(total => total)) {
99
109
  // Stop testing.
100
110
  break;
101
111
  }
@@ -107,6 +117,9 @@ exports.reporter = async (page, options) => {
107
117
  console.log(`ERROR: Test of testaro rule ${rule} prevented (${error.message})`);
108
118
  }
109
119
  }
120
+ testTimes.sort((a, b) => b[1] - a[1]).forEach(pair => {
121
+ data.testTimes[pair[0]] = pair[1];
122
+ });
110
123
  }
111
124
  // Otherwise, i.e. if the rule specification is invalid:
112
125
  else {