testaro 32.1.0 → 32.2.1
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/testaro/styleDiff.js +4 -0
- package/tests/ibm.js +2 -2
- package/tests/qualWeb.js +111 -105
package/package.json
CHANGED
package/testaro/styleDiff.js
CHANGED
|
@@ -245,14 +245,18 @@ exports.reporter = async (page, withItems) => {
|
|
|
245
245
|
h5: [3, 'Level-5 headings', 'H5'],
|
|
246
246
|
h6: [3, 'Level-6 headings', 'H6'],
|
|
247
247
|
};
|
|
248
|
+
// For each eligible element type:
|
|
248
249
|
Object.keys(elementData).forEach(elementName => {
|
|
250
|
+
// If it has more than 1 style:
|
|
249
251
|
const elementTotal = data.totals[elementName];
|
|
250
252
|
if (elementTotal && elementTotal.subtotals) {
|
|
251
253
|
const currentData = elementData[elementName];
|
|
252
254
|
const severity = currentData[0];
|
|
253
255
|
const elementSubtotals = elementTotal.subtotals;
|
|
256
|
+
// Treat the count of its styles in excess of 1 as the instance count for that element type.
|
|
254
257
|
const extraCount = elementSubtotals.length - 1;
|
|
255
258
|
totals[severity] += extraCount;
|
|
259
|
+
// Add a summary standard instance for that element type.
|
|
256
260
|
standardInstances.push({
|
|
257
261
|
ruleID: 'styleDiff',
|
|
258
262
|
what: `${currentData[1]} have ${elementSubtotals.length} different styles`,
|
package/tests/ibm.js
CHANGED
|
@@ -144,9 +144,9 @@ const doTest = async (content, withItems, timeLimit, rules) => {
|
|
|
144
144
|
const actReport = runReport && runReport.report;
|
|
145
145
|
// Delete any report files.
|
|
146
146
|
try {
|
|
147
|
-
const reportNames = await fs.readdir('
|
|
147
|
+
const reportNames = await fs.readdir('ibmOutput');
|
|
148
148
|
for (const reportName of reportNames) {
|
|
149
|
-
await fs.rm(`
|
|
149
|
+
await fs.rm(`ibmOutput/${reportName}`);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
catch(error) {
|
package/tests/qualWeb.js
CHANGED
|
@@ -61,143 +61,149 @@ exports.reporter = async (page, options) => {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
// Specify a URL or provide the content.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
else {
|
|
68
|
-
qualWebOptions.html = await page.content();
|
|
69
|
-
}
|
|
70
|
-
// Specify which rules to test for.
|
|
71
|
-
const actSpec = rules ? rules.find(typeRules => typeRules.startsWith('act:')) : null;
|
|
72
|
-
const wcagSpec = rules ? rules.find(typeRules => typeRules.startsWith('wcag:')) : null;
|
|
73
|
-
const bestSpec = rules ? rules.find(typeRules => typeRules.startsWith('best:')) : null;
|
|
74
|
-
if (actSpec) {
|
|
75
|
-
if (actSpec === 'act:') {
|
|
76
|
-
qualWebOptions.execute.act = false;
|
|
64
|
+
try {
|
|
65
|
+
if (withNewContent) {
|
|
66
|
+
qualWebOptions.url = page.url();
|
|
77
67
|
}
|
|
78
68
|
else {
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
qualWebOptions.html = await page.content();
|
|
70
|
+
}
|
|
71
|
+
// Specify which rules to test for.
|
|
72
|
+
const actSpec = rules ? rules.find(typeRules => typeRules.startsWith('act:')) : null;
|
|
73
|
+
const wcagSpec = rules ? rules.find(typeRules => typeRules.startsWith('wcag:')) : null;
|
|
74
|
+
const bestSpec = rules ? rules.find(typeRules => typeRules.startsWith('best:')) : null;
|
|
75
|
+
if (actSpec) {
|
|
76
|
+
if (actSpec === 'act:') {
|
|
77
|
+
qualWebOptions.execute.act = false;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const actRules = actSpec.slice(4).split(',').map(num => `QW-ACT-R${num}`);
|
|
81
|
+
qualWebOptions['act-rules'] = {rules: actRules};
|
|
82
|
+
qualWebOptions.execute.act = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
qualWebOptions['act-rules'] = {
|
|
87
|
+
levels: ['A', 'AA', 'AAA'],
|
|
88
|
+
principles: ['Perceivable', 'Operable', 'Understandable', 'Robust']
|
|
89
|
+
};
|
|
81
90
|
qualWebOptions.execute.act = true;
|
|
82
91
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (wcagSpec === 'wcag:') {
|
|
93
|
-
qualWebOptions.execute.wcag = false;
|
|
92
|
+
if (wcagSpec) {
|
|
93
|
+
if (wcagSpec === 'wcag:') {
|
|
94
|
+
qualWebOptions.execute.wcag = false;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const wcagTechniques = wcagSpec.slice(5).split(',').map(num => `QW-WCAG-T${num}`);
|
|
98
|
+
qualWebOptions['wcag-techniques'] = {techniques: wcagTechniques};
|
|
99
|
+
qualWebOptions.execute.wcag = true;
|
|
100
|
+
}
|
|
94
101
|
}
|
|
95
102
|
else {
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
qualWebOptions['wcag-techniques'] = {
|
|
104
|
+
levels: ['A', 'AA', 'AAA'],
|
|
105
|
+
principles: ['Perceivable', 'Operable', 'Understandable', 'Robust']
|
|
106
|
+
};
|
|
98
107
|
qualWebOptions.execute.wcag = true;
|
|
99
108
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
if (bestSpec) {
|
|
110
|
+
if (bestSpec === 'best:') {
|
|
111
|
+
qualWebOptions.execute.bp = false;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const bestPractices = bestSpec.slice(5).split(',').map(num => `QW-BP${num}`);
|
|
115
|
+
qualWebOptions['best-practices'] = {bestPractices};
|
|
116
|
+
// qualWebOptions.execute.bp = true;
|
|
117
|
+
// Temporarily disable best practices, because they crash QualWeb.
|
|
118
|
+
qualWebOptions.execute.bp = false;
|
|
119
|
+
}
|
|
111
120
|
}
|
|
112
121
|
else {
|
|
113
|
-
const bestPractices = bestSpec.slice(5).split(',').map(num => `QW-BP${num}`);
|
|
114
|
-
qualWebOptions['best-practices'] = {bestPractices};
|
|
115
122
|
// qualWebOptions.execute.bp = true;
|
|
116
123
|
// Temporarily disable best practices, because they crash QualWeb.
|
|
117
124
|
qualWebOptions.execute.bp = false;
|
|
118
125
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// Remove passing results.
|
|
142
|
-
const ruleAssertions = assertions[ruleID];
|
|
143
|
-
const {metadata} = ruleAssertions;
|
|
144
|
-
if (metadata) {
|
|
145
|
-
if (metadata.warning === 0 && metadata.failed === 0) {
|
|
146
|
-
delete assertions[ruleID];
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
if (ruleAssertions.results) {
|
|
150
|
-
ruleAssertions.results = ruleAssertions.results.filter(
|
|
151
|
-
raResult => raResult.verdict !== 'passed'
|
|
152
|
-
);
|
|
126
|
+
// Get the report.
|
|
127
|
+
let actReports = await qualWeb.evaluate(qualWebOptions);
|
|
128
|
+
// Remove the copy of the DOM from it.
|
|
129
|
+
const result = actReports[withNewContent ? qualWebOptions.url : 'customHtml'];
|
|
130
|
+
if (result && result.system && result.system.page && result.system.page.dom) {
|
|
131
|
+
delete result.system.page.dom;
|
|
132
|
+
// For each test section of the act report:
|
|
133
|
+
const {modules} = result;
|
|
134
|
+
if (modules) {
|
|
135
|
+
for (const section of ['act-rules', 'wcag-techniques', 'best-practices']) {
|
|
136
|
+
if (qualWebOptions[section]) {
|
|
137
|
+
if (modules[section]) {
|
|
138
|
+
const {assertions} = modules[section];
|
|
139
|
+
if (assertions) {
|
|
140
|
+
const ruleIDs = Object.keys(assertions);
|
|
141
|
+
ruleIDs.forEach(ruleID => {
|
|
142
|
+
// Remove passing results.
|
|
143
|
+
const ruleAssertions = assertions[ruleID];
|
|
144
|
+
const {metadata} = ruleAssertions;
|
|
145
|
+
if (metadata) {
|
|
146
|
+
if (metadata.warning === 0 && metadata.failed === 0) {
|
|
147
|
+
delete assertions[ruleID];
|
|
153
148
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const {elements} = raResult;
|
|
160
|
-
if (elements && elements.length) {
|
|
161
|
-
elements.forEach(element => {
|
|
162
|
-
if (element.htmlCode && element.htmlCode.length > 700) {
|
|
163
|
-
element.htmlCode = `${element.htmlCode.slice(0, 700)} …`;
|
|
149
|
+
else {
|
|
150
|
+
if (ruleAssertions.results) {
|
|
151
|
+
ruleAssertions.results = ruleAssertions.results.filter(
|
|
152
|
+
raResult => raResult.verdict !== 'passed'
|
|
153
|
+
);
|
|
164
154
|
}
|
|
165
|
-
}
|
|
155
|
+
}
|
|
166
156
|
}
|
|
157
|
+
// Shorten long HTML codes of elements.
|
|
158
|
+
const {results} = ruleAssertions;
|
|
159
|
+
results.forEach(raResult => {
|
|
160
|
+
const {elements} = raResult;
|
|
161
|
+
if (elements && elements.length) {
|
|
162
|
+
elements.forEach(element => {
|
|
163
|
+
if (element.htmlCode && element.htmlCode.length > 700) {
|
|
164
|
+
element.htmlCode = `${element.htmlCode.slice(0, 700)} …`;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
167
169
|
});
|
|
168
|
-
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
data.prevented = true;
|
|
173
|
+
data.error = 'ERROR: No assertions';
|
|
174
|
+
}
|
|
169
175
|
}
|
|
170
176
|
else {
|
|
171
177
|
data.prevented = true;
|
|
172
|
-
data.error =
|
|
178
|
+
data.error = `ERROR: No ${section} section`;
|
|
173
179
|
}
|
|
174
180
|
}
|
|
175
|
-
else {
|
|
176
|
-
data.prevented = true;
|
|
177
|
-
data.error = `ERROR: No ${section} section`;
|
|
178
|
-
}
|
|
179
181
|
}
|
|
180
182
|
}
|
|
183
|
+
else {
|
|
184
|
+
data.prevented = true;
|
|
185
|
+
data.error = 'ERROR: No modules';
|
|
186
|
+
}
|
|
181
187
|
}
|
|
182
188
|
else {
|
|
183
189
|
data.prevented = true;
|
|
184
|
-
data.error = 'ERROR: No
|
|
190
|
+
data.error = 'ERROR: No DOM';
|
|
185
191
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
// Stop the QualWeb core engine.
|
|
193
|
+
await qualWeb.stop();
|
|
194
|
+
// Return the result.
|
|
195
|
+
try {
|
|
196
|
+
JSON.stringify(result);
|
|
197
|
+
}
|
|
198
|
+
catch(error) {
|
|
199
|
+
const message = `ERROR: qualWeb result cannot be made JSON (${error.message})`;
|
|
200
|
+
data.prevented = true;
|
|
201
|
+
data.error = message;
|
|
202
|
+
};
|
|
196
203
|
}
|
|
197
204
|
catch(error) {
|
|
198
|
-
const message = `ERROR: qualWeb result cannot be made JSON (${error.message})`;
|
|
199
205
|
data.prevented = true;
|
|
200
|
-
data.error = message;
|
|
206
|
+
data.error = error.message.slice(0, 200);
|
|
201
207
|
};
|
|
202
208
|
return {
|
|
203
209
|
data,
|