Skip to content

Commit fcc51eb

Browse files
committed
fix: incomplete results should have impact
1 parent 93a0273 commit fcc51eb

File tree

5 files changed

+45
-23
lines changed

5 files changed

+45
-23
lines changed

lib/core/utils/aggregateChecks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { CANTTELL_PRIO, FAIL_PRIO } = axe.constants;
12
let checkMap = [];
23
checkMap[axe.constants.PASS_PRIO] = true;
34
checkMap[axe.constants.CANTTELL_PRIO] = null;
@@ -51,9 +52,8 @@ axe.utils.aggregateChecks = function (nodeResOriginal) {
5152
nodeResult[type].forEach((check) => impacts.push(check.impact));
5253
});
5354

54-
5555
// for failed nodes, define the impact
56-
if (nodeResult.priority === axe.constants.FAIL_PRIO) {
56+
if ([CANTTELL_PRIO, FAIL_PRIO].includes(nodeResult.priority)) {
5757
nodeResult.impact = axe.utils.aggregate(axe.constants.impact, impacts);
5858
} else {
5959
nodeResult.impact = null;

lib/core/utils/aggregateRule.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ axe.utils.aggregateRule = function (subResults) {
3535
ruleResult[groupName].push(subResult);
3636
});
3737

38-
// Take the highest impact of failed rules
39-
var failGroup = axe.constants.FAIL_GROUP;
40-
if (ruleResult[failGroup].length > 0) {
41-
// Get the impact of all violations
42-
let impactList = ruleResult[failGroup]
38+
// Take the highest impact of failed or canttell rules
39+
var impactGroup = axe.constants.FAIL_GROUP;
40+
if (ruleResult[impactGroup].length === 0) {
41+
impactGroup = axe.constants.CANTTELL_GROUP;
42+
}
43+
44+
if (ruleResult[impactGroup].length > 0) {
45+
// Get the impact of all issues
46+
let impactList = ruleResult[impactGroup]
4347
.map((failure) => failure.impact);
4448

4549
ruleResult.impact = axe.utils.aggregate(axe.constants.impact, impactList) || null;

test/core/utils/aggregateChecks.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ describe('axe.utils.aggregateChecks', function() {
5454
});
5555
});
5656

57+
it('returns impact for fail and canttell', function () {
58+
var failCheck = axe.utils.aggregateChecks( createTestCheckResults({
59+
any: [{ result: false, impact: 'serious' }]
60+
}));
61+
var canttellCheck = axe.utils.aggregateChecks( createTestCheckResults({
62+
any: [{ result: undefined, impact: 'moderate' }]
63+
}));
64+
65+
assert.equal(failCheck.impact, 'serious');
66+
assert.equal(canttellCheck.impact, 'moderate');
67+
});
68+
69+
it('sets impact to null for pass', function () {
70+
var passCheck = axe.utils.aggregateChecks( createTestCheckResults({
71+
any: [{ result: true, impact: 'serious' }]
72+
}));
73+
assert.isNull(passCheck.impact);
74+
});
5775

5876
describe('none', function () {
5977
it('gives result FAIL when any is true', function() {

test/core/utils/aggregateRule.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ describe('axe.utils.aggregateRule', function() {
107107
assert.lengthOf(ruleResult.passes, 1);
108108
});
109109

110+
it('should provide impact on incomplete', function () {
111+
var ruleResult = axe.utils.aggregateRule( createTestResults({
112+
none: { result: undefined, impact: 'serious' }
113+
}));
114+
assert.equal(ruleResult.impact, 'serious');
115+
});
116+
110117
it('should raise the highest "raisedMetadata" on failing checks', function() {
111118
var ruleResult = axe.utils.aggregateRule( createTestResults({
112119
none: { result: true, impact: 'moderate' },
@@ -116,12 +123,12 @@ describe('axe.utils.aggregateRule', function() {
116123
{ result: false, impact: 'serious'}
117124
]
118125
},
119-
{ none: { result: false, impact: 'critical' }},
126+
{ none: { result: undefined, impact: 'critical' }},
120127
{ none: { result: false, impact: 'critical' }}
121128
));
122129
assert.equal(ruleResult.impact, 'serious');
123130
assert.equal(ruleResult.violations[0].impact, 'serious');
131+
assert.equal(ruleResult.incomplete[0].impact, 'critical');
124132
assert.isNull(ruleResult.passes[0].impact);
125-
assert.isNull(ruleResult.passes[1].impact);
126133
});
127134
});

test/playground.html

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,17 @@
22
<html lang="en">
33
<title>O hai</title>
44

5-
<div style="
6-
height: 50px;
7-
width: 50px;
8-
border: solid 1px black;
9-
overflow: auto;
10-
">
11-
<p>foofoofoofoofoofoo</p>
12-
<p>foofoofoofoofoofoo</p>
13-
<p>foofoofoofoofoofoo</p>
14-
<p>foofoofoofoofoofoo</p>
15-
<p>foofoofoofoofoofoo</p>
16-
</div>
5+
<video src="https://youtu.be/cgbJo5fuFMo"></video>
6+
<p style="color: #ccc">Some text</p>
7+
<p style="background:url(https://bennettfeely.com/gradients/img/gradient_24.png)">
8+
Some more text</p>
179

1810
<script src="/axe.js"></script>
1911
<script>
2012
window.addEventListener('load' , function () {
21-
axe.a11yCheck(document, { restoreScroll: true }, function (res) {
22-
console.log(res);
13+
axe.run(document, function (err, res) {
14+
console.log(res.violations[0]);
15+
res.incomplete.forEach(issue => console.log(issue))
2316
});
2417
})
2518
</script>

0 commit comments

Comments
 (0)