-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM] add cypress-axe to e2e tests to check A11y #126610
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,6 +6,7 @@ | |||||
*/ | ||||||
import { synthtrace } from '../../../synthtrace'; | ||||||
import { opbeans } from '../../fixtures/synthtrace/opbeans'; | ||||||
import { checkA11y } from '../../support/commands'; | ||||||
|
||||||
const start = '2021-10-10T00:00:00.000Z'; | ||||||
const end = '2021-10-10T00:15:00.000Z'; | ||||||
|
@@ -43,6 +44,17 @@ describe('Dependencies', () => { | |||||
|
||||||
cy.contains('h1', 'postgresql'); | ||||||
}); | ||||||
|
||||||
it('has no detectable a11y violations on load', () => { | ||||||
cy.visit( | ||||||
`/app/apm/services/opbeans-java/dependencies?${new URLSearchParams( | ||||||
timeRange | ||||||
)}` | ||||||
); | ||||||
cy.contains('a[role="tab"]', 'Dependencies'); | ||||||
// set skipFailures to true to not fail the test when there are accessibility failures | ||||||
checkA11y(true); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make it clear what
Suggested change
|
||||||
}); | ||||||
}); | ||||||
|
||||||
describe('dependency overview page', () => { | ||||||
|
@@ -62,6 +74,18 @@ describe('Dependencies', () => { | |||||
|
||||||
cy.contains('h1', 'opbeans-java'); | ||||||
}); | ||||||
|
||||||
it('has no detectable a11y violations on load', () => { | ||||||
cy.visit( | ||||||
`/app/apm/backends/overview?${new URLSearchParams({ | ||||||
...timeRange, | ||||||
backendName: 'postgresql', | ||||||
})}` | ||||||
); | ||||||
cy.contains('h1', 'postgresql'); | ||||||
// set skipFailures to true to not fail the test when there are accessibility failures | ||||||
checkA11y(true); | ||||||
}); | ||||||
}); | ||||||
|
||||||
describe('service overview page', () => { | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import url from 'url'; | ||
import { synthtrace } from '../../../../synthtrace'; | ||
import { opbeans } from '../../../fixtures/synthtrace/opbeans'; | ||
import { checkA11y } from '../../../support/commands'; | ||
|
||
const timeRange = { | ||
rangeFrom: '2021-10-10T00:00:00.000Z', | ||
|
@@ -53,6 +54,12 @@ describe('When navigating to the service inventory', () => { | |
cy.visit(serviceInventoryHref); | ||
}); | ||
|
||
it('has no detectable a11y violations on load', () => { | ||
cy.contains('Services'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking some text on the page could be included in another test as it's not specific to accessibility (same with other files) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shows an error if trying to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean without having anything else in the test? What error do you get? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
// set skipFailures to true to not fail the test when there are accessibility failures | ||
checkA11y(true); | ||
}); | ||
|
||
it('has a list of services', () => { | ||
cy.contains('opbeans-node'); | ||
cy.contains('opbeans-java'); | ||
|
@@ -93,7 +100,7 @@ describe('When navigating to the service inventory', () => { | |
cy.wait(aliasNames); | ||
}); | ||
|
||
it.skip('when selecting a different time range and clicking the update button', () => { | ||
it('when selecting a different time range and clicking the update button', () => { | ||
cy.wait(aliasNames); | ||
|
||
cy.selectAbsoluteTimeRange( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,12 @@ | |
import url from 'url'; | ||
import { synthtrace } from '../../../../synthtrace'; | ||
import { opbeans } from '../../../fixtures/synthtrace/opbeans'; | ||
import { checkA11y } from '../../../support/commands'; | ||
|
||
const start = '2021-10-10T00:00:00.000Z'; | ||
const end = '2021-10-10T00:15:00.000Z'; | ||
|
||
const serviceOverviewHref = url.format({ | ||
const serviceTransactionsHref = url.format({ | ||
pathname: '/app/apm/services/opbeans-node/transactions', | ||
query: { rangeFrom: start, rangeTo: end }, | ||
}); | ||
|
@@ -35,8 +36,18 @@ describe('Transactions Overview', () => { | |
cy.loginAsReadOnlyUser(); | ||
}); | ||
|
||
it('has no detectable a11y violations on load', () => { | ||
cy.visit(serviceTransactionsHref); | ||
cy.contains('a[role="tab"]', 'Transactions').should( | ||
'have.class', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might want to avoid depending on |
||
'euiTab-isSelected' | ||
); | ||
// set skipFailures to true to not fail the test when there are accessibility failures | ||
checkA11y(true); | ||
}); | ||
|
||
it('persists transaction type selected when navigating to Overview tab', () => { | ||
cy.visit(serviceOverviewHref); | ||
cy.visit(serviceTransactionsHref); | ||
cy.get('[data-test-subj="headerFilterTransactionType"]').should( | ||
'have.value', | ||
'request' | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,6 +6,11 @@ | |||||
*/ | ||||||
import 'cypress-real-events/support'; | ||||||
import { Interception } from 'cypress/types/net-stubbing'; | ||||||
import 'cypress-axe'; | ||||||
import { | ||||||
AXE_CONFIG, | ||||||
AXE_OPTIONS, | ||||||
} from 'test/accessibility/services/a11y/constants'; | ||||||
|
||||||
Cypress.Commands.add('loginAsReadOnlyUser', () => { | ||||||
cy.loginAs({ username: 'apm_read_user', password: 'changeme' }); | ||||||
|
@@ -78,3 +83,21 @@ Cypress.Commands.add( | |||||
}); | ||||||
} | ||||||
); | ||||||
|
||||||
// A11y configuration | ||||||
|
||||||
const axeConfig = { | ||||||
...AXE_CONFIG, | ||||||
rules: [...AXE_CONFIG.rules], | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this the same with just using |
||||||
}; | ||||||
const axeOptions = { | ||||||
...AXE_OPTIONS, | ||||||
runOnly: [...AXE_OPTIONS.runOnly, 'best-practice'], | ||||||
}; | ||||||
|
||||||
export const checkA11y = (skipFailures: boolean) => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we wrap |
||||||
cy.injectAxe(); | ||||||
cy.configureAxe(axeConfig); | ||||||
const context = '.kbnAppWrapper'; // Scopes a11y checks to only our app | ||||||
cy.checkA11y(context, axeOptions, undefined, skipFailures); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's I'd prefer this:
Suggested change
But I assume that's out of our control. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't change that unfortunately There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But we can get rid of the last two params when we don't need to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sqren The |
||||||
}; |
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.
If there is a second tab that can be interacted with, it'd be great to click on that tab and make a second
checkA11y
call to bump code coverage.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.
Hi @1Copenut, this is our first approach to the A11y checks in our pages, we are going to add more checks in the future for now we are just checking the first render and not the interactions.
APM Service Overview contains multiple tabs, it's good to know that we can bump the code coverage if we check A11y in all of them.