-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Add cypress and cypress-axe packages for accessibility testing (#7201) #7213
Open
heybran
wants to merge
1
commit into
pods-framework:main
Choose a base branch
from
heybran:feature/7201-add-cypress-for-accessiblity-testing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { defineConfig } = require("cypress"); | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Add a `cypress.env.json` file at Pods root directory, and update the `host`, `username`, `password` to match WordPress site that cypress is going to test on. | ||
|
||
```json | ||
{ | ||
"host": "http://127.0.0.1:8000", | ||
"username": "your-wordpress-site-username", | ||
"password": "your-wordpress-site-password" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
describe( 'Edit pod screen', () => { | ||
beforeEach( () => { | ||
cy.visit( Cypress.env( 'host' ) + '/wp-admin/' ); | ||
cy.login( Cypress.env( 'username' ), Cypress.env( 'password' ) ); | ||
} ); | ||
|
||
it( 'Edit pod screen - add field - has no detectable a11y violations on load (custom configuration)', () => { | ||
cy.visit( Cypress.env( 'host' ) + '/wp-admin/admin.php?page=pods&action=edit&id=6' ) | ||
.injectAxe() | ||
/** | ||
* cy.click() can only be called on a single element. Your subject contained 2 elements. | ||
* Pass { multiple: true } if you want to serially click each element. | ||
* | ||
* @see https://docs.cypress.io/api/commands/click | ||
*/ | ||
.get( '[aria-label="Add a new field to this field group"]:first-child' ).click() | ||
// Add a new group modal - default wp modal component. | ||
.checkA11y( '.components-modal__content' ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
describe( 'Edit pod screen', () => { | ||
beforeEach( () => { | ||
cy.visit( Cypress.env( 'host' ) + '/wp-admin/' ); | ||
cy.login( Cypress.env( 'username' ), Cypress.env( 'password' ) ); | ||
} ); | ||
|
||
it( 'Edit pod screen - add new group - has no detectable a11y violations on load (custom configuration)', () => { | ||
cy.visit( Cypress.env( 'host' ) + '/wp-admin/admin.php?page=pods&action=edit&id=6' ) | ||
.injectAxe() | ||
/** | ||
* cy.click() can only be called on a single element. Your subject contained 2 elements. | ||
* Pass { multiple: true } if you want to serially click each element. | ||
* | ||
* @see https://docs.cypress.io/api/commands/click | ||
*/ | ||
.get( '.pods-button-group_container:first-child [aria-label="Add new field group to the Pod"]:first' ).click() | ||
// Add a new group modal - default wp modal component. | ||
.checkA11y( '.components-modal__screen-overlay' ); | ||
} ); | ||
|
||
it( 'Edit pod screen - add new group - advanced tab - has no detectable a11y violations on load (custom configuration)', () => { | ||
cy.visit( Cypress.env( 'host' ) + '/wp-admin/admin.php?page=pods&action=edit&id=6' ) | ||
.injectAxe() | ||
/** | ||
* cy.click() can only be called on a single element. Your subject contained 2 elements. | ||
* Pass { multiple: true } if you want to serially click each element. | ||
* | ||
* @see https://docs.cypress.io/api/commands/click | ||
*/ | ||
.get( '.pods-button-group_container:first-child [aria-label="Add new field group to the Pod"]:first' ).click() | ||
.get( '[aria-controls="advanced-tab"]' ).click() | ||
// Add a new group modal - default wp modal component. | ||
.checkA11y( '.components-modal__content' ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
describe( 'Edit pod screen', () => { | ||
beforeEach( () => { | ||
cy.visit( Cypress.env( 'host' ) + '/wp-admin/' ); | ||
cy.login( Cypress.env( 'username' ), Cypress.env( 'password' ) ); | ||
} ); | ||
|
||
it( 'Edit pod screen has no detectable a11y violations on load (custom configuration)', () => { | ||
cy.visit( Cypress.env( 'host' ) + '/wp-admin/admin.php?page=pods&action=edit&id=6' ); | ||
cy.injectAxe(); | ||
cy.checkA11y( '#wpbody-content' ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
describe( 'Pods Manage Pods screen', () => { | ||
beforeEach( () => { | ||
cy.visit( Cypress.env( 'host' ) + '/wp-admin/' ); | ||
cy.login( Cypress.env( 'username' ), Cypress.env( 'password' ) ); | ||
} ); | ||
|
||
it( 'Manage pods screen has no detectable a11y violations on load (custom configuration)', () => { | ||
cy.visit( Cypress.env( 'host' ) + '/wp-admin/admin.php?page=pods' ); | ||
cy.injectAxe(); | ||
cy.checkA11y( '#wpbody-content' ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
# Notes from cypress reports | ||
|
||
## Manage Pods screen | ||
|
||
Command: a11y error! | ||
Id: color-contrast | ||
Impact: serious | ||
Tags: Array(8) | ||
Description: Ensures the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds | ||
Help: Elements must meet minimum color contrast ratio thresholds | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/color-contrast?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix any of the following:\n Element has insufficient color contrast of 1.96 (foreground color: #f6f6e8, background color: #95bf3b, font size: 9.8pt (13px), font weight: normal). Expected contrast ratio of 4.5:1" | ||
|
||
html: | ||
"<a href=\"https://friends.pods.io/donations/become-a-friend/?utm_source=pods_plugin_callout&utm_medium=link&utm_campaign=friends_2023_docs\" target=\"_blank\" rel=\"noreferrer\" class=\"pods-admin_friends-callout_button--join\">\n\t\t\t\tDonate Now »\n\t\t\t</a>" | ||
|
||
|
||
|
||
--- | ||
|
||
Command: a11y error! | ||
Id: link-name | ||
Impact: serious | ||
Tags: (12) ['cat.name-role-value', 'wcag2a', 'wcag244', 'wcag412', 'section508', 'section508.22.a', 'TTv5', 'TT6.a', 'EN-301-549', 'EN-9.2.4.4', 'EN-9.4.1.2', 'ACT'] | ||
Description: Ensures links have discernible text | ||
Help: Links must have discernible text | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/link-name?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix all of the following:\n Element is in tab order and does not have accessible text\n\nFix any of the following:\n Element does not have text that is visible to screen readers\n aria-label attribute does not exist or is empty\n aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty\n Element has no title attribute" | ||
|
||
html: | ||
"<a href=\"/wp-admin/admin.php?page=pods&pods_callout_dismiss=friends_2023_docs\" class=\"pods-admin_friends-callout_close\">" | ||
impact | ||
|
||
## Edit pod screen | ||
|
||
Command: a11y error! | ||
Id: aria-command-name | ||
Impact: serious | ||
Tags: Array(8) | ||
Description: Ensures every ARIA button, link and menuitem has an accessible name | ||
Help: ARIA commands must have an accessible name | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/aria-command-name?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix any of the following:\n Element does not have text that is visible to screen readers\n aria-label attribute does not exist or is empty\n aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty\n Element has no title attribute" | ||
|
||
html: | ||
"<div class=\"pods-field-group_handle\" role=\"button\" tabindex=\"0\" aria-disabled=\"false\" aria-roledescription=\"sortable\" aria-describedby=\"DndDescribedBy-0\"><span class=\"dashicon dashicons dashicons-menu\"></span></div>" | ||
|
||
--- | ||
|
||
Command: a11y error! | ||
Id: color-contrast | ||
Impact: serious | ||
Tags: (8) ['cat.color', 'wcag2aa', 'wcag143', 'TTv5', 'TT13.c', 'EN-301-549', 'EN-9.1.4.3', 'ACT'] | ||
index-21ca8685.js:133730 Description: Ensures the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds | ||
Help: Elements must meet minimum color contrast ratio thresholds | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/color-contrast?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix any of the following:\n Element has insufficient color contrast of 4.04 (foreground color: #007cba, background color: #f1f1f1, font size: 9.8pt (13px), font weight: normal). Expected contrast ratio of 4.5:1" | ||
|
||
html: | ||
"<button type=\"button\" aria-label=\"Edit the slug\" class=\"components-button is-secondary\">Edit</button>" | ||
|
||
--- | ||
|
||
Command: a11y error! | ||
Id: nested-interactive | ||
Impact: serious | ||
Tags: (7) ['cat.keyboard', 'wcag2a', 'wcag412', 'TTv5', 'TT6.a', 'EN-301-549', 'EN-9.4.1.2'] | ||
Description: Ensures interactive controls are not nested as they are not always announced by screen readers or can cause focus problems for assistive technologies | ||
Help: Interactive controls must not be nested | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/nested-interactive?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix any of the following:\n Element has focusable descendants" | ||
|
||
html: | ||
"<div tabindex=\"0\" role=\"button\" class=\"pods-field-group_title\" aria-label=\"Press and hold to drag this item to a new position in the list\">" | ||
|
||
|
||
### Edit pod screen - add new group | ||
|
||
Command: a11y error! | ||
Id: aria-command-name | ||
Impact: serious | ||
Tags: Array(8) | ||
Description: Ensures every ARIA button, link and menuitem has an accessible name | ||
Help: ARIA commands must have an accessible name | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/aria-command-name?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix any of the following:\n Element does not have text that is visible to screen readers\n aria-label attribute does not exist or is empty\n aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty\n Element has no title attribute" | ||
|
||
html: | ||
"<span tabindex=\"0\" role=\"button\" class=\"pods-help-tooltip__icon\" aria-expanded=\"false\"><span class=\"dashicon dashicons dashicons-editor-help\"></span></span>" | ||
|
||
|
||
failureSummary: | ||
"Fix any of the following:\n Element does not have text that is visible to screen readers\n aria-label attribute does not exist or is empty\n aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty\n Element has no title attribute" | ||
|
||
html: | ||
"<span tabindex=\"0\" role=\"button\" class=\"pods-help-tooltip__icon\" aria-expanded=\"false\"><span class=\"dashicon dashicons dashicons-editor-help\"></span></span>" | ||
|
||
--- | ||
|
||
Command: a11y error! | ||
Id: aria-required-children | ||
Impact: critical | ||
Tags: (5) ['cat.aria', 'wcag2a', 'wcag131', 'EN-301-549', 'EN-9.1.3.1'] | ||
Description: Ensures elements with an ARIA role that require child roles contain them | ||
Help: Certain ARIA roles must contain particular children | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/aria-required-children?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix any of the following:\n Element has children which are not allowed: [role=button]\n Element uses aria-busy=\"true\" while showing a loader" | ||
html: | ||
"<div class=\"pods-settings-modal__tabs\" role=\"tablist\" aria-label=\"Pods Field Group Settings\">" | ||
|
||
--- | ||
|
||
Command: a11y error! | ||
Id: aria-valid-attr-value | ||
Impact: critical | ||
Tags: (5) ['cat.aria', 'wcag2a', 'wcag412', 'EN-301-549', 'EN-9.4.1.2'] | ||
Description: Ensures all ARIA attributes have valid values | ||
Help: ARIA attributes must conform to valid values | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/aria-valid-attr-value?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix all of the following:\n Invalid ARIA attribute value: aria-controls=\"basic-tab\"" | ||
|
||
html: | ||
"<div class=\"pods-settings-modal__tab-item pods-settings-modal__tab-item--active\" aria-controls=\"basic-tab\" role=\"button\" tabindex=\"0\">Group Details</div>" | ||
|
||
|
||
failureSummary: | ||
"Fix all of the following:\n Invalid ARIA attribute value: aria-controls=\"advanced-tab\"" | ||
|
||
html: | ||
"<div class=\"pods-settings-modal__tab-item\" aria-controls=\"advanced-tab\" role=\"button\" tabindex=\"0\">Advanced</div>" | ||
|
||
--- | ||
|
||
Command: a11y error! | ||
Id: color-contrast | ||
Impact: serious | ||
Tags: (8) ['cat.color', 'wcag2aa', 'wcag143', 'TTv5', 'TT13.c', 'EN-301-549', 'EN-9.1.4.3', 'ACT'] | ||
Description: Ensures the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds | ||
Help: Elements must meet minimum color contrast ratio thresholds | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/color-contrast?application=axeAPI | ||
|
||
'Fix any of the following:\n Element has insufficie…weight: normal). Expected contrast ratio of 4.5:1', 'Fix any of the following:\n Element has insufficie…t weight: bold). Expected contrast ratio of 4.5:1', 'Fix any of the following:\n Element has insufficie…t weight: bold). Expected contrast ratio of 4.5:1', 'Fix any of the following:\n Element has insufficie…weight: normal). Expected contrast ratio of 4.5:1', 'Fix any of the following:\n Element has insufficie…weight: normal). Expected contrast ratio of 4.5:1', 'Fix any of the following:\n Element has insufficie…weight: normal). Expected contrast ratio of 4.5:1', 'Fix any of the following:\n Element has insufficie…weight: normal). Expected contrast ratio of 4.5:1', 'Fix any of the following:\n Element has insufficie…weight: normal). Expected contrast ratio of 4.5:1', 'Fix any of the following:\n Element has insufficie…weight: normal). Expected contrast ratio of 4.5:1', 'Fix any of the following:\n Element has insufficie…weight: normal). Expected contrast ratio of 4.5:1' | ||
|
||
--- | ||
|
||
Command: a11y error! | ||
Id: heading-order | ||
Impact: moderate | ||
Tags: (2) ['cat.semantics', 'best-practice'] | ||
Description: Ensures the order of headings is semantically correct | ||
Help: Heading levels should only increase by one | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/heading-order?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix any of the following:\n Heading order invalid" | ||
|
||
html: | ||
"<h3 class=\"pods-form-ui-heading pods-form-ui-heading-visibility\" id=\"heading-visibility\">Visibility</h3>" | ||
|
||
## Edit pod screen - add field | ||
|
||
Command: a11y error! | ||
Id: aria-command-name | ||
Impact: serious | ||
Tags: (8) ['cat.aria', 'wcag2a', 'wcag412', 'TTv5', 'TT6.a', 'EN-301-549', 'EN-9.4.1.2', 'ACT'] | ||
Description: Ensures every ARIA button, link and menuitem has an accessible name | ||
Help: ARIA commands must have an accessible name | ||
Helpurl: https://dequeuniversity.com/rules/axe/4.8/aria-command-name?application=axeAPI | ||
|
||
failureSummary: | ||
"Fix any of the following:\n Element does not have text that is visible to screen readers\n aria-label attribute does not exist or is empty\n aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty\n Element has no title attribute" | ||
|
||
html: | ||
"<span tabindex=\"0\" role=\"button\" class=\"pods-help-tooltip__icon\" aria-expanded=\"false\"><span class=\"dashicon dashicons dashicons-editor-help\"></span></span>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
|
||
Cypress.Commands.add('login', (username, password) => { | ||
cy.get('#user_login').type(username) | ||
cy.get('#user_pass').type(password) | ||
cy.get('#wp-submit').click() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// *********************************************************** | ||
// This example support/e2e.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
import "cypress-axe"; | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the
/cypress/
directory into/tests/cypress/
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried, but can't make it work as cypress has specific rules. I can close this PR and keep the cypress on my local repo since I don't think anyone else other than me will be needing cypress.