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

MCR-3080: bring back a11y tests in ci #2715

Merged
merged 29 commits into from
Aug 30, 2024

Conversation

JasonLin0991
Copy link
Contributor

@JasonLin0991 JasonLin0991 commented Aug 29, 2024

Summary

MCR-3080

  • Removed pa11y plugin
    • Tried unsuccessfully to try to get pa11y to work again.
  • Added cypress-axe and axe-core to run our a11y tests.
  • Updated documentation.
  • Added 2 accessibly tests
    • 'has no a11y violations on submission form with form input errors'
    • 'has no a11y violations on CMS dashboards'
  • Removed protobufjs from package.json in services/cypress
  • Fixed an issue with local Cypress LD interceptions.
    • We are using some kind of proxy for LD api requests so for local deployment we have to look for a different url.

The a11y logs for violations could be better. Rather than including it into this ticket I have a new one to improve the logs.
https://jiraent.cms.gov/browse/MCR-4416

These are two more tickets that add more a11y testing to other parts of the app that I think could really use it. They are not completely filled out and could use some refinement.
https://jiraent.cms.gov/browse/MCR-4417
https://jiraent.cms.gov/browse/MCR-4418

There are three violations with the accessibility testing. So to not increase the scope of this ticket, I made two tickets to address the violations

https://jiraent.cms.gov/browse/MCR-4420
https://jiraent.cms.gov/browse/MCR-4421

Related issues

Screenshots

Test cases covered

acccessibility.spec.ts

  • 'has no a11y violations on submission form with form input errors'
  • 'has no a11y violations on CMS dashboards'

QA guidance

@JasonLin0991 JasonLin0991 marked this pull request as draft August 29, 2024 03:15
@JasonLin0991 JasonLin0991 marked this pull request as ready for review August 29, 2024 21:20
@JasonLin0991 JasonLin0991 requested review from mojotalantikite and haworku and removed request for mojotalantikite August 29, 2024 21:20
@@ -71,6 +71,8 @@
"devDependencies": {
"c8": "^10.1.2",
"cypress": "^13.13.2",
"axe-core": "^4.10.0",
"cypress-axe": "^1.5.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.

@mojotalantikite I added these two dependencies here too. Correct me if things changed but, I did this because Cypress in CI runs from root and on local is runs from services/cypress without this here CI could not find the dependencies. A lot has changed since so is there a better, but simple, way to not have to install in both places?

I could do some configuration in each test to point to the location of the install based on deployment, but if installing the deps in both doesn't cost or complicate much would this be ok?

Copy link
Contributor

@haworku haworku Aug 30, 2024

Choose a reason for hiding this comment

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

@mojotalantikite @JasonLin0991 imo this is also a good time to consider if cypress should be moved considering the new world we are. Throwing it out there, not trying to suggest moving the entire folder is needed ...just want us to think expansively since we are also doing a lot around modularizing and simplifying our top level architecture right now so maybe we are seeing another opportunity here.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is totally fine. I personally think it's clearer to declare the dependencies in each service's package.json that needs them. Back with Yarn 1 everything got hoisted and when we moved to pnpm it started complaining about missing packages, as it was easy to just ignore the dependency if it was already installed elsewhere with Yarn.

Plus with pnpm everything is symlinked around, so it's not actually going to install it in two places, it's just going to throw in a symlink from the global package store to each service's node_modules that declares it.

@@ -63,3 +78,6 @@ Together these tools include linting, testing, and auditing loaded web pages for
[axe-core-cli]: https://www.npmjs.com/package/@axe-core/cli
[cypress-audit]: https://github.com/mfrachet/cypress-audit
[lighthouse-ci]: https://github.com/GoogleChrome/lighthouse-ci
Copy link
Contributor

Choose a reason for hiding this comment

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

ADRs aren't supposed to be edited in hindsight. They are meant to be a point in time record.

So what you do here - this would be a new ADR to update frontend a11y toolset to use cypress-axe and then you also edit ADR 005 to say for the pa11y decision - superseded by ADR 00XXX. Theres already an example of this with protobufs where ADR 024 supercedes ADR 009.

@@ -19,7 +19,7 @@ Together these tools include linting, testing, and auditing loaded web pages for

[eslint jsx-a11y][eslint-a11y] Provides React-friendly code linting which allows developers to find accessibility issues during local development.

[pa11y][pa11y] and [pa11y-ci][pa11y-ci] - Accessibility test runner for end to end testing in the command line or Node.js. End to end testing can catch concerns that are not noticeable in linting or unit tests since tests run on browser.
[cypress-axe][cypress-axe] and [axe-core][axe-copre] - Accessibility test runner for end to end testing in the command line or Node.js. End to end testing can catch concerns that are not noticeable in linting or unit tests since tests run on browser. Our previous choice [pa11y][pa11y] seems to not be maintained anymore and no longer works with our end to end testing.

[jest-axe][jest-axe] - This tool provides additional jest matchers, like `.toHaveNoViolations`, to use in unit tests. This may be redundant when end to end accessibility testing is present.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also a request - could you please also clarify that jest-axeis removed from our tool set? Reason is we aren't using it and it was removed from package.json I think awhile ago so its not in use.

cy.deprecatedNavigateV1Form('CONTINUE')
cy.deprecatedNavigateV1Form('CONTINUE')
cy.fillOutContractActionAndRateCertification()
cy.deprecatedNavigateV1Form('CONTINUE_FROM_START_NEW')
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought Pearl merged her work and start, submission and contract details are are all on v2. I think this could be using the v2 helpers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see a v2 of fillOutContractActionAndRateCertification. I do see startNewContractOnlySubmissionWithBaseContractV2, but the purpose of the code here is to:

  • check a11y violations on the empty form with field errors
  • fill out the form and continue so that we have a submission to go to each form page.

Using startNewContractOnlySubmissionWithBaseContractV2 would fill this out and continue before we could check for a11y violations.

Copy link
Contributor

@haworku haworku Aug 30, 2024

Choose a reason for hiding this comment

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

Look at navigateContractAndRatesForm and navigateContractForm - I was looking at the navigate command. We don't want to be use the deprecated commands anymore at all we should be removing them.

That's fine to use fillOUtContractActionAndRateCertification agree we aren't done with the whole form yet

cy.checkA11y('', {
runOnly: {
type: 'tag',
values: ['wcag22aa']
Copy link
Contributor

@haworku haworku Aug 30, 2024

Choose a reason for hiding this comment

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

I don't think this is working - I added basic accessibility violations (like an image missing alt text, a button with no text content) and there were no errors. When I change this value I start to get errors again. I think it is not working for some version saw a github issue or two as well

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'm seeing best-practice work lets just use that if you agree that 22aa is broken and so is wcagaa right now.

Copy link
Contributor Author

@JasonLin0991 JasonLin0991 Aug 30, 2024

Choose a reason for hiding this comment

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

Just to make visible our conversation. Rules for each standard are not cumulative. So in order to test all rules, all the standards must be included. If we only include 'wcag22aa' then only the specific rules added in for that standard will be tested.

The configuration has been updated to include the complete rules

cy.checkA11y('', {
    runOnly: {
        type: 'tag',
        values: ['wcag2a','wcag2aa', 'wcag21a', 'wcag21aa','wcag22aa']

Copy link

Choose a reason for hiding this comment

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

Hi @JasonLin0991 and @haworku , Even in this above eg:
cy.checkA11y('', {
runOnly: {
type: 'tag',
values: ['wcag2a','wcag2aa', 'wcag21a', 'wcag21aa','wcag22aa']

No violations are getting shown for wcag21a and wcag22aa.

Copy link
Contributor Author

@JasonLin0991 JasonLin0991 Sep 5, 2024

Choose a reason for hiding this comment

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

@sethims I followed the axe-core docs under axe.run() to figure out that the tags need to be combined. You can look through the rule of each standard using axe.getRules(). Compare the rules from getRules with the specific rule violations you are testing for. That should help with debugging. Good luck!

@JasonLin0991 JasonLin0991 merged commit a270f44 into main Aug 30, 2024
28 checks passed
@JasonLin0991 JasonLin0991 deleted the jl-mcr-3080-bring-back-a11y-tests-in-ci branch August 30, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants