testaro 33.1.3 → 34.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/README.md +1 -1
- package/package.json +1 -1
- package/procs/standardize.js +27 -51
- package/run.js +1 -1
- package/tests/aslint.js +9 -3
package/README.md
CHANGED
|
@@ -424,7 +424,7 @@ When you include a `rules` property, you limit the tests of the tool that are pe
|
|
|
424
424
|
|
|
425
425
|
The `nuVal`, `qualWeb`, and `testaro` tools require specific formats for the `rules` property. Those formats are described below in the sections about those tools.
|
|
426
426
|
|
|
427
|
-
The `
|
|
427
|
+
The `ed11y` tool does not yet allow rule specification.
|
|
428
428
|
|
|
429
429
|
###### Examples
|
|
430
430
|
|
package/package.json
CHANGED
package/procs/standardize.js
CHANGED
|
@@ -61,7 +61,12 @@ const getIdentifiers = code => {
|
|
|
61
61
|
}
|
|
62
62
|
return [tagName, id];
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
/*
|
|
65
|
+
Differentiates some rule IDs of aslint.
|
|
66
|
+
If the purported rule ID is a key and the what property contains all of the strings except the
|
|
67
|
+
last of any array item of the value of that key, then the final rule ID is the last item of that
|
|
68
|
+
array item.
|
|
69
|
+
*/
|
|
65
70
|
const aslintData = {
|
|
66
71
|
'misused_required_attribute': [
|
|
67
72
|
['not needed', 'misused_required_attributeR']
|
|
@@ -293,7 +298,6 @@ const doQualWeb = (result, standardResult, ruleClassName) => {
|
|
|
293
298
|
excerpt: cap(htmlCode)
|
|
294
299
|
};
|
|
295
300
|
standardResult.instances.push(instance);
|
|
296
|
-
standardResult.totals[instance.ordinalSeverity]++;
|
|
297
301
|
});
|
|
298
302
|
});
|
|
299
303
|
});
|
|
@@ -345,7 +349,6 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
345
349
|
}
|
|
346
350
|
// alfa
|
|
347
351
|
else if (toolName === 'alfa' && result.totals) {
|
|
348
|
-
standardResult.totals = [result.totals.warnings, 0, 0, result.totals.failures];
|
|
349
352
|
result.items.forEach(item => {
|
|
350
353
|
const {codeLines} = item.target;
|
|
351
354
|
const code = Array.isArray(codeLines) ? codeLines.join(' ') : '';
|
|
@@ -375,10 +378,6 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
375
378
|
}
|
|
376
379
|
// aslint
|
|
377
380
|
else if (toolName === 'aslint' && result.summary && result.summary.byIssueType) {
|
|
378
|
-
// Get the totals.
|
|
379
|
-
standardResult.totals = [
|
|
380
|
-
result.summary.byIssueType.warning, 0, 0, result.summary.byIssueType.error
|
|
381
|
-
];
|
|
382
381
|
// For each rule:
|
|
383
382
|
Object.keys(result.rules).forEach(ruleID => {
|
|
384
383
|
// If it has a valid issue type:
|
|
@@ -396,7 +395,7 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
396
395
|
&& ruleResult.message.actual.description
|
|
397
396
|
) {
|
|
398
397
|
const what = ruleResult.message.actual.description;
|
|
399
|
-
// Get
|
|
398
|
+
// Get the differentiated ID of the rule if any.
|
|
400
399
|
const ruleData = aslintData[ruleID];
|
|
401
400
|
let finalRuleID = ruleID;
|
|
402
401
|
if (ruleData) {
|
|
@@ -407,6 +406,7 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
407
406
|
finalRuleID = changer[changer.length - 1];
|
|
408
407
|
}
|
|
409
408
|
}
|
|
409
|
+
// Get the instance properties.
|
|
410
410
|
const xpath = ruleResult.element && ruleResult.element.xpath || '';
|
|
411
411
|
let tagName = xpath
|
|
412
412
|
&& xpath.replace(/^.*\//, '').replace(/[^-\w].*$/, '').toUpperCase()
|
|
@@ -449,13 +449,6 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
449
449
|
&& result.totals
|
|
450
450
|
&& (result.totals.rulesWarned || result.totals.rulesViolated)
|
|
451
451
|
) {
|
|
452
|
-
const {totals} = result;
|
|
453
|
-
standardResult.totals = [
|
|
454
|
-
totals.warnings.minor + totals.warnings.moderate,
|
|
455
|
-
totals.warnings.serious + totals.warnings.critical,
|
|
456
|
-
totals.violations.minor + totals.violations.moderate,
|
|
457
|
-
totals.violations.serious + totals.violations.critical
|
|
458
|
-
];
|
|
459
452
|
doAxe(result, standardResult, 'incomplete');
|
|
460
453
|
doAxe(result, standardResult, 'violations');
|
|
461
454
|
}
|
|
@@ -465,11 +458,8 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
465
458
|
&& result
|
|
466
459
|
&& ['results', 'errorCount', 'warningCount'].every(key => result[key] !== undefined)
|
|
467
460
|
) {
|
|
468
|
-
// Populate the totals of the standard result.
|
|
469
|
-
const {results, errorCount, warningCount} = result;
|
|
470
|
-
standardResult.totals = [warningCount, 0, errorCount, 0];
|
|
471
461
|
// For each result:
|
|
472
|
-
results.forEach(result => {
|
|
462
|
+
result.results.forEach(result => {
|
|
473
463
|
const {test, content, tagName, id, loc, excerpt} = result;
|
|
474
464
|
if (['test', 'content'].every(key => result[key])) {
|
|
475
465
|
// Standardize the what property.
|
|
@@ -501,17 +491,9 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
501
491
|
else if (toolName === 'htmlcs' && result) {
|
|
502
492
|
doHTMLCS(result, standardResult, 'Warning');
|
|
503
493
|
doHTMLCS(result, standardResult, 'Error');
|
|
504
|
-
const {instances} = standardResult;
|
|
505
|
-
standardResult.totals = [
|
|
506
|
-
instances.filter(instance => instance.ordinalSeverity === 0).length,
|
|
507
|
-
0,
|
|
508
|
-
0,
|
|
509
|
-
instances.filter(instance => instance.ordinalSeverity === 3).length
|
|
510
|
-
];
|
|
511
494
|
}
|
|
512
495
|
// ibm
|
|
513
496
|
else if (toolName === 'ibm' && result.totals) {
|
|
514
|
-
standardResult.totals = [0, result.totals.recommendation, 0, result.totals.violation];
|
|
515
497
|
if (result.items) {
|
|
516
498
|
result.items.forEach(item => {
|
|
517
499
|
const identifiers = getIdentifiers(item.snippet);
|
|
@@ -547,12 +529,6 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
547
529
|
doNuVal(result, standardResult, 'rawPage');
|
|
548
530
|
}
|
|
549
531
|
const {instances} = standardResult;
|
|
550
|
-
standardResult.totals = [
|
|
551
|
-
instances.filter(instance => instance.ordinalSeverity === 0).length,
|
|
552
|
-
0,
|
|
553
|
-
instances.filter(instance => instance.ordinalSeverity === 2).length,
|
|
554
|
-
instances.filter(instance => instance.ordinalSeverity === 3).length,
|
|
555
|
-
];
|
|
556
532
|
}
|
|
557
533
|
// qualWeb
|
|
558
534
|
else if (
|
|
@@ -564,7 +540,6 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
564
540
|
|| result.modules['best-practices']
|
|
565
541
|
)
|
|
566
542
|
) {
|
|
567
|
-
standardResult.totals = [0, 0, 0, 0];
|
|
568
543
|
if (result.modules['act-rules']) {
|
|
569
544
|
doQualWeb(result, standardResult, 'act-rules');
|
|
570
545
|
}
|
|
@@ -577,24 +552,29 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
577
552
|
}
|
|
578
553
|
// testaro
|
|
579
554
|
else if (toolName === 'testaro') {
|
|
555
|
+
// For each violated rule:
|
|
580
556
|
const rules = result ? Object.keys(result) : [];
|
|
581
|
-
standardResult.totals = [0, 0, 0, 0];
|
|
582
557
|
rules.forEach(rule => {
|
|
558
|
+
// Copy its instances to the standard result.
|
|
583
559
|
const ruleResult = result[rule];
|
|
584
|
-
standardResult.totals.forEach((total, index) => {
|
|
585
|
-
standardResult.totals[index] += ruleResult
|
|
586
|
-
&& ruleResult.totals ? ruleResult.totals[index] || 0 : 0;
|
|
587
|
-
});
|
|
588
560
|
if (ruleResult.standardInstances) {
|
|
589
561
|
standardResult.instances.push(... ruleResult.standardInstances);
|
|
590
562
|
}
|
|
591
563
|
else {
|
|
592
564
|
console.log(`ERROR: Testaro rule ${rule} result has no standardInstances property`);
|
|
593
565
|
}
|
|
566
|
+
// Add its (sample-ratio-weighted) totals to the totals of the standard result.
|
|
567
|
+
if (ruleResult.totals) {
|
|
568
|
+
for (const index in ruleResult.totals) {
|
|
569
|
+
standardResult.totals[index] += ruleResult.totals[index];
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
console.log(`ERROR: Testaro rule ${rule} result has no totals property`);
|
|
574
|
+
}
|
|
594
575
|
});
|
|
595
576
|
const preventionCount = result.preventions && result.preventions.length;
|
|
596
577
|
if (preventionCount) {
|
|
597
|
-
standardResult.totals[3] += preventionCount;
|
|
598
578
|
standardResult.instances.push({
|
|
599
579
|
ruleID: 'testPrevention',
|
|
600
580
|
what: 'Page prevented tests from being performed',
|
|
@@ -606,7 +586,6 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
606
586
|
excerpt: ''
|
|
607
587
|
});
|
|
608
588
|
}
|
|
609
|
-
standardResult.totals = standardResult.totals.map(total => Math.round(total));
|
|
610
589
|
}
|
|
611
590
|
// wave
|
|
612
591
|
else if (
|
|
@@ -618,21 +597,18 @@ const convert = (toolName, data, result, standardResult) => {
|
|
|
618
597
|
|| result.categories.alert
|
|
619
598
|
)
|
|
620
599
|
) {
|
|
621
|
-
const {categories} = result;
|
|
622
|
-
standardResult.totals = [
|
|
623
|
-
categories.alert.count || 0,
|
|
624
|
-
0,
|
|
625
|
-
0,
|
|
626
|
-
(categories.error.count || 0) + (categories.contrast.count || 0)
|
|
627
|
-
];
|
|
628
600
|
['error', 'contrast', 'alert'].forEach(categoryName => {
|
|
629
601
|
doWAVE(result, standardResult, categoryName);
|
|
630
602
|
});
|
|
631
603
|
}
|
|
632
|
-
//
|
|
633
|
-
|
|
634
|
-
standardResult.
|
|
604
|
+
// Populate the totals of the standard result if the tool is not Testaro.
|
|
605
|
+
if (toolName !== 'testaro') {
|
|
606
|
+
standardResult.instances.forEach(instance => {
|
|
607
|
+
standardResult.totals[instance.ordinalSeverity] += instance.count || 1;
|
|
608
|
+
});
|
|
635
609
|
}
|
|
610
|
+
// Round the totals of the standard result.
|
|
611
|
+
standardResult.totals = standardResult.totals.map(total => Math.round(total));
|
|
636
612
|
};
|
|
637
613
|
// Converts the results.
|
|
638
614
|
exports.standardize = act => {
|
package/run.js
CHANGED
package/tests/aslint.js
CHANGED
|
@@ -43,7 +43,7 @@ exports.reporter = async (page, options) => {
|
|
|
43
43
|
`${__dirname}/../node_modules/aslint-testaro/aslint.bundle.js`, 'utf8'
|
|
44
44
|
);
|
|
45
45
|
// Get the nonce, if any.
|
|
46
|
-
const {report} = options;
|
|
46
|
+
const {act, report} = options;
|
|
47
47
|
const {jobData} = report;
|
|
48
48
|
const scriptNonce = jobData && jobData.lastScriptNonce;
|
|
49
49
|
// Inject the ASLint bundle and runner into the page.
|
|
@@ -94,10 +94,16 @@ exports.reporter = async (page, options) => {
|
|
|
94
94
|
const actReport = await reportLoc.textContent();
|
|
95
95
|
// Populate the act report.
|
|
96
96
|
result = JSON.parse(actReport);
|
|
97
|
-
//
|
|
97
|
+
// If any rules were reported violated:
|
|
98
98
|
if (result.rules) {
|
|
99
|
+
// For each such rule:
|
|
99
100
|
Object.keys(result.rules).forEach(ruleID => {
|
|
100
|
-
|
|
101
|
+
// If the rule was passed or skipped or rules to be tested were specified and exclude it:
|
|
102
|
+
const excluded = act.rules && ! act.rules.includes(ruleID);
|
|
103
|
+
const instanceType = result.rules[ruleID].status.type;
|
|
104
|
+
// If rules to be tested were specified and exclude it or the rule was passed or skipped:
|
|
105
|
+
if (excluded || ['passed', 'skipped'].includes(instanceType)) {
|
|
106
|
+
// Delete the rule report.
|
|
101
107
|
delete result.rules[ruleID];
|
|
102
108
|
}
|
|
103
109
|
});
|