Skip to content

Commit

Permalink
test(a11y): add accessibility tests (#27)
Browse files Browse the repository at this point in the history
* test(a11y): add accessibility tests

* skip for now

* add other pages to a11y test

* chore: update packages and add hooks apge

* skip tests for now

* test: expand all the things
  • Loading branch information
wass3r authored and jbrockopp committed Dec 4, 2019
1 parent f5a343e commit 8628a06
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"baseUrl": "http://localhost:8888",
"video": false
}
}
88 changes: 88 additions & 0 deletions cypress/integration/a11y.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
const A11Y_OPTS = {
runOnly: {
type: "tag",
values: ["section508", "best-practice", "wcag21aa", "wcag2aa"]
}
};

context("Accessibility (a11y)", () => {
context("Logged out", () => {
it.skip("overview", () => {
cy.clearSession();
cy.visit("/account/login");
cy.injectAxe();
cy.wait(500);
cy.checkA11y(A11Y_OPTS);
});
});

context("Logged in", () => {
beforeEach(() => {
cy.clearSession();
cy.server();
// overview page
cy.route("GET", "*api/v1/repos*", "fixture:overview_page.json");
// add repos page
cy.route(
"GET",
"*api/v1/user/source/repos*",
"fixture:add_repositories.json"
);
// settings page
cy.route("GET", "*api/v1/repos/*/octocat", "fixture:repository.json");
// repo and build page
cy.stubBuilds();
cy.stubBuild();
cy.stubStepsWithLogs();
// hooks page
cy.route("GET", "*api/v1/hooks/github/octocat*", "fixture:hooks_5.json");
cy.route(
"GET",
"*api/v1/repos/*/octocat/builds/1*",
"fixture:build_success.json"
);
cy.route(
"GET",
"*api/v1/repos/*/octocat/builds/2*",
"fixture:build_failure.json"
);
cy.route(
"GET",
"*api/v1/repos/*/octocat/builds/3*",
"fixture:build_running.json"
);
});

it.skip("overview", () => {
cy.checkA11yForPage("/", A11Y_OPTS);
});

it.skip("add repos", () => {
cy.checkA11yForPage("/account/add-repos", A11Y_OPTS);
});

it.skip("settings", () => {
cy.checkA11yForPage("/github/octocat/settings", A11Y_OPTS);
});

it.skip("repo page", () => {
cy.checkA11yForPage("/someorg/somerepo", A11Y_OPTS);
});

it.skip("hooks page", () => {
cy.login("/github/octocat/hooks");
cy.injectAxe();
cy.wait(500);
cy.get("[data-test=hook]").click({ multiple: true });
cy.checkA11y(A11Y_OPTS);
});

it.skip("build page", () => {
cy.login("/someorg/somerepo/1");
cy.injectAxe();
cy.wait(500);
cy.get("[data-test=step-header]").click({ multiple: true });
cy.checkA11y(A11Y_OPTS);
});
});
});
8 changes: 7 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ Cypress.Commands.add("stubBuildsErrors", () => {
});
});


Cypress.Commands.add("stubBuildErrors", () => {
cy.route({
method: "GET",
Expand All @@ -158,3 +157,10 @@ Cypress.Commands.add("stubStepsErrors", () => {
response: "server error"
});
});

Cypress.Commands.add("checkA11yForPage", (path = "/", opts = {}) => {
cy.login(path);
cy.injectAxe();
cy.wait(500);
cy.checkA11y(opts);
});
5 changes: 4 additions & 1 deletion cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
// https://on.cypress.io/configuration
// ***********************************************************

// Import cypress-axe for accessibility tests
import "cypress-axe";

// Import commands.js using ES2015 syntax:
import './commands'
import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')
82 changes: 67 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
"dependencies": {
"@fullhuman/postcss-purgecss": "^1.3.0",
"@types/parcel-env": "0.0.0",
"autoprefixer": "^9.7.1",
"autoprefixer": "^9.7.3",
"elm": "^0.19.1-3",
"node-elm-compiler": "^5.0.4",
"parcel-bundler": "^1.12.4",
"rimraf": "^3.0.0",
"sass": "^1.23.3",
"sass": "^1.23.7",
"typescript": "^3.7.2"
},
"devDependencies": {
"cypress": "^3.6.0",
"elm-hot": "^1.1.3",
"axe-core": "^3.4.0",
"cypress": "^3.7.0",
"cypress-axe": "^0.5.1",
"elm-hot": "^1.1.4",
"start-server-and-test": "^1.10.6"
},
"scripts": {
Expand Down

0 comments on commit 8628a06

Please sign in to comment.