testaro 12.2.3 → 12.2.5
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 +1 -1
- package/tests/qualWeb.js +47 -30
package/package.json
CHANGED
package/tests/qualWeb.js
CHANGED
|
@@ -57,42 +57,59 @@ exports.reporter = async (page, withNewContent, rules = null) => {
|
|
|
57
57
|
let reports = await qualWeb.evaluate(qualWebOptions);
|
|
58
58
|
// Remove the copy of the DOM from it.
|
|
59
59
|
let report = reports[withNewContent ? qualWebOptions.url : 'customHtml'];
|
|
60
|
-
if (report && report.system && report.system.page && report.system.page.dom){
|
|
60
|
+
if (report && report.system && report.system.page && report.system.page.dom) {
|
|
61
61
|
delete report.system.page.dom;
|
|
62
62
|
// For each section of the report:
|
|
63
|
-
['act-rules'
|
|
63
|
+
const sections = ['act-rules'];
|
|
64
|
+
if (! rules) {
|
|
65
|
+
sections.push('wcag-techniques', 'best-practices');
|
|
66
|
+
}
|
|
67
|
+
sections.forEach(section => {
|
|
64
68
|
// For each test:
|
|
65
|
-
const {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
const {modules} = report;
|
|
70
|
+
if (modules && modules[section]) {
|
|
71
|
+
const {assertions} = modules[section];
|
|
72
|
+
if (assertions) {
|
|
73
|
+
const ruleIDs = Object.keys(assertions);
|
|
74
|
+
ruleIDs.forEach(ruleID => {
|
|
75
|
+
// Remove passing results.
|
|
76
|
+
const ruleAssertions = assertions[ruleID];
|
|
77
|
+
const {metadata} = ruleAssertions;
|
|
78
|
+
if (metadata) {
|
|
79
|
+
if (metadata.warning === 0 && metadata.failed === 0) {
|
|
80
|
+
delete assertions[ruleID];
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
if (ruleAssertions.results) {
|
|
84
|
+
ruleAssertions.results = ruleAssertions.results.filter(
|
|
85
|
+
result => result.verdict !== 'passed'
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
80
89
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
// Shorten long HTML codes of elements.
|
|
91
|
+
const {results} = ruleAssertions;
|
|
92
|
+
results.forEach(result => {
|
|
93
|
+
const {elements} = result;
|
|
94
|
+
if (elements && elements.length) {
|
|
95
|
+
elements.forEach(element => {
|
|
96
|
+
if (element.htmlCode && element.htmlCode.length > 700) {
|
|
97
|
+
element.htmlCode = `${element.htmlCode.slice(0, 700)} …`;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
91
100
|
}
|
|
92
101
|
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
report.prevented = true;
|
|
106
|
+
report.error = 'ERROR: No assertions';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
report.prevented = true;
|
|
111
|
+
report.error = `ERROR: No ${section} section`;
|
|
112
|
+
}
|
|
96
113
|
});
|
|
97
114
|
// Stop the QualWeb core engine.
|
|
98
115
|
await qualWeb.stop();
|