From 596ae97cc3657e88210aa77cebe6e49ec3a1a66d Mon Sep 17 00:00:00 2001 From: ana-oprea <80201759+ana-oprea@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:50:12 +0200 Subject: [PATCH] Add Accessibility acceptance tests for content-types (#6339) Co-authored-by: ichim-david Co-authored-by: Jefferson Bledsoe Co-authored-by: Wagner Trezub <60133113+Wagner3UB@users.noreply.github.com> --- .../volto/cypress/tests/core/a11y/content.js | 100 ++++++++++++++++++ .../cypress/tests/core/basic/metadata.js | 1 + packages/volto/news/6339.internal | 1 + 3 files changed, 102 insertions(+) create mode 100644 packages/volto/cypress/tests/core/a11y/content.js create mode 100644 packages/volto/news/6339.internal diff --git a/packages/volto/cypress/tests/core/a11y/content.js b/packages/volto/cypress/tests/core/a11y/content.js new file mode 100644 index 0000000000..c266399a4b --- /dev/null +++ b/packages/volto/cypress/tests/core/a11y/content.js @@ -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(); + }); +}); diff --git a/packages/volto/cypress/tests/core/basic/metadata.js b/packages/volto/cypress/tests/core/basic/metadata.js index 6d5b414aad..7c7924cd1e 100644 --- a/packages/volto/cypress/tests/core/basic/metadata.js +++ b/packages/volto/cypress/tests/core/basic/metadata.js @@ -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}') diff --git a/packages/volto/news/6339.internal b/packages/volto/news/6339.internal new file mode 100644 index 0000000000..972df6ac4d --- /dev/null +++ b/packages/volto/news/6339.internal @@ -0,0 +1 @@ +Add Accessibility acceptance tests for content types. @ana-oprea @ichim-david