Skip to content
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

[Enterprise Search] Set up cypress-axe tests #108465

Merged
merged 7 commits into from
Aug 24, 2021

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Aug 12, 2021

Summary

Follow up to #108309

What this PR does:

  • Installs and sets up the cypress-axe dev dependency
  • DRY's out some axe-core configs that the current FTR a11y tests use to re-use in Cypress 0a51689 (cc @myasonik for review on this)
  • Adds checkA11y() that runs axe against our current placeholder/hello-world E2E tests

What this PR does NOT do:

  • Set up more a full set of checkA11y() tests for each product's views/routes (hoping to do this in a follow-up PR)
    • In light of the Cypress PR being reverted, I likely won't have time to expand on our E2E tests. Hoping this setup helps however and y'all continue to use the established checkA11y() helper for future tests.

As always, I recommend following along by commit.

Screencaps

In open mode, you should be able to inspect and see that 0 accessibility violations were detected:

Screencap showing how to debug cypress-axe accessibility failures:

QA

  • Setup
    • Have Elasticsearch running on localhost:9200
    • Have Enterprise Search running on localhost:3002
    • In kibana.dev.yml, set csp.strict: false and csp.warnLegacyBrowsers: false
    • Have Kibana running with --no-base-path and on localhost:5601
    • cd to x-pack/plugins/enterprise_search/
  • Confirm sh cypress.sh run overview passes
  • Confirm sh cypress.sh run as passes
  • Confirm sh cypress.sh run ws passes

Checklist

@cee-chen cee-chen added release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed v7.15.0 labels Aug 12, 2021
@cee-chen cee-chen requested review from myasonik and a team August 12, 2021 22:56
@cee-chen cee-chen requested a review from a team as a code owner August 12, 2021 22:56
@cee-chen cee-chen requested review from a team August 12, 2021 22:56
Copy link
Contributor Author

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Misc comments. Excited to get this set up so we can add more axe checks to our app and potentially close out #79359!


import { ReporterVersion } from 'axe-core';

export const AXE_CONFIG = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@myasonik Let me know if you're cool with this setup (constants.ts file and all capitalized CONSTANTS vars)! If not I can definitely rename to anything that you prefer!

test/accessibility/services/a11y/constants.ts Show resolved Hide resolved
},
],
});
window.axe.configure(config);
Copy link
Contributor Author

@cee-chen cee-chen Aug 13, 2021

Choose a reason for hiding this comment

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

NB: the new AXE_CONFIG const has to get passed as a new config arg instead of being imported in-file, because of the way analyzeWithAxe gets called during browser runtime by Kibana's FTR tests. Otherwise you just get a bunch of undefined errors

Copy link
Contributor

@myasonik myasonik left a comment

Choose a reason for hiding this comment

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

Awesome to see! 🚀

@byronhulcher
Copy link
Contributor

In kibana.dev.yml, set csp.strict: false and csp.warnLegacyBrowsers: false
Have Kibana running with --no-base-path and on localhost:5601

Can we document this somewhere in the codebase? Maybe a x-pack/plugins/enterprise_search/public/applications/app_search/README.md file (we could also include some of the non-internal guidance from the Getting Started guide like Running Kibana, Where do I write code?, How do I write code?, Relevant guides)

@byronhulcher
Copy link
Contributor

byronhulcher commented Aug 13, 2021

Hey constance, could you make a branch for me with an axe error? I'm having trouble generating one, I tried messing around with bad h* tags which is what has gotten me in trouble the most but my tests always pass with 0 accessibility failures. Just want to validate these appear in the CI as failures.

@cee-chen
Copy link
Contributor Author

cee-chen commented Aug 13, 2021

@byronhulcher Interesting, it's possible that the new axe config settings we imported from the Kibana a11y tests are ignoring those failures. I'll play around with it and see if we need to override anything.

Also as a heads up, #108309 was reverted due to causing Typescript build issues in master with our Cypress config, so I'm moving this PR back into draft until then. I'll be speaking to Spencer/the KibanaOps team to figure out our TS issues! Thanks Michail for the approval on this before your last day; with your review I feel confident about letting this PR sit for a bit and then merging later once Typescript is no longer causing issues.

@cee-chen cee-chen marked this pull request as draft August 13, 2021 14:51
@cee-chen
Copy link
Contributor Author

cee-chen commented Aug 13, 2021

Sorry, just saw your 1st comment also Byron (wish GitHub would let us thread non-code comments):

Can we document this somewhere in the codebase?

It's documented in our Kibana plugin README. Documentation was added in the previous Cypress setup PR:

https://github.com/constancecchen/kibana/blob/54978c8d5685bada2911d4c1911afaa22047a4d3/x-pack/plugins/enterprise_search/README.md#cypress-tests

@cee-chen cee-chen removed the request for review from a team August 13, 2021 18:26
@cee-chen
Copy link
Contributor Author

@byronhulcher OK, I dug into validating heading levels and it turns out the settings we were inheriting from the base Kibana setup did indeed have those violations turned off (they're tagged under best-practices). I override them in our own configuration this PR (a982179) and checked with Michail just now - they weren't intentionally turned off, but were skipped due to time reasons on their end (not having the bandwidth to fix every best-practices error across Kibana at the time). He's super +1 to us adding it to our codebase.

With the extra config above, I added an extra branch with an example error - feel free to check it out! cypress-axe-error, commit cee-chen@52b8b2e

+ fix string union type error
+ remove unnecessary tsconfig exclude
- Mostly just re-exporting the shared command and checking for failures, I only ran this after the shared axe config settings and found no failures
- notably heading level issues (thanks Byron for catching this!)

- however I now also need to set an ignore on a duplicate landmark violation caused by the global header (not sure why it's showing up - shouldn't it be out of context? bah)

- remove option to pass args into checkA11y - I figure it's not super likely we'll need to override axe settings per-page (vs not running it), but we can pass it custom configs or args later if needed
@cee-chen cee-chen marked this pull request as ready for review August 16, 2021 20:48
@cee-chen
Copy link
Contributor Author

OK, with #108560 merged in this should now be ready to review!

@byronhulcher, I know it's ON week, but this should hopefully be a relatively small PR and I was hoping to get your eyes on it (since your comments have already helped me improve our axe config settings!)

Similarly WS folks, would super appreciate a review whenever you have time so I can wrap up my last Enterprise Search PR!

Copy link
Contributor

@scottybollinger scottybollinger left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@mistic mistic added v7.16.0 and removed v7.15.0 labels Aug 18, 2021
@cee-chen
Copy link
Contributor Author

@elasticmachine merge upstream

@cee-chen
Copy link
Contributor Author

@byronhulcher @JasonStoltz 👋 Would super appreciate a quick review on this PR from either of y'all this week!

@JasonStoltz
Copy link
Member

@constancecchen I will take a look

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@JasonStoltz JasonStoltz left a comment

Choose a reason for hiding this comment

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

Great work Constance!

@cee-chen
Copy link
Contributor Author

Thanks y'all!! Enjoy! 🎉

@cee-chen cee-chen merged commit 8dfdead into elastic:master Aug 24, 2021
@cee-chen cee-chen deleted the cypress-axe branch August 24, 2021 19:05
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Aug 24, 2021
* Set up cypress-axe

@see https://github.com/component-driven/cypress-axe

* DRY out Kibana axe rules into constants that Cypress can use

* Create shared & configured checkA11y command

+ fix string union type error
+ remove unnecessary tsconfig exclude

* Add Overview plugin a11y tests

* Add AS & WS placeholder a11y checks

- Mostly just re-exporting the shared command and checking for failures, I only ran this after the shared axe config settings and found no failures

* Configure our axe settings further to catch best practices

- notably heading level issues (thanks Byron for catching this!)

- however I now also need to set an ignore on a duplicate landmark violation caused by the global header (not sure why it's showing up - shouldn't it be out of context? bah)

- remove option to pass args into checkA11y - I figure it's not super likely we'll need to override axe settings per-page (vs not running it), but we can pass it custom configs or args later if needed

Co-authored-by: Kibana Machine <[email protected]>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Aug 24, 2021
* Set up cypress-axe

@see https://github.com/component-driven/cypress-axe

* DRY out Kibana axe rules into constants that Cypress can use

* Create shared & configured checkA11y command

+ fix string union type error
+ remove unnecessary tsconfig exclude

* Add Overview plugin a11y tests

* Add AS & WS placeholder a11y checks

- Mostly just re-exporting the shared command and checking for failures, I only ran this after the shared axe config settings and found no failures

* Configure our axe settings further to catch best practices

- notably heading level issues (thanks Byron for catching this!)

- however I now also need to set an ignore on a duplicate landmark violation caused by the global header (not sure why it's showing up - shouldn't it be out of context? bah)

- remove option to pass args into checkA11y - I figure it's not super likely we'll need to override axe settings per-page (vs not running it), but we can pass it custom configs or args later if needed

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Constance <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes v7.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants