testaro 5.1.1 → 5.1.2
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/htmlcs.js +54 -36
package/package.json
CHANGED
package/tests/htmlcs.js
CHANGED
|
@@ -18,45 +18,63 @@ exports.reporter = async page => {
|
|
|
18
18
|
if (! result.prevented) {
|
|
19
19
|
let messageStrings = [];
|
|
20
20
|
for (const standard of ['WCAG2AA']) {
|
|
21
|
-
const nextIssues = await page.evaluate(standard =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
const nextIssues = await page.evaluate(standard => {
|
|
22
|
+
let issues = null;
|
|
23
|
+
try {
|
|
24
|
+
issues = HTMLCS_RUNNER.run(standard);
|
|
25
|
+
}
|
|
26
|
+
catch(error) {
|
|
27
|
+
console.log(`ERROR executing HTMLCS_RUNNER on ${document.URL} (${error.message})`);
|
|
28
|
+
};
|
|
29
|
+
return issues;
|
|
30
|
+
}, standard);
|
|
31
|
+
if (nextIssues) {
|
|
32
|
+
messageStrings.push(... nextIssues);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
result.prevented = true;
|
|
36
|
+
result.error = 'ERROR executing HTMLCS_RUNNER in the page';
|
|
37
|
+
break;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
};
|
|
40
|
+
if (! result.prevented) {
|
|
41
|
+
// Sort the issues by class and standard.
|
|
42
|
+
messageStrings.sort();
|
|
43
|
+
// Remove any duplicate issues.
|
|
44
|
+
messageStrings = [... new Set(messageStrings)];
|
|
45
|
+
// Initialize the result.
|
|
46
|
+
result.Error = {};
|
|
47
|
+
result.Warning = {};
|
|
48
|
+
// For each issue:
|
|
49
|
+
messageStrings.forEach(string => {
|
|
50
|
+
const parts = string.split(/\|/, 6);
|
|
51
|
+
const partCount = parts.length;
|
|
52
|
+
if (partCount < 6) {
|
|
53
|
+
console.log(`ERROR: Issue string ${string} has too few parts`);
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
// If it is an error or a warning (not a notice):
|
|
56
|
+
else if (['Error', 'Warning'].includes(parts[0])) {
|
|
57
|
+
/*
|
|
58
|
+
Add the issue to an issueClass.issueCode.description array in the result.
|
|
59
|
+
This saves space, because, although some descriptions are issue-specific, such as
|
|
60
|
+
descriptions that state the contrast ratio of an element, most descriptions are
|
|
61
|
+
generic, so typically many issues share a description.
|
|
62
|
+
*/
|
|
63
|
+
const issueCode = parts[1].replace(/^WCAG2|\.Principle\d\.Guideline[\d_]+/g, '');
|
|
64
|
+
if (! result[parts[0]][issueCode]) {
|
|
65
|
+
result[parts[0]][issueCode] = {};
|
|
66
|
+
}
|
|
67
|
+
if (! result[parts[0]][issueCode][parts[4]]) {
|
|
68
|
+
result[parts[0]][issueCode][parts[4]] = [];
|
|
69
|
+
}
|
|
70
|
+
result[parts[0]][issueCode][parts[4]].push({
|
|
71
|
+
tagName: parts[2],
|
|
72
|
+
id: parts[3],
|
|
73
|
+
code: parts[5]
|
|
74
|
+
});
|
|
52
75
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
id: parts[3],
|
|
56
|
-
code: parts[5]
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
60
78
|
}
|
|
61
79
|
return {result};
|
|
62
80
|
};
|