Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aria-roledescription): keep disabled with { runOnly: 'wcag2a' } #4526

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default class Audit {
this.checks = {};
this.brand = 'axe';
this.application = 'axeAPI';
this.tagExclude = ['experimental'];
this.tagExclude = ['experimental', 'deprecated'];
this.noHtml = audit.noHtml;
this.allowedOrigins = audit.allowedOrigins;
unpackToObject(audit.rules, this, 'addRule');
Expand Down
4 changes: 2 additions & 2 deletions test/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,12 @@ describe('Audit', () => {
});
it('should reset brand tagExlcude', () => {
axe._load({});
assert.deepEqual(axe._audit.tagExclude, ['experimental']);
assert.deepEqual(axe._audit.tagExclude, ['experimental', 'deprecated']);
axe.configure({
tagExclude: ['ninjas']
});
axe._audit.resetRulesAndChecks();
assert.deepEqual(axe._audit.tagExclude, ['experimental']);
assert.deepEqual(axe._audit.tagExclude, ['experimental', 'deprecated']);
});

it('should reset noHtml', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/core/public/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ describe('axe.configure', function () {

it('overrides the default value of audit.tagExclude', function () {
axe._load({});
assert.deepEqual(axe._audit.tagExclude, ['experimental']);
assert.deepEqual(axe._audit.tagExclude, ['experimental', 'deprecated']);

axe.configure({
tagExclude: ['ninjas']
Expand Down
31 changes: 31 additions & 0 deletions test/integration/full/configuration/tag-exclude.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en" xml:lang="en">
<head>
<title>axe.configure({ tagExclude }) test</title>
<meta charset="utf8" />
<link
rel="stylesheet"
type="text/css"
href="/node_modules/mocha/mocha.css"
/>
<script src="/node_modules/mocha/mocha.js"></script>
<script src="/node_modules/chai/chai.js"></script>
<script src="/axe.js"></script>
<script>
mocha.setup({
timeout: 10000,
ui: 'bdd'
});
var assert = chai.assert;
</script>
</head>
<body>
<img alt="" />

<div id="mocha"></div>
<script src="/test/integration/no-ui-reporter.js"></script>
<script src="/test/testutils.js"></script>
<script src="tag-exclude.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
</html>
112 changes: 112 additions & 0 deletions test/integration/full/configuration/tag-exclude.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
describe('all rules test', () => {
const experimentalRuleId = 'img-alt-experimental';
const deprecatedRuleId = 'img-alt-deprecated';

beforeEach(() => {
axe.configure({
rules: [
{
id: experimentalRuleId,
impact: 'critical',
selector: 'img',
tags: ['wcag2a', 'experimental'],
enabled: false,
metadata: {
description:
'Ensures <img> elements have alternate text or a role of none or presentation',
help: 'Images must have alternate text'
},
all: [],
any: ['has-alt'],
none: []
},
{
id: deprecatedRuleId,
impact: 'critical',
selector: 'img',
tags: ['wcag2a', 'deprecated'],
enabled: false,
metadata: {
description:
'Ensures <img> elements have alternate text or a role of none or presentation',
help: 'Images must have alternate text'
},
all: [],
any: ['has-alt'],
none: []
}
]
});
});

after(() => {
axe.reset();
});

function findResult(results, ruleId) {
return [
...results.violations,
...results.passes,
...results.incomplete,
...results.inapplicable
].find(result => result.id === ruleId);
}

it('does not run experimental rules by default', async () => {
const results = await axe.run({
runOnly: {
type: 'tags',
values: ['wcag2a']
}
});
assert.isUndefined(findResult(results, experimentalRuleId));
});

it('does not run deprecated rules by default', async () => {
const results = await axe.run({
runOnly: {
type: 'tags',
values: ['wcag2a']
}
});
assert.isUndefined(findResult(results, deprecatedRuleId));
});

it('runs tagExclude rules when enabled with { rules }', async () => {
const results = await axe.run({
runOnly: {
type: 'tags',
values: ['wcag2a']
},
rules: {
[experimentalRuleId]: { enabled: true },
[deprecatedRuleId]: { enabled: true }
}
});

assert.isDefined(findResult(results, experimentalRuleId));
assert.isDefined(findResult(results, deprecatedRuleId));
});

it('runs tagExclude rules when enabled with { runOnly: { type: rule } }', async () => {
const results = await axe.run({
runOnly: {
type: 'rule',
values: [experimentalRuleId, deprecatedRuleId]
}
});
assert.isDefined(findResult(results, experimentalRuleId));
assert.isDefined(findResult(results, deprecatedRuleId));
});

it('runs tagExclude rules when enabled with { runOnly: { type: tag } }', async () => {
const results = await axe.run({
runOnly: {
type: 'tag',
values: ['wcag2a', 'experimental', 'deprecated']
}
});
assert.isDefined(findResult(results, experimentalRuleId));
assert.isDefined(findResult(results, deprecatedRuleId));
});
});
Loading