Skip to content

Commit

Permalink
Task: update branding a11y tests to ignore role set on label elem…
Browse files Browse the repository at this point in the history
…ent (#1863)

* feat: add option to configure axe before running it; update branding test to use custom rules

* fix: ignore link role in a11y tests
  • Loading branch information
andrewleith committed Jun 13, 2024
1 parent e9437b8 commit e20a226
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests_cypress/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = defineConfig({
rules: {
"form-dup-name": "off",
"prefer-native-element": ["error", {
"exclude": ["button"]
"exclude": ["button", "link"]
}],
},
});
Expand Down Expand Up @@ -52,6 +52,6 @@ module.exports = defineConfig({
viewportWidth: 1280,
viewportHeight: 850,
testIsolation: true,
retries: 3
// retries: 3
},
});
6 changes: 6 additions & 0 deletions tests_cypress/cypress/e2e/admin/branding/a11y.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ describe("Branding A11Y", () => {
htmlValidate: true,
deadLinks: false,
mimeTypes: false,
axeConfig: [
{
id: "aria-allowed-role",
enabled: false,
},
],
},
);
});
Expand Down
7 changes: 5 additions & 2 deletions tests_cypress/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LoginPage from "../Notify/Admin/Pages/LoginPage";
let links_checked = [];
let svgs_checked = [];

Cypress.Commands.add('a11yScan', (url, options = { a11y: true, htmlValidate: true, deadLinks: true, mimeTypes: true }) => {
Cypress.Commands.add('a11yScan', (url, options = { a11y: true, htmlValidate: true, deadLinks: true, mimeTypes: true, axeConfig: false }) => {
const current_hostname = config.Hostnames.Admin;
// bypass rate limiting
cy.intercept(`${current_hostname}/*`, (req) => {
Expand All @@ -18,7 +18,10 @@ Cypress.Commands.add('a11yScan', (url, options = { a11y: true, htmlValidate: tru
// 1. validate a11y rules using axe dequeue
if (options.a11y) {
cy.injectAxe();
cy.checkA11y();

if (options.axeConfig) {
cy.configureAxe({ rules: options.axeConfig });
}
}

// 2. validate html
Expand Down

0 comments on commit e20a226

Please sign in to comment.