testaro 45.0.5 → 45.0.7
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/procs/identify.js +36 -26
- package/tests/aslint.js +0 -11
- package/tests/wave.js +58 -49
package/package.json
CHANGED
package/procs/identify.js
CHANGED
|
@@ -170,35 +170,45 @@ exports.identify = async (instance, page) => {
|
|
|
170
170
|
}
|
|
171
171
|
// If either ID remains undefined and the instance specifies a tag name:
|
|
172
172
|
if (tagName && ! (elementID.boxID && elementID.pathID)) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
173
|
+
try {
|
|
174
|
+
// Get locators for elements with the tag name.
|
|
175
|
+
let locators = page.locator(tagName);
|
|
176
|
+
// If there is exactly 1 of them:
|
|
177
|
+
let locatorCount = await locators.count();
|
|
178
|
+
if (locatorCount === 1) {
|
|
179
|
+
// Add a box ID and a path ID to the result.
|
|
180
|
+
await addIDs(locators, elementID);
|
|
181
|
+
}
|
|
182
|
+
// If either ID remains undefined and the instance also specifies an excerpt:
|
|
183
|
+
if (excerpt && ! (elementID.boxID && elementID.pathID)) {
|
|
184
|
+
// Get the plain text parts of the excerpt, converting ... to an empty string.
|
|
185
|
+
const minTagExcerpt = excerpt.replace(/<[^>]+>/g, '<>');
|
|
186
|
+
const plainParts = (minTagExcerpt.match(/[^<>]+/g) || [])
|
|
187
|
+
.map(part => part === '...' ? '' : part);
|
|
188
|
+
// Get the longest of them.
|
|
189
|
+
const sortedPlainParts = plainParts.sort((a, b) => b.length - a.length);
|
|
190
|
+
const mainPart = sortedPlainParts.length ? sortedPlainParts[0] : '';
|
|
191
|
+
// If there is one:
|
|
192
|
+
if (mainPart.trim().replace(/\s+/g, '').length) {
|
|
193
|
+
// Get locators for elements with the tag name and the text.
|
|
194
|
+
const locators = page.locator(tagName.toLowerCase(), {hasText: mainPart});
|
|
195
|
+
// If there is exactly 1 of them:
|
|
196
|
+
const locatorCount = await locators.count();
|
|
197
|
+
if (locatorCount === 1) {
|
|
198
|
+
// Add a box ID and a path ID to the result.
|
|
199
|
+
await addIDs(locators, elementID);
|
|
200
|
+
}
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
}
|
|
204
|
+
// If the tag name is invalid:
|
|
205
|
+
catch(error) {
|
|
206
|
+
// Add this to the instance.
|
|
207
|
+
instance.invalidity = {
|
|
208
|
+
badProperty: 'tagName',
|
|
209
|
+
validityError: error.message
|
|
210
|
+
};
|
|
211
|
+
}
|
|
202
212
|
}
|
|
203
213
|
// Return the result (not yet getting IDs from Nu Html Checker lines and columns).
|
|
204
214
|
return elementID;
|
package/tests/aslint.js
CHANGED
|
@@ -85,17 +85,6 @@ exports.reporter = async (page, report, actIndex, timeLimit) => {
|
|
|
85
85
|
timeout: 1000 * timeLimit
|
|
86
86
|
};
|
|
87
87
|
await reportLoc.waitFor(waitOptions);
|
|
88
|
-
// const timeResult = await doBy(timeLimit, reportLoc, 'waitFor', [waitArg], 'aslint testing');
|
|
89
|
-
// console.log(`timeResult type is ${typeof timeResult}`);
|
|
90
|
-
// If the result attachment timed out:
|
|
91
|
-
/*
|
|
92
|
-
if (timeResult === 'timedOut') {
|
|
93
|
-
// Report this.
|
|
94
|
-
data.prevented = true;
|
|
95
|
-
data.error = 'Attachment of results to page by aslint timed out';
|
|
96
|
-
await page.close({runBeforeUnload: true});
|
|
97
|
-
}
|
|
98
|
-
*/
|
|
99
88
|
}
|
|
100
89
|
catch(error) {
|
|
101
90
|
const message = 'Attachment of test results to page failed';
|
package/tests/wave.js
CHANGED
|
@@ -58,57 +58,66 @@ exports.reporter = async (page, report, actIndex) => {
|
|
|
58
58
|
// When they arrive:
|
|
59
59
|
response.on('end', async () => {
|
|
60
60
|
// Delete unnecessary properties.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
61
|
+
try {
|
|
62
|
+
const actResult = JSON.parse(rawReport);
|
|
63
|
+
const {categories, statistics} = actResult;
|
|
64
|
+
delete categories.feature;
|
|
65
|
+
delete categories.structure;
|
|
66
|
+
delete categories.aria;
|
|
67
|
+
// If rules were specified:
|
|
68
|
+
if (rules && rules.length) {
|
|
69
|
+
// For each WAVE rule category:
|
|
70
|
+
['error', 'contrast', 'alert'].forEach(category => {
|
|
71
|
+
// If any violations were reported:
|
|
72
|
+
if (
|
|
73
|
+
categories[category]
|
|
74
|
+
&& categories[category].items
|
|
75
|
+
&& Object.keys(categories[category].items).length
|
|
76
|
+
) {
|
|
77
|
+
// For each rule violated:
|
|
78
|
+
Object.keys(categories[category].items).forEach(ruleID => {
|
|
79
|
+
// If it was not a specified rule:
|
|
80
|
+
if (! rules.includes(ruleID)) {
|
|
81
|
+
// Decrease the category violation count by the count of its violations.
|
|
82
|
+
categories[category].count -= categories[category].items[ruleID].count;
|
|
83
|
+
// Remove its violations from the report.
|
|
84
|
+
delete categories[category].items[ruleID];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Add WCAG information from the WAVE documentation.
|
|
91
|
+
const waveDocJSON = await fs.readFile('procs/wavedoc.json');
|
|
92
|
+
const waveDoc = JSON.parse(waveDocJSON);
|
|
93
|
+
Object.keys(categories).forEach(categoryName => {
|
|
94
|
+
const category = categories[categoryName];
|
|
95
|
+
const {items} = category;
|
|
96
|
+
Object.keys(items).forEach(issueName => {
|
|
97
|
+
const issueDoc = waveDoc.find((issue => issue.name === issueName));
|
|
98
|
+
const {guidelines} = issueDoc;
|
|
99
|
+
items[issueName].wcag = guidelines;
|
|
100
|
+
});
|
|
87
101
|
});
|
|
102
|
+
// Add important data to the result.
|
|
103
|
+
if (statistics) {
|
|
104
|
+
data.pageTitle = statistics.pagetitle || '';
|
|
105
|
+
data.pageURL = statistics.pageurl || '';
|
|
106
|
+
data.time = statistics.time || null;
|
|
107
|
+
data.creditsRemaining = statistics.creditsremaining || null;
|
|
108
|
+
data.allItemCount = statistics.allitemcount || null;
|
|
109
|
+
data.totalElements = statistics.totalelements || null;
|
|
110
|
+
}
|
|
111
|
+
// Return the result.
|
|
112
|
+
resolve(actResult);
|
|
88
113
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const issueDoc = waveDoc.find((issue => issue.name === issueName));
|
|
97
|
-
const {guidelines} = issueDoc;
|
|
98
|
-
items[issueName].wcag = guidelines;
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
// Add important data to the result.
|
|
102
|
-
if (statistics) {
|
|
103
|
-
data.pageTitle = statistics.pagetitle || '';
|
|
104
|
-
data.pageURL = statistics.pageurl || '';
|
|
105
|
-
data.time = statistics.time || null;
|
|
106
|
-
data.creditsRemaining = statistics.creditsremaining || null;
|
|
107
|
-
data.allItemCount = statistics.allitemcount || null;
|
|
108
|
-
data.totalElements = statistics.totalelements || null;
|
|
109
|
-
}
|
|
110
|
-
// Return the result.
|
|
111
|
-
resolve(actResult);
|
|
114
|
+
catch(error) {
|
|
115
|
+
console.log(`ERROR parsing tool report: ${error.message}`);
|
|
116
|
+
console.log(`rawReport: ${rawReport}`);
|
|
117
|
+
data.prevented = true;
|
|
118
|
+
data.error = error.message;
|
|
119
|
+
resolve(result);
|
|
120
|
+
};
|
|
112
121
|
});
|
|
113
122
|
}
|
|
114
123
|
);
|