Skip to content

Commit

Permalink
Add two accessibility tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLin0991 committed Aug 29, 2024
1 parent ca34107 commit 41333e9
Showing 1 changed file with 99 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -1,102 +1,114 @@
// Define at the top of the spec file or just import it
function terminalLog(violations: Record<string, any>[]) {
console.log(violations)
cy.task(
'log',
`${violations.length} accessibility violation${
violations.length === 1 ? '' : 's'
} ${violations.length === 1 ? 'was' : 'were'} detected`
)
// pluck specific keys to keep the table readable
const violationData: Record<string, any>[] = violations.map(
({ id, impact, description, nodes }) => ({
id,
impact,
description,
nodes: nodes.length
})
)

cy.task('table', violationData)
}
import { stateUser } from '../../../utils/apollo-test-utils';

describe('state user in state submission form', () => {
beforeEach(() => {
cy.stubFeatureFlags()
cy.interceptGraphQL()
})
// SKIPPED because we currently have a bug that looks related to https://github.com/mfrachet/cypress-audit/issues/136#issuecomment-1311236777
// this started when we upgraded node and serverless and started default to ipv6 which prevented tests
// current this keeps pa11y from running
it('can fill out contract only submission with no a11y errors', () => {
it('has not a11y errors with submission form and and form erros', () => {
// goal of this test is to check every single form page and navigation (going backwards, forwards or save as draft with new info)

cy.interceptFeatureFlags({'438-attestation': true})
cy.logInAsStateUser()

// Inject the axe run-time
cy.injectAxe()

// Start a base contract only submissions
cy.startNewContractOnlySubmissionWithBaseContract()
cy.checkA11y(undefined, undefined, terminalLog)
cy.findByTestId('state-dashboard-page').should('exist')
cy.findByRole('link', { name: 'Start new submission' }).click()

// Check accessibility on Submission type page
cy.findByRole('heading', { level: 1, name: /New submission/ })
cy.findByRole('button', {
name: 'Continue',
}).should('not.have.attr', 'aria-disabled')
cy.findByRole('button', {
name: 'Continue',
}).safeClick()
cy.checkA11yWithSection508()

cy.fillOutContractActionAndRateCertification()
cy.deprecatedNavigateV1Form('CONTINUE_FROM_START_NEW')

cy.findByRole('heading', { level: 2, name: /Contract details/ })
cy.findByRole('button', {
name: 'Continue',
}).should('not.have.attr', 'aria-disabled')
cy.findByRole('button', {
name: 'Continue',
}).safeClick()
cy.checkA11yWithSection508()

cy.location().then((fullUrl) => {
const submissionURL = fullUrl.toString().replace(
'edit/contract-details',
''
)

// cy.findByRole('heading', {
// level: 2,
// name: /Contract details/,
// timeout: 10_000,
// })
// // cy.checkA11y()
//
// // check contract details a11y
// // cy.pa11y({
// // hideElements: '.usa-step-indicator',
// // actions: ['wait for element #form-guidance to be visible'],
// // threshold: 6,
// // hideElements: '.usa-step-indicator',
// // })
// cy.deprecatedNavigateV1Form('BACK')
// // check submissionType a11y
// // cy.pa11y({
// // hideElements: '.usa-step-indicator',
// // actions: ['wait for element #form-guidance to be visible'],
// // threshold: 6,
// // hideElements: '.usa-step-indicator',
// // })
// // cy.checkA11y()
//
// cy.deprecatedNavigateV1Form('CONTINUE')
// // cy.checkA11y()
// cy.deprecatedNavigateV1Form('CONTINUE')
// // cy.checkA11y()
//
// cy.findByRole('heading', { level: 2, name: /Contacts/ })
// // cy.checkA11y()
// cy.fillOutStateContact()
//
// // check contacts a11y
// // cy.pa11y({
// // hideElements: '.usa-step-indicator',
// // actions: ['wait for element #form-guidance to be visible'],
// // threshold: 6,
// // hideElements: '.usa-step-indicator',
// // })
//
// cy.deprecatedNavigateV1Form('SAVE_DRAFT')
// cy.findByRole('heading', { level: 1, name: /Submissions dashboard/ })
// //cy.checkA11y()
//
//
// cy.deprecatedNavigateV1Form('CONTINUE')
// // skip documents page - that will be deleted soon
// cy.deprecatedNavigateV1Form('CONTINUE')
//
// // Check that we end up on Review and Submit
// cy.findByRole('heading', { level: 2, name: /Review and submit/ })
// Check accessibility on rate details page
cy.navigateFormByDirectLink(`${submissionURL}edit/rate-details`)
cy.findByRole('radiogroup', {
name: /Was this rate certification included with another submission?/,
})
.should('exist')
.within(() => {
cy.findByText('No, this rate certification was not included with any other submissions').click()
})
cy.injectAxe()
cy.findByRole('button', {
name: 'Continue',
}).should('not.have.attr', 'aria-disabled')
cy.findByRole('button', {
name: 'Continue',
}).safeClick()
cy.checkA11yWithSection508()

// check review and submit a11y
// cy.pa11y({
// hideElements: '.usa-step-indicator',
// actions: ['wait for element #form-guidance to be visible'],
// threshold: 6,
// hideElements: '.usa-step-indicator',
// })
//Check accessibility on contacts page
cy.navigateFormByDirectLink(`${submissionURL}edit/contacts`)
cy.findByRole('heading', { level: 2, name: /Contacts/ })
cy.injectAxe()
cy.findByRole('button', {
name: 'Continue',
}).should('not.have.attr', 'aria-disabled')
cy.findByRole('button', {
name: 'Continue',
}).safeClick()
cy.checkA11yWithSection508()

//Check accessibility on documents page
cy.navigateFormByDirectLink(`${submissionURL}edit/documents`)
cy.findByRole('heading', { level: 2, name: /Supporting documents/ })
cy.injectAxe()
cy.findByRole('button', {
name: 'Continue',
}).should('not.have.attr', 'aria-disabled')
cy.findByRole('button', {
name: 'Continue',
}).safeClick()
cy.checkA11yWithSection508()

//Check accessibility on review and submit page
cy.navigateFormByDirectLink(`${submissionURL}edit/review-and-submit`)
cy.findByRole('heading', { level: 2, name: /Review and submit/ })
cy.injectAxe()
cy.checkA11yWithSection508()

//Check the dashboard
cy.navigateContractRatesForm('SAVE_DRAFT', false)
cy.checkA11yWithSection508()
})
})

it('has no errors on CMS dashboard', () => {
cy.apiCreateAndSubmitContractWithRates(stateUser()).then(() => {
cy.logInAsCMSUser()
cy.injectAxe()
//check submissions tab
cy.checkA11yWithSection508()

//check rate reviews tab
cy.findByRole('tab', { name: 'Rate reviews' }).should('exist').click()
cy.checkA11yWithSection508()
})
})
})

0 comments on commit 41333e9

Please sign in to comment.