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

Bug 1880118: Cypress a11y enhancements #6698

Merged

Conversation

dtaylor113
Copy link
Contributor

@dtaylor113 dtaylor113 commented Sep 21, 2020

This PR includes 3 a11y enhancements to our Cypress tests:

1. Adds a11y checks to Namespaces and Monitoring tests
2. Ports Protractors other-routes tests to Cypress and does a11y check on the routes:

 Running:  crud/other-routes.spec.ts                                                       (4 of 6)
  Visiting other routes
No BRIDGE_KUBEADMIN_PASSWORD set, skipping login
1 accessibility violation was detected for / page
┌─────────┬─────────────┬───────────┬───────────────────────────────────────┬───────┐
│ (index) │     id      │  impact   │              description              │ nodes │
├─────────┼─────────────┼───────────┼───────────────────────────────────────┼───────┤
│    0    │ 'link-name' │ 'serious' │ 'Ensures links have discernible text' │   5   │
└─────────┴─────────────┴───────────┴───────────────────────────────────────┴───────┘
    ✓ successfully displays view for route: / (10235ms)
    ✓ successfully displays view for route: /k8s/cluster/clusterroles/view (6958ms)
    ✓ successfully displays view for route: /k8s/cluster/nodes (5735ms)
    ✓ successfully displays view for route: /k8s/all-namespaces/events (5852ms)
    ✓ successfully displays view for route: /k8s/all-namespaces/import (5790ms)
    ✓ successfully displays view for route: /api-explorer (7243ms)
    ✓ successfully displays view for route: /api-resource/ns/default/core~v1~Pod (5697ms)
    ✓ successfully displays view for route: /api-resource/ns/default/core~v1~Pod/schema (5656ms)
    ✓ successfully displays view for route: /api-resource/ns/default/core~v1~Pod/instances (5900ms)
    ✓ successfully displays view for route: /api-resource/ns/default/core~v1~Pod/access (5783ms)
    ✓ successfully displays view for route: /k8s/cluster/user.openshift.io~v1~User (5659ms)
    ✓ successfully displays view for route: /k8s/ns/openshift-machine-api/machine.openshift.io~v1beta1~Machine (5756ms)
    ✓ successfully displays view for route: /k8s/ns/openshift-machine-api/machine.openshift.io~v1beta1~MachineSet (5680ms)
    ✓ successfully displays view for route: /k8s/ns/openshift-machine-api/autoscaling.openshift.io~v1beta1~MachineAutoscaler (5824ms)
    ✓ successfully displays view for route: /k8s/ns/openshift-machine-api/machine.openshift.io~v1beta1~MachineHealthCheck (5730ms)
    ✓ successfully displays view for route: /k8s/cluster/machineconfiguration.openshift.io~v1~MachineConfig (5734ms)
    ✓ successfully displays view for route: /k8s/cluster/machineconfiguration.openshift.io~v1~MachineConfigPool (5704ms)
    ✓ successfully displays view for route: /k8s/all-namespaces/monitoring.coreos.com~v1~Alertmanager (5683ms)
    ✓ successfully displays view for route: /k8s/ns/openshift-monitoring/monitoring.coreos.com~v1~Alertmanager/main (5641ms)
    ✓ successfully displays view for route: /settings/cluster (5679ms)
    ✓ successfully displays view for route: /monitoring/query-browser (5671ms)
No BRIDGE_KUBEADMIN_PASSWORD set, skipping logout
    ✓ successfully displays view for route: /search/all-namespaces?kind=config.openshift.io~v1~Console (6087ms)

3. Outputs a11y summary:

A11y Test Results:
┌──────────────────────┬────────┐
│       (index)        │ Values │
├──────────────────────┼────────┤
│   numberA11yChecks   │  '82'  │
│ numberA11yViolations │  '4'   │
└──────────────────────┴────────┘

JIRA Story: https://issues.redhat.com/browse/CONSOLE-2359

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. label Sep 21, 2020
@openshift-ci-robot
Copy link
Contributor

@dtaylor113: This pull request references Bugzilla bug 1880118, which is valid. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1880118: Cypress a11y enhancements

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Sep 21, 2020
@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label Sep 21, 2020
@openshift-ci-robot
Copy link
Contributor

@dtaylor113: This pull request references Bugzilla bug 1880118, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1880118: Cypress a11y enhancements

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -33,6 +34,12 @@ module.exports = (on, config) => {
console.table(data);
return null;
},
readFileMaybe(filename) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
readFileMaybe(filename) {
readFileIfExists(filename) {

description,
nodes: nodes.length,
}));
window.Cypress.numberA11yViolations += violations.length;
Copy link
Member

Choose a reason for hiding this comment

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

Should we be modifying the Cypress object? I'd think we'd want to avoid mutating that since it's not our API and store this somewhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, how about window.a11y.numberViolations ?

Comment on lines 49 to 50
numberA11yViolations: number;
numberA11yChecks: number;
Copy link
Member

Choose a reason for hiding this comment

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

If we're only accessing these in the Cypress tests, it would be better to avoid adding the types here since this window definition applies to console itself.

Comment on lines 26 to 27
window.Cypress.numberA11yViolations = Number(a11yResult.numberA11yViolations);
window.Cypress.numberA11yChecks = Number(a11yResult.numberA11yChecks);
Copy link
Member

Choose a reason for hiding this comment

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

If you move this inside the try block, you can use const on allyResult.

} catch (e) {
cy.task(
'logError',
`couldn't parse cypress-a11y-results.json. ${JSON.stringify(e, null, ' ')}`,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need the full stack trace here, only the error message?

Suggested change
`couldn't parse cypress-a11y-results.json. ${JSON.stringify(e, null, ' ')}`,
`couldn't parse cypress-a11y-results.json. ${e}`,

@@ -132,8 +135,10 @@ describe('Kubernetes resource CRUD operations', () => {
// filter should have 3 chip groups: resource, label, and name
listPage.filter.numberOfActiveFiltersShouldBe(3);
listPage.rows.shouldExist(name);
cy.testA11y(`Search page for ${kind}: ${name}`);

// Search page same for all resources, so only a11y test once
Copy link
Member

Choose a reason for hiding this comment

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

This isn't true since the lists are different for each resource. I'd go ahead and test each one unless there is a good reason not to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, thought it was the same for every resource.

@@ -25,11 +25,13 @@ describe('Namespace', () => {
listPage.rows.shouldNotExist(newName);
listPage.filter.byName(testName);
listPage.rows.shouldExist(testName); // created via cy.createProject(testName) above
cy.testA11y(`Namespace List page`);
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary backticks. (I thought we had an eslint rule for this.)

Suggested change
cy.testA11y(`Namespace List page`);
cy.testA11y('Namespace List page');


cy.log('creates the Namespace');
listPage.clickCreateYAMLbutton();
modal.shouldBeOpened();
cy.byTestID('input-name').type(newName);
cy.testA11y(`Create Namespace modal`);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cy.testA11y(`Create Namespace modal`);
cy.testA11y('Create Namespace modal');

@@ -41,6 +43,7 @@ describe('Namespace', () => {
listPage.rows.clickKebabAction(newName, 'Delete Namespace');
modal.shouldBeOpened();
cy.byTestID('project-name-input').type(newName);
cy.testA11y(`Delete Namespace modal`);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cy.testA11y(`Delete Namespace modal`);
cy.testA11y('Delete Namespace modal');

@@ -45,6 +45,7 @@ describe('Monitoring: Alerts', () => {
cy.byLegacyTestID('resource-title').should('have.text', 'Alerting');
listPage.projectDropdownShouldNotExist();
listPage.rows.shouldBeLoaded();
cy.testA11y(`Monitor Alerting list page`);
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary backticks throughout this file.

@openshift-ci-robot
Copy link
Contributor

@dtaylor113: This pull request references Bugzilla bug 1880118, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1880118: Cypress a11y enhancements

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dtaylor113
Copy link
Contributor Author

Hi @spadgett, I believe I have addressed all of your comments. PTAL -thanks

@@ -1,59 +1,37 @@
/* eslint-disable import/no-duplicates */
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

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 is not :-) removed.

Comment on lines 87 to 90
// YAML Editor same for all resources, so only a11y test once
if (kind === 'Pod') {
cy.testA11y(`YAML Editor for ${kind}: ${name}`);
}
Copy link
Member

Choose a reason for hiding this comment

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

I thought the YAML Editor html elements would be the same for every resource, only the inner YAML text changes, so no need to rerun a11y checks for every resource, just one would do, right?

I wouldn't assume that will always be true, and there's no virtually no overhead to checking a11y for each resource. And it makes the code simpler as well. I don't see a reason to restrict it to just pods.

@dtaylor113
Copy link
Contributor Author

dtaylor113 commented Sep 22, 2020

spadgett 2 minutes ago Member
I thought the YAML Editor html elements would be the same for every resource, only the inner YAML text changes, so no need to rerun a11y checks for every resource, just one would do, right?

I wouldn't assume that will always be true, and there's no virtually no overhead to checking a11y for each resource. And it makes the code simpler as well. I don't see a reason to restrict it to just pods.

Fixed. Ok, just didn't want to inflate a11y total number of checks run, that's an extra 27 checks which might be the same page/elements.

@dtaylor113 dtaylor113 force-pushed the cypress-axe-enhancements branch 2 times, most recently from 262b4ed to 4d3cafb Compare September 22, 2020 15:46
@openshift-ci-robot
Copy link
Contributor

@dtaylor113: This pull request references Bugzilla bug 1880118, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1880118: Cypress a11y enhancements

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@spadgett spadgett 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 @dtaylor113 👍

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 22, 2020
];
otherRoutes.forEach((route) => {
it(`successfully displays view for route: ${route}`, () => {
cy.visit(`${route}`);
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
cy.visit(`${route}`);
cy.visit(route);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @spadgett, fixed, pls re-add 'lgtm' label -thanks

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 22, 2020
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 22, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 22, 2020
@dtaylor113
Copy link
Contributor Author

Hi @spadgett, had to resolve merge conflict, pls re-add 'lgtm' label -thanks

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 22, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dtaylor113, spadgett

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 85b76c6 into openshift:master Sep 23, 2020
@openshift-ci-robot
Copy link
Contributor

@dtaylor113: Some pull requests linked via external trackers have merged:

The following pull requests linked via external trackers have not merged:

These pull request must merge or be unlinked from the Bugzilla bug in order for it to move to the next state.

Bugzilla bug 1880118 has not been moved to the MODIFIED state.

In response to this:

Bug 1880118: Cypress a11y enhancements

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@spadgett spadgett added this to the v4.6 milestone Sep 30, 2020
@dtaylor113 dtaylor113 deleted the cypress-axe-enhancements branch November 25, 2020 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants