Skip to content

Commit 6fe2ae5

Browse files
committed
test(plugin-axe): add coverage for multi-check issues
1 parent 6c3dff0 commit 6fe2ae5

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

packages/plugin-axe/src/lib/runner/transform.unit.test.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,113 @@ describe('toAuditOutputs', () => {
385385
]);
386386
});
387387

388+
it('should join none and all check messages', () => {
389+
const results = createMockAxeResults({
390+
violations: [
391+
createMockResult('aria-allowed-attr', [
392+
createMockNode({
393+
html: '<div role="button" aria-checked="true" aria-invalid-attr="x"></div>',
394+
target: ['div'],
395+
impact: 'critical',
396+
none: [
397+
createMockCheck({
398+
id: 'aria-unsupported-attr',
399+
message:
400+
'aria-invalid-attr attribute is not supported for role button',
401+
}),
402+
],
403+
all: [
404+
createMockCheck({
405+
id: 'aria-allowed-attr',
406+
message:
407+
'aria-checked attribute is not allowed for role button',
408+
}),
409+
],
410+
}),
411+
]),
412+
],
413+
});
414+
415+
expect(toAuditOutputs(results, 'https://example.com')).toStrictEqual<
416+
AuditOutput[]
417+
>([
418+
{
419+
slug: 'aria-allowed-attr',
420+
score: 0,
421+
value: 1,
422+
displayValue: '1 error',
423+
details: {
424+
issues: [
425+
{
426+
message:
427+
'aria-invalid-attr attribute is not supported for role button. aria-checked attribute is not allowed for role button',
428+
severity: 'error',
429+
source: {
430+
url: 'https://example.com',
431+
snippet:
432+
'<div role="button" aria-checked="true" aria-invalid-attr="x"></div>',
433+
selector: 'div',
434+
},
435+
},
436+
],
437+
},
438+
},
439+
]);
440+
});
441+
442+
it('should join multiple all check messages', () => {
443+
const results = createMockAxeResults({
444+
violations: [
445+
createMockResult('aria-hidden-focus', [
446+
createMockNode({
447+
html: '<div aria-hidden="true"><button>Click</button></div>',
448+
target: ['div'],
449+
impact: 'serious',
450+
all: [
451+
createMockCheck({
452+
id: 'focusable-modal-open',
453+
message: 'No focusable modal is open',
454+
}),
455+
createMockCheck({
456+
id: 'focusable-disabled',
457+
message: 'Element is keyboard accessible',
458+
}),
459+
createMockCheck({
460+
id: 'focusable-not-tabbable',
461+
message: 'Element is in tab order',
462+
}),
463+
],
464+
}),
465+
]),
466+
],
467+
});
468+
469+
expect(toAuditOutputs(results, 'https://example.com')).toStrictEqual<
470+
AuditOutput[]
471+
>([
472+
{
473+
slug: 'aria-hidden-focus',
474+
score: 0,
475+
value: 1,
476+
displayValue: '1 error',
477+
details: {
478+
issues: [
479+
{
480+
message:
481+
'No focusable modal is open. Element is keyboard accessible. Element is in tab order',
482+
severity: 'error',
483+
source: {
484+
url: 'https://example.com',
485+
snippet: '<div aria-hidden="true"><button>Click</button></div>',
486+
selector: 'div',
487+
},
488+
},
489+
],
490+
},
491+
},
492+
]);
493+
});
494+
388495
it('should omit selector when target is missing', () => {
389496
const results = createMockAxeResults({
390497
violations: [

0 commit comments

Comments
 (0)