testaro 32.4.0 → 33.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/README.md +48 -46
- package/call.js +6 -4
- package/ed11y/editoria11y.min.js +747 -0
- package/netWatch.js +1 -0
- package/package.json +1 -1
- package/procs/standardize.js +39 -0
- package/run.js +2 -1
- package/tests/alfa.js +1 -1
- package/tests/aslint.js +1 -1
- package/tests/axe.js +1 -1
- package/tests/ed11y.js +142 -0
- package/tests/htmlcs.js +1 -1
- package/tests/ibm.js +1 -1
- package/tests/nuVal.js +1 -0
- package/tests/qualWeb.js +1 -1
- package/tests/testaro.js +1 -1
- package/tests/wave.js +7 -0
package/netWatch.js
CHANGED
|
@@ -64,6 +64,7 @@ const serveObject = (object, response) => {
|
|
|
64
64
|
Arguments:
|
|
65
65
|
0. whether to continue watching after a job is run.
|
|
66
66
|
1: interval in seconds from a cycle of no-job checks to the next cycle.
|
|
67
|
+
2. whether to ignore unknown-certificate errors from watched servers.
|
|
67
68
|
*/
|
|
68
69
|
exports.netWatch = async (isForever, intervalInSeconds, isCertTolerant = true) => {
|
|
69
70
|
const urls = jobURLSpec
|
package/package.json
CHANGED
package/procs/standardize.js
CHANGED
|
@@ -440,6 +440,7 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
440
440
|
// axe
|
|
441
441
|
else if (
|
|
442
442
|
toolName === 'axe'
|
|
443
|
+
&& result
|
|
443
444
|
&& result.totals
|
|
444
445
|
&& (result.totals.rulesWarned || result.totals.rulesViolated)
|
|
445
446
|
) {
|
|
@@ -453,6 +454,44 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
453
454
|
doAxe(result, standardResult, 'incomplete');
|
|
454
455
|
doAxe(result, standardResult, 'violations');
|
|
455
456
|
}
|
|
457
|
+
// ed11y
|
|
458
|
+
else if (
|
|
459
|
+
toolName === 'ed11y'
|
|
460
|
+
&& result
|
|
461
|
+
&& ['results', 'errorCount', 'warningCount'].every(key => result[key] !== undefined)
|
|
462
|
+
) {
|
|
463
|
+
// Populate the totals of the standard result.
|
|
464
|
+
const {results, errorCount, warningCount} = result;
|
|
465
|
+
standardResult.totals = [warningCount, 0, errorCount, 0];
|
|
466
|
+
// For each result:
|
|
467
|
+
results.forEach(result => {
|
|
468
|
+
const {test, content, tagName, id, loc, excerpt} = result;
|
|
469
|
+
if (['test', 'content'].every(key => result[key])) {
|
|
470
|
+
// Standardize the what property.
|
|
471
|
+
let what = '';
|
|
472
|
+
if (content.includes('<p>This')) {
|
|
473
|
+
what = content.replace(/^.*?<p>(This.+?)<\/p> *<p>(.*?)<\/p>.*/, '$1 $2');
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
what = content.replace(/^.*?<p>(.+?)<\/p>.*/, '$1');
|
|
477
|
+
}
|
|
478
|
+
// Add a standard instance to the standard result.
|
|
479
|
+
standardResult.instances.push({
|
|
480
|
+
ruleID: test,
|
|
481
|
+
what,
|
|
482
|
+
ordinalSeverity: 0,
|
|
483
|
+
tagName,
|
|
484
|
+
id,
|
|
485
|
+
location: {
|
|
486
|
+
doc: 'dom',
|
|
487
|
+
type: 'box',
|
|
488
|
+
spec: loc
|
|
489
|
+
},
|
|
490
|
+
excerpt
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
}
|
|
456
495
|
// htmlcs
|
|
457
496
|
else if (toolName === 'htmlcs' && result) {
|
|
458
497
|
doHTMLCS(result, standardResult, 'Warning');
|
package/run.js
CHANGED
|
@@ -58,6 +58,7 @@ const tools = {
|
|
|
58
58
|
alfa: 'alfa',
|
|
59
59
|
aslint: 'ASLint',
|
|
60
60
|
axe: 'Axe',
|
|
61
|
+
ed11y: 'Editoria11y',
|
|
61
62
|
htmlcs: 'HTML CodeSniffer WCAG 2.1 AA ruleset',
|
|
62
63
|
ibm: 'IBM Accessibility Checker',
|
|
63
64
|
nuVal: 'Nu Html Checker',
|
|
@@ -1568,7 +1569,7 @@ exports.doJob = async report => {
|
|
|
1568
1569
|
// If the report is valid:
|
|
1569
1570
|
const reportInvalidity = isValidReport(report);
|
|
1570
1571
|
if (reportInvalidity) {
|
|
1571
|
-
console.log(reportInvalidity);
|
|
1572
|
+
console.log(`ERROR: ${reportInvalidity}`);
|
|
1572
1573
|
}
|
|
1573
1574
|
else {
|
|
1574
1575
|
// Add initialized job data to the report.
|
package/tests/alfa.js
CHANGED
|
@@ -33,7 +33,7 @@ let alfaRules = require('@siteimprove/alfa-rules').default;
|
|
|
33
33
|
|
|
34
34
|
// FUNCTIONS
|
|
35
35
|
|
|
36
|
-
// Conducts and reports
|
|
36
|
+
// Conducts and reports the alfa tests.
|
|
37
37
|
exports.reporter = async (page, options) => {
|
|
38
38
|
const {rules} = options;
|
|
39
39
|
// If only some rules are to be employed:
|
package/tests/aslint.js
CHANGED
package/tests/axe.js
CHANGED
|
@@ -47,7 +47,7 @@ const {injectAxe, getAxeResults} = require('axe-playwright');
|
|
|
47
47
|
|
|
48
48
|
// FUNCTIONS
|
|
49
49
|
|
|
50
|
-
// Conducts and reports
|
|
50
|
+
// Conducts and reports the Axe tests.
|
|
51
51
|
exports.reporter = async (page, options) => {
|
|
52
52
|
const {detailLevel, rules} = options;
|
|
53
53
|
// Initialize the act report.
|
package/tests/ed11y.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/*
|
|
2
|
+
© 2023 CVS Health and/or one of its affiliates. All rights reserved.
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
ed11y
|
|
25
|
+
This test implements the Editoria11y ruleset for accessibility.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
// IMPORTS
|
|
29
|
+
|
|
30
|
+
// Module to handle files.
|
|
31
|
+
const fs = require('fs/promises');
|
|
32
|
+
|
|
33
|
+
// FUNCTIONS
|
|
34
|
+
|
|
35
|
+
// Conducts and reports the Editoria11y tests.
|
|
36
|
+
exports.reporter = async (page, options) => {
|
|
37
|
+
// Get the nonce, if any.
|
|
38
|
+
const {report} = options;
|
|
39
|
+
const {jobData} = report;
|
|
40
|
+
const scriptNonce = jobData && jobData.lastScriptNonce;
|
|
41
|
+
// Get the test script.
|
|
42
|
+
const script = await fs.readFile(`${__dirname}/../ed11y/editoria11y.min.js`, 'utf8');
|
|
43
|
+
const rawResultJSON = await page.evaluate(args => new Promise(async resolve => {
|
|
44
|
+
const {scriptNonce, script} = args;
|
|
45
|
+
// When the script is executed:
|
|
46
|
+
document.addEventListener('ed11yResults', () => {
|
|
47
|
+
// Get the result.
|
|
48
|
+
const resultObj = {};
|
|
49
|
+
[
|
|
50
|
+
'version',
|
|
51
|
+
'options',
|
|
52
|
+
'mediaCount',
|
|
53
|
+
'errorCount',
|
|
54
|
+
'warningCount',
|
|
55
|
+
'dismissedCount',
|
|
56
|
+
'totalCount'
|
|
57
|
+
]
|
|
58
|
+
.forEach(key => {
|
|
59
|
+
try {
|
|
60
|
+
resultObj[key] = Ed11y[key];
|
|
61
|
+
}
|
|
62
|
+
catch(error) {
|
|
63
|
+
console.log(`ERROR: invalid value of ${key} property of Ed11y (${error.message})`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// Get data on the text alternatives of images from the result.
|
|
67
|
+
resultObj.imageAlts = Ed11y
|
|
68
|
+
.imageAlts
|
|
69
|
+
.filter(item => item[3] !== 'pass')
|
|
70
|
+
.map(item => item.slice(1));
|
|
71
|
+
// Delete useless properties from the result.
|
|
72
|
+
delete resultObj.options.sleekTheme;
|
|
73
|
+
delete resultObj.options.darkTheme;
|
|
74
|
+
delete resultObj.options.lightTheme;
|
|
75
|
+
// Initialize the element results.
|
|
76
|
+
const results = resultObj.results = [];
|
|
77
|
+
// Populate them and add them to the result.
|
|
78
|
+
Ed11y.results.forEach(elResult => {
|
|
79
|
+
const result = {};
|
|
80
|
+
result.test = elResult.test || '';
|
|
81
|
+
if (elResult.content) {
|
|
82
|
+
result.content = elResult.content.replace(/\s+/g, ' ');
|
|
83
|
+
}
|
|
84
|
+
if (elResult.element) {
|
|
85
|
+
const{element} = elResult;
|
|
86
|
+
result.tagName = element.tagName || '';
|
|
87
|
+
result.id = element.id || '';
|
|
88
|
+
result.loc = {};
|
|
89
|
+
const locRect = element.getBoundingClientRect();
|
|
90
|
+
if (locRect) {
|
|
91
|
+
['x', 'y', 'width', 'height'].forEach(dim => {
|
|
92
|
+
result.loc[dim] = Math.round(locRect[dim]);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
let elText = element.textContent.replace(/\s+/g, ' ').trim();
|
|
96
|
+
if (! elText) {
|
|
97
|
+
elText = element.outerHTML;
|
|
98
|
+
}
|
|
99
|
+
if (elText.length > 400) {
|
|
100
|
+
elText = `${elText.slice(0, 200)}…${elText.slice(-200)}`;
|
|
101
|
+
}
|
|
102
|
+
result.excerpt = elText.replace(/\s+/g, ' ');
|
|
103
|
+
}
|
|
104
|
+
results.push(result);
|
|
105
|
+
});
|
|
106
|
+
// Return the result.
|
|
107
|
+
try {
|
|
108
|
+
const resultJSON = JSON.stringify(resultObj);
|
|
109
|
+
resolve(resultJSON);
|
|
110
|
+
}
|
|
111
|
+
catch(error) {
|
|
112
|
+
console.log(`ERROR stringifying result object (${error.message})`);
|
|
113
|
+
resolve('{}');
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
// Add the test script to the page.
|
|
117
|
+
const testScript = document.createElement('script');
|
|
118
|
+
if (scriptNonce) {
|
|
119
|
+
testScript.nonce = scriptNonce;
|
|
120
|
+
console.log(`Added nonce ${scriptNonce} to script`);
|
|
121
|
+
}
|
|
122
|
+
testScript.textContent = script;
|
|
123
|
+
document.body.insertAdjacentElement('beforeend', testScript);
|
|
124
|
+
// Run the script.
|
|
125
|
+
try {
|
|
126
|
+
await new Ed11y({
|
|
127
|
+
alertMode: 'headless'
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
catch(error) {
|
|
131
|
+
console.log(`ERROR creating Ed11y (${error.message})`);
|
|
132
|
+
resolve(JSON.stringify({error: error.message}));
|
|
133
|
+
};
|
|
134
|
+
}), {scriptNonce, script});
|
|
135
|
+
const result = JSON.parse(rawResultJSON);
|
|
136
|
+
let data = {};
|
|
137
|
+
// Return the act report.
|
|
138
|
+
return {
|
|
139
|
+
data,
|
|
140
|
+
result
|
|
141
|
+
};
|
|
142
|
+
};
|
package/tests/htmlcs.js
CHANGED
|
@@ -32,7 +32,7 @@ const fs = require('fs/promises');
|
|
|
32
32
|
|
|
33
33
|
// FUNCTIONS
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// Conducts and reports the HTML CodeSniffer tests.
|
|
36
36
|
exports.reporter = async (page, options) => {
|
|
37
37
|
const {report, rules} = options;
|
|
38
38
|
const data = {};
|
package/tests/ibm.js
CHANGED
|
@@ -176,7 +176,7 @@ const doTest = async (content, withItems, timeLimit, rules) => {
|
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
|
-
//
|
|
179
|
+
// Conducts and reports the IBM Equal Access tests.
|
|
180
180
|
exports.reporter = async (page, options) => {
|
|
181
181
|
const {withItems, withNewContent, rules} = options;
|
|
182
182
|
const contentType = withNewContent ? 'new' : 'existing';
|
package/tests/nuVal.js
CHANGED
package/tests/qualWeb.js
CHANGED
package/tests/testaro.js
CHANGED
|
@@ -129,7 +129,7 @@ const wait = ms => {
|
|
|
129
129
|
}, ms);
|
|
130
130
|
});
|
|
131
131
|
};
|
|
132
|
-
// Conducts and reports Testaro tests.
|
|
132
|
+
// Conducts and reports the Testaro tests.
|
|
133
133
|
exports.reporter = async (page, options) => {
|
|
134
134
|
const {report, withItems, stopOnFail, args} = options;
|
|
135
135
|
const argRules = args ? Object.keys(args) : null;
|
package/tests/wave.js
CHANGED
|
@@ -26,8 +26,15 @@
|
|
|
26
26
|
specifies a WAVE report type: 1, 2, 3, or 4. The larger the number, the more detailed (and
|
|
27
27
|
expensive) the report.
|
|
28
28
|
*/
|
|
29
|
+
|
|
30
|
+
// CONSTANTS
|
|
31
|
+
|
|
29
32
|
const fs = require('fs/promises');
|
|
30
33
|
const https = require('https');
|
|
34
|
+
|
|
35
|
+
// FUNCTIONS
|
|
36
|
+
|
|
37
|
+
// Conducts and reports the WAVE tests.
|
|
31
38
|
exports.reporter = async (page, options) => {
|
|
32
39
|
const {reportType, rules} = options;
|
|
33
40
|
const waveKey = process.env.WAVE_KEY;
|