Skip to content

Commit

Permalink
Add Accessibility acceptance tests for content-types (#6339)
Browse files Browse the repository at this point in the history
Co-authored-by: ichim-david <[email protected]>
Co-authored-by: Jefferson Bledsoe <[email protected]>
Co-authored-by: Wagner Trezub <[email protected]>
  • Loading branch information
4 people authored Nov 26, 2024
1 parent 2d47989 commit 596ae97
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
100 changes: 100 additions & 0 deletions packages/volto/cypress/tests/core/a11y/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
describe('Accessibility Tests Content Types', () => {
beforeEach(() => {
cy.autologin();
cy.visit('/');
cy.injectAxe(); // make sure axe is available on the page
});

it('Event tested for a11y axe violations', () => {
cy.get('#toolbar-add').click();
cy.get('#toolbar-add-event').click();
cy.get('.documentFirstHeading').type('Test Event Content Type');

cy.get('#toolbar-save').click();

cy.wait(1000);
cy.get('.ics-download').contains('Download Event').focus();
cy.checkA11y();
});

it('File tested for a11y axe violations', () => {
cy.get('#toolbar-add').click();
cy.get('#toolbar-add-file').click();
cy.get('#field-title').type('Test File Content Type');
cy.get('#field-description').type(
'A11y cypress test for File content type',
);

cy.get('input[id="field-file"]').attachFile('file.pdf', {
subjectType: 'input',
});

cy.get('#toolbar-save').focus().click();

cy.wait(1000);
cy.contains('file.pdf').focus();
cy.checkA11y();
});

it('Image tested for a11y axe violations', () => {
cy.get('#toolbar-add').click();
cy.get('#toolbar-add-image').click();
cy.get('#field-title').type('Test Image Content Type');
cy.get('#field-description').type('Image description');
cy.fixture('image.png', 'base64')
.then((fc) => {
return Cypress.Blob.base64StringToBlob(fc);
})
.then((fileContent) => {
cy.get('input#field-image').attachFile(
{ fileContent, fileName: 'image.png', mimeType: 'image/png' },
{ subjectType: 'input' },
);
cy.get('#field-image-image').parent().parent().contains('image.png');
});
cy.get('#toolbar-save').click();

cy.wait(1000);
cy.get('#view img').should('have.attr', 'alt', 'Test Image Content Type');
cy.checkA11y();
});

it('Link tested for a11y axe violations', () => {
cy.get('#toolbar-add').click();
cy.get('#toolbar-add-link').click();
cy.get('#field-title').type('Test Link Content Type');
cy.get('#field-description').type(
'A11y cypress test for Link content type',
);
cy.get('#field-remoteUrl').type('https://google.com');
cy.get('#toolbar-save').click();

cy.wait(1000);
cy.get('a.external')
.should('have.attr', 'href', 'https://google.com')
.focus();
cy.checkA11y();
});

it('News Item tested for a11y axe violations', () => {
cy.get('#toolbar-add').click();
cy.get('#toolbar-add-news-item').click();
cy.get('.documentFirstHeading').type('Test News Content Type');
cy.get('#field-description').type('test summary');
cy.get('#field-subjects').type('test');
cy.get('#toolbar-save').click();

cy.wait(1000);
cy.checkA11y();
});

it('Page tested for a11y axe violations', () => {
cy.get('#toolbar-add').click();
cy.get('#toolbar-add-document').click();
cy.get('.documentFirstHeading').type('My Page');
cy.get('#toolbar-save').click();

cy.wait(1000);
cy.checkA11y();
});
});
1 change: 1 addition & 0 deletions packages/volto/cypress/tests/core/basic/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('Add Content Tests', () => {
});

it('After removing value of widget the focus should be removed from the field', () => {
cy.wait(2000);
cy.get('#field-creators').type('aaa');
cy.get('#field-creators')
.type('aaa{Enter}')
Expand Down
1 change: 1 addition & 0 deletions packages/volto/news/6339.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Accessibility acceptance tests for content types. @ana-oprea @ichim-david

0 comments on commit 596ae97

Please sign in to comment.