testaro 12.0.0 → 12.1.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/README.md CHANGED
@@ -380,6 +380,10 @@ The changes in `htmlcs/HTMLCS.js` are:
380
380
  > );
381
381
  ```
382
382
 
383
+ ###### QualWeb
384
+
385
+ A `qualWeb` test act performs the ACT rules, WCAG Techniques, and best-practices tests of QualWeb. Only failures and warnings are included in the report. The EARL report of QualWeb is not generated, because it is equivalent to the report of the ACT rules tests.
386
+
383
387
  ###### Tenon
384
388
 
385
389
  Most tools require only one act, but the `tenon` tool requires two acts:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "12.0.0",
3
+ "version": "12.1.0",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tests/qualWeb.js CHANGED
@@ -3,7 +3,7 @@
3
3
  This test implements the QualWeb ruleset for accessibility.
4
4
  */
5
5
  // IMPORTS
6
- const {QualWeb, generateEARLReport} = require('@qualweb/core');
6
+ const {QualWeb} = require('@qualweb/core');
7
7
  // CONSTANTS
8
8
  const qualweb = new QualWeb({});
9
9
  const clusterOptions = {
@@ -52,24 +52,43 @@ exports.reporter = async (page, rules = null) => {
52
52
  }
53
53
  // Get the report.
54
54
  const reports = await qualweb.evaluate(qualwebOptions);
55
- // Trim it.
55
+ // Prepare to trim its ACT rules and WCAG Techniques section.
56
56
  delete reports.customHtml.system.page.dom;
57
- const {assertions} = reports.customHtml.modules['act-rules'];
58
- const ruleIDs = Object.keys(assertions);
59
- ruleIDs.forEach(ruleID => {
60
- assertions[ruleID].results = assertions[ruleID]
61
- .results
62
- .filter(result => result.verdict !== 'passed');
57
+ ['act-rules', 'wcag-techniques', 'best-practices'].forEach(module => {
58
+ const {assertions} = reports.customHtml.modules[module];
59
+ const ruleIDs = Object.keys(assertions);
60
+ ruleIDs.forEach(ruleID => {
61
+ // Remove passing customHtml results.
62
+ const ruleAssertions = assertions[ruleID];
63
+ const {metadata} = ruleAssertions;
64
+ if (metadata) {
65
+ if (metadata.warning === 0 && metadata.failed === 0) {
66
+ delete assertions[ruleID];
67
+ }
68
+ else {
69
+ if (ruleAssertions.results) {
70
+ ruleAssertions.results = ruleAssertions.results.filter(
71
+ result => result.verdict !== 'passed'
72
+ );
73
+ }
74
+ }
75
+ }
76
+ // Shorten long HTML codes of elements.
77
+ const {results} = ruleAssertions;
78
+ results.forEach(result => {
79
+ const {elements} = result;
80
+ if (elements && elements.length) {
81
+ elements.forEach(element => {
82
+ if (element.htmlCode && element.htmlCode.length > 700) {
83
+ element.htmlCode = `${element.htmlCode.slice(0, 700)} …`;
84
+ }
85
+ });
86
+ }
87
+ });
88
+ });
63
89
  });
64
90
  // Stop the QualWeb core engine.
65
91
  await qualweb.stop();
66
- // Specify the EARL options.
67
- const earlOptions = {};
68
- // Get the EARL report.
69
- const earlReports = generateEARLReport(reports, earlOptions);
70
- // Add the reports to the data.
71
- data.reports = reports;
72
- data.earlReports = earlReports;
73
92
  // Return the result.
74
93
  try {
75
94
  JSON.stringify(data);
@@ -81,5 +100,5 @@ exports.reporter = async (page, rules = null) => {
81
100
  error: `ERROR: qualWeb result cannot be made JSON (${error.message})`
82
101
  };
83
102
  }
84
- return {result: data};
103
+ return {result: reports};
85
104
  };