open-nomad/ui/tests/helpers/a11y-audit.js
Buck Doyle 29de8f4f76
Add component accessibility auditing and fixes (#8679)
This continues #8455 by adding accessibility audits to component integration
tests and fixing associated errors. It adds audits to existing tests rather than
adding separate ones to facilitate auditing the various permutations a
component’s rendering can go through.

It also adds linting to ensure audits happen in component tests. This
necessitated consolidating test files that were scattered.
2020-08-25 10:56:02 -05:00

27 lines
719 B
JavaScript

import a11yAudit from 'ember-a11y-testing/test-support/audit';
function appendRuleOverrides(overriddenRules) {
const rules = {
'color-contrast': {
enabled: false,
},
'heading-order': {
enabled: false,
},
};
overriddenRules.forEach(rule => (rules[rule] = { enabled: false }));
return rules;
}
export default async function defaultA11yAudit(assert, ...overriddenRules) {
await a11yAudit({ rules: appendRuleOverrides(overriddenRules) });
assert.ok(true, 'a11y audit passes');
}
export async function componentA11yAudit(element, assert, ...overriddenRules) {
await a11yAudit(element, { rules: appendRuleOverrides(overriddenRules) });
assert.ok(true, 'a11y audit passes');
}