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 1 commit
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
32 changes: 32 additions & 0 deletions test/integration/full/configuration/tag-exclude.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!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>
<p aria-roledescription="my paragraph" id="deprecated">paragraph</p>
<div role="link" aria-label="OK" id="experimental">Next</div>

<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>
102 changes: 102 additions & 0 deletions test/integration/full/configuration/tag-exclude.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
describe('all rules test', () => {
const experimentalRuleId = 'label-content-name-mismatch';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relies on the current state of axe and rules that could be made non-experimental or removed eventually. It would be better to configure axe with custom rules that are experimental and deprecated and test those ones instead.

const deprecatedRuleId = 'aria-roledescription';

function joinResults(results) {
return [
...results.violations,
...results.passes,
...results.incomplete,
...results.inapplicable
];
}

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

const joinedResults = joinResults(results);
const experimentalResult = joinedResults.find(
result => result.id === experimentalRuleId
);
assert.isUndefined(experimentalResult);
});

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

const joinedResults = joinResults(results);
const deprecatedResult = joinedResults.find(
result => result.id === deprecatedRuleId
);
assert.isUndefined(deprecatedResult);
});

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

const joinedResults = joinResults(results);
const experimentalResult = joinedResults.find(
result => result.id === experimentalRuleId
);
const deprecatedResult = joinedResults.find(
result => result.id === experimentalRuleId
);
assert.isDefined(experimentalResult);
assert.isDefined(deprecatedResult);
});

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

it('runs tagExclude rules when enabled with { runOnly: { type: tag } }', async () => {
const results = await axe.run({
runOnly: {
type: 'tag',
values: ['wcag2a', 'wcag21a', 'experimental', 'deprecated']
}
});
const joinedResults = joinResults(results);
const experimentalResult = joinedResults.find(
result => result.id === experimentalRuleId
);
const deprecatedResult = joinedResults.find(
result => result.id === experimentalRuleId
);
assert.isDefined(experimentalResult);
assert.isDefined(deprecatedResult);
});
});
Loading