testaro 2.3.3 → 2.3.6
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/commands.js +6 -0
- package/index.js +5 -5
- package/package.json +1 -1
- package/procs/score/asp09.js +1 -1
- package/tests/aatt.js +3 -2
- package/tests/alfa.js +82 -80
package/commands.js
CHANGED
|
@@ -142,6 +142,12 @@ exports.commands = {
|
|
|
142
142
|
]
|
|
143
143
|
},
|
|
144
144
|
tests: {
|
|
145
|
+
aatt: [
|
|
146
|
+
'Perform an AATT test with HTML CodeSniffer',
|
|
147
|
+
{
|
|
148
|
+
waitLong: [false, 'boolean', '', 'whether to wait 20 instead of 10 seconds for the result']
|
|
149
|
+
}
|
|
150
|
+
],
|
|
145
151
|
axe: [
|
|
146
152
|
'Perform an Axe test',
|
|
147
153
|
{
|
package/index.js
CHANGED
|
@@ -454,7 +454,7 @@ const goto = async (page, url, timeout, waitUntil, isStrict) => {
|
|
|
454
454
|
return 'error';
|
|
455
455
|
});
|
|
456
456
|
if (typeof response !== 'string') {
|
|
457
|
-
const httpStatus = response.
|
|
457
|
+
const httpStatus = response.status();
|
|
458
458
|
if ([200, 304].includes(httpStatus) || url.startsWith('file:')) {
|
|
459
459
|
const actualURL = page.url();
|
|
460
460
|
if (isStrict && deSlash(actualURL) !== deSlash(url)) {
|
|
@@ -1105,16 +1105,16 @@ const doScript = async (options, report) => {
|
|
|
1105
1105
|
const scoreTable = scoreTables[0];
|
|
1106
1106
|
const {result} = scoreTable;
|
|
1107
1107
|
if (result) {
|
|
1108
|
-
const {logWeights,
|
|
1109
|
-
if (logWeights &&
|
|
1110
|
-
|
|
1108
|
+
const {logWeights, scores} = result;
|
|
1109
|
+
if (logWeights && scores) {
|
|
1110
|
+
scores.log = Math.floor(
|
|
1111
1111
|
logWeights.count * logCount
|
|
1112
1112
|
+ logWeights.size * logSize
|
|
1113
1113
|
+ logWeights.prohibited * prohibitedCount
|
|
1114
1114
|
+ logWeights.visitTimeout * visitTimeoutCount
|
|
1115
1115
|
+ logWeights.visitRejection * visitRejectionCount
|
|
1116
1116
|
);
|
|
1117
|
-
|
|
1117
|
+
scores.total += scores.log;
|
|
1118
1118
|
}
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
package/package.json
CHANGED
package/procs/score/asp09.js
CHANGED
package/tests/aatt.js
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
const {evaluate} = require('aatt');
|
|
8
8
|
|
|
9
9
|
// FUNCTIONS
|
|
10
|
-
exports.reporter = async page => {
|
|
11
|
-
|
|
10
|
+
exports.reporter = async (page, waitLong) => {
|
|
11
|
+
// Set the limit in seconds on the wait for the result.
|
|
12
|
+
const timeLimit = waitLong ? 20 : 10;
|
|
12
13
|
// Get the HTML of the document body.
|
|
13
14
|
const source = await page.content();
|
|
14
15
|
// Return the result of a test with the HTML CodeSniffer WCAG 2.1 AA ruleset as a string.
|
package/tests/alfa.js
CHANGED
|
@@ -18,90 +18,92 @@ exports.reporter = async page => {
|
|
|
18
18
|
const msgText = msg.text();
|
|
19
19
|
console.log(msgText);
|
|
20
20
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
ruleData[ruleID] = ruleText;
|
|
21
|
+
try {
|
|
22
|
+
const response = await rulePage.goto('https://alfa.siteimprove.com/rules', {timeout: 10000});
|
|
23
|
+
let ruleData = {};
|
|
24
|
+
if (response.status() === 200) {
|
|
25
|
+
// Compile data on the rule IDs and summaries.
|
|
26
|
+
ruleData = await rulePage.evaluate(() => {
|
|
27
|
+
const rulePs = Array.from(document.querySelectorAll('p.h5'));
|
|
28
|
+
const ruleData = {};
|
|
29
|
+
rulePs.forEach(ruleP => {
|
|
30
|
+
const childNodes = Array.from(ruleP.childNodes);
|
|
31
|
+
const ruleID = childNodes[0].textContent.slice(4).toLowerCase();
|
|
32
|
+
const ruleText = childNodes
|
|
33
|
+
.slice(1)
|
|
34
|
+
.map(node => node.textContent)
|
|
35
|
+
.join(' ')
|
|
36
|
+
.trim()
|
|
37
|
+
.replace(/"/g, '\'')
|
|
38
|
+
.replace(/\s+/g, ' ');
|
|
39
|
+
ruleData[ruleID] = ruleText;
|
|
40
|
+
});
|
|
41
|
+
return ruleData;
|
|
43
42
|
});
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (codeLines[0] === '#document') {
|
|
66
|
-
codeLines.splice(2, codeLines.length - 3, '...');
|
|
67
|
-
}
|
|
68
|
-
else if (codeLines[0].startsWith('<html')) {
|
|
69
|
-
codeLines.splice(1, codeLines.length - 2, '...');
|
|
70
|
-
}
|
|
71
|
-
const outcomeData = {
|
|
72
|
-
index,
|
|
73
|
-
verdict,
|
|
74
|
-
rule: {
|
|
75
|
-
ruleID,
|
|
76
|
-
ruleSummary,
|
|
77
|
-
scope: '',
|
|
78
|
-
uri,
|
|
79
|
-
requirements
|
|
80
|
-
},
|
|
81
|
-
target: {
|
|
82
|
-
type: targetJ.type,
|
|
83
|
-
tagName: targetJ.name || '',
|
|
84
|
-
path: target.path(),
|
|
85
|
-
codeLines: codeLines.map(line => line.length > 99 ? `${line.slice(0, 99)}...` : line)
|
|
43
|
+
await rulePage.close();
|
|
44
|
+
}
|
|
45
|
+
const data = [];
|
|
46
|
+
await Scraper.with(async scraper => {
|
|
47
|
+
for (const input of await scraper.scrape(page.url())) {
|
|
48
|
+
const audit = Audit.of(input, alfaRules.default);
|
|
49
|
+
const outcomes = Array.from(await audit.evaluate());
|
|
50
|
+
outcomes.forEach((outcome, index) => {
|
|
51
|
+
const {target} = outcome;
|
|
52
|
+
if (target && ! target._members) {
|
|
53
|
+
const outcomeJ = outcome.toJSON();
|
|
54
|
+
const verdict = outcomeJ.outcome;
|
|
55
|
+
if (verdict !== 'passed') {
|
|
56
|
+
const {rule} = outcomeJ;
|
|
57
|
+
const {tags, uri, requirements} = rule;
|
|
58
|
+
const ruleID = uri.replace(/^.+-/, '');
|
|
59
|
+
const ruleSummary = ruleData[ruleID] || '';
|
|
60
|
+
const targetJ = outcomeJ.target;
|
|
61
|
+
const codeLines = target.toString().split('\n');
|
|
62
|
+
if (codeLines[0] === '#document') {
|
|
63
|
+
codeLines.splice(2, codeLines.length - 3, '...');
|
|
86
64
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
tags.forEach(tag => {
|
|
90
|
-
if (tag.type === 'scope') {
|
|
91
|
-
outcomeData.rule.scope = tag.scope;
|
|
65
|
+
else if (codeLines[0].startsWith('<html')) {
|
|
66
|
+
codeLines.splice(1, codeLines.length - 2, '...');
|
|
92
67
|
}
|
|
93
|
-
|
|
94
|
-
|
|
68
|
+
const outcomeData = {
|
|
69
|
+
index,
|
|
70
|
+
verdict,
|
|
71
|
+
rule: {
|
|
72
|
+
ruleID,
|
|
73
|
+
ruleSummary,
|
|
74
|
+
scope: '',
|
|
75
|
+
uri,
|
|
76
|
+
requirements
|
|
77
|
+
},
|
|
78
|
+
target: {
|
|
79
|
+
type: targetJ.type,
|
|
80
|
+
tagName: targetJ.name || '',
|
|
81
|
+
path: target.path(),
|
|
82
|
+
codeLines: codeLines.map(line => line.length > 99 ? `${line.slice(0, 99)}...` : line)
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const etcTags = [];
|
|
86
|
+
tags.forEach(tag => {
|
|
87
|
+
if (tag.type === 'scope') {
|
|
88
|
+
outcomeData.rule.scope = tag.scope;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
etcTags.push(tag);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
if (etcTags.length) {
|
|
95
|
+
outcomeData.etcTags = etcTags;
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
-
if (etcTags.length) {
|
|
98
|
-
outcomeData.etcTags = etcTags;
|
|
97
|
+
data.push(outcomeData);
|
|
99
98
|
}
|
|
100
|
-
data.push(outcomeData);
|
|
101
99
|
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return {result: data};
|
|
104
|
+
}
|
|
105
|
+
catch(error) {
|
|
106
|
+
console.log(`ERROR: navigation to URL timed out (${error})`);
|
|
107
|
+
return {result: {error: 'ERROR: navigation to URL timed out'}};
|
|
108
|
+
}
|
|
107
109
|
};
|