Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Added Cypress Axe. #103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Added Cypress Axe. #103

wants to merge 1 commit into from

Conversation

dlabaj
Copy link
Contributor

@dlabaj dlabaj commented Nov 12, 2020

Fixes issue #20 using cypress axe.

Signed-off-by: Donald Labaj [email protected]

@github-actions
Copy link

github-actions bot commented Nov 12, 2020

PR Report

Bundle Sizes

View bundle sizes for 'client'
Bundle New Size Original Size Increase/Decrease File
1.bundle.js 631.33KB 631.33KB 0% 1.bundle.js
Strimzi UI JS Bundle 11.08KB 11.08KB 0% main.bundle.js
Overall bundle size change: 0%
View bundle sizes for 'server'
Bundle New Size Original Size Increase/Decrease File
Strimzi UI Server JS Bundle 26.74KB 26.67KB 0% main.js
Overall bundle size change: 0.26%

Test Coverage

View test coverage
File Lines Statement Functions Branches
Total 100% 100% 100% 100%
client/Bootstrap/Navigation/useRouteConfig/useRouteConfig.hook.ts 100% 100% 100% 100%
client/Contexts/ConfigFeatureFlag/Context.tsx 100% 100% 100% 100%
client/Contexts/ConfigFeatureFlag/FeatureFlag.view.tsx 100% 100% 100% 100%
client/Contexts/Introspect/Introspection.ts 100% 100% 100% 100%
client/Contexts/Logging/Context.tsx 100% 100% 100% 100%
client/Hooks/useConfigFeatureFlag/useConfigFeatureFlag.ts 100% 100% 100% 100%
client/Hooks/useLogger/Hook.ts 100% 100% 100% 100%
client/Panels/Home/Home.tsx 100% 100% 100% 100%
client/Utils/sanitise/sanitise.ts 100% 100% 100% 100%
client/Utils/window/window.ts 100% 100% 100% 100%
File Lines Statement Functions Branches
Total 100% 100% 100% 100%
server/api/controller.ts 100% 100% 100% 100%
server/api/router.ts 100% 100% 100% 100%
server/client/controller.ts 100% 100% 100% 100%
server/client/router.ts 100% 100% 100% 100%
server/config/controller.ts 100% 100% 100% 100%
server/config/router.ts 100% 100% 100% 100%
server/core/app.ts 100% 100% 100% 100%
server/core/modules.ts 100% 100% 100% 100%
server/log/router.ts 100% 100% 100% 100%
server/mockapi/data.ts 100% 100% 100% 100%
server/mockapi/router.ts 100% 100% 100% 100%

Triggered by commit: a4c0f81

@dlabaj dlabaj changed the title Added Cypress Axe. DRAFT: Added Cypress Axe. Nov 12, 2020
});

Then(`the welcome message appears`, () => {
cy.get('#root').contains(`Welcome to the Strimzi UI`);
cy.checkA11y();
Copy link
Contributor

Choose a reason for hiding this comment

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

https://www.npmjs.com/package/cypress-axe#using-the-violationcallback-argument - I'd like if we had support for this to log out to console.

Otherwise, when test fails - while we can watch the video that GHA uploads as an artifact, it would be good to have failure in the workflow log.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also - Carbon is not always 100% accessible - how do you flag particular rules as "ignore for this element"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Finally - we will need to discuss "what rules should we run" and "what impact level fails". Can you propose a default set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can disable rules that the frameworks don't support. On patternfly we try to not disable rules.

Copy link
Contributor

@nictownsend nictownsend left a comment

Choose a reason for hiding this comment

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

Principle looks good; I'm still unclear as to how you can disable individual rules/elements per checkA11y call though. Can you investigate please

@@ -5,9 +5,10 @@
import { Given, Then } from 'cypress-cucumber-preprocessor/steps';

Given('I am on the strimzi-ui homepage', () => {
cy.visit('localhost:3000/index.html');
cy.visit('localhost:8080/index.html');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the port change? When your run npm run e2e it should be starting up express on 3000

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was a mistake I will fix it

);

Cypress.Commands.add('testA11y', (target: string) => {
cy.injectAxe();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the inject and configure be run multiple times inside a test (expect there will be multiple calls to testA11y - or does it have to be ran only once per test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It only has to be run once.

Copy link
Contributor

Choose a reason for hiding this comment

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

cy.testally would be called multiple times - so should cy.injextAxe() and configureAxe() instead be in a before all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that makes sense I'll modify it.

cy.configureAxe({
rules: [
{ id: 'color-contrast', enabled: false }, // seem to be somewhat inaccurate and has difficulty always picking up the correct colors, tons of open issues for it on axe-core
{ id: 'focusable-content', enabled: false }, // recently updated and need to give the PF team time to fix issues before enabling
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the issues being fixed in Axe by PF, or are rules disabled until new version of PF is released?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently they are being fixed by the patternfly team

package.json Outdated
@@ -63,9 +63,8 @@
"pino-filter": "^1.0.0",
"pino-http": "^5.3.0",
"pino-pretty": "^4.3.0",
"sass": "^1.29.0",
"react-i18next": "^11.7.3",
"sass": "^1.26.10",
Copy link
Contributor

Choose a reason for hiding this comment

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

When you merge package.json please ensure only one sass entry and version 1.29.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thought I fixed that thanks for the catch.

@nictownsend
Copy link
Contributor

@dlabaj few outstanding questions that are blocking this being merged (post-rebase)

@dlabaj dlabaj changed the title DRAFT: Added Cypress Axe. Added Cypress Axe. Dec 3, 2020
@dlabaj dlabaj force-pushed the cypress-a11y branch 3 times, most recently from f58a9f9 to 1c55d6a Compare December 3, 2020 20:12
Fixes issue strimzi#20 using cypress axe.
Signed-off-by: Donald Labaj <[email protected]>
);

Cypress.Commands.add('testA11y', (target: string) => {
cy.injectAxe();
Copy link
Contributor

Choose a reason for hiding this comment

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

cy.testally would be called multiple times - so should cy.injextAxe() and configureAxe() instead be in a before all?

Base automatically changed from master to main March 25, 2021 11:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants