|
| 1 | +import { Options } from 'cypress-axe'; |
| 2 | +import { testA11y } from 'cypress/support/utils'; |
| 3 | + |
| 4 | +const ITEM_EDIT_PAGE = '/items/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION')).concat('/edit'); |
| 5 | + |
| 6 | +beforeEach(() => { |
| 7 | + // All tests start with visiting the Edit Item Page |
| 8 | + cy.visit(ITEM_EDIT_PAGE); |
| 9 | + |
| 10 | + // This page is restricted, so we will be shown the login form. Fill it out & submit. |
| 11 | + cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD')); |
| 12 | +}); |
| 13 | + |
| 14 | +describe('Edit Item > Edit Metadata tab', () => { |
| 15 | + it('should pass accessibility tests', () => { |
| 16 | + cy.get('a[data-test="metadata"]').click(); |
| 17 | + |
| 18 | + // <ds-edit-item-page> tag must be loaded |
| 19 | + cy.get('ds-edit-item-page').should('be.visible'); |
| 20 | + |
| 21 | + // Analyze <ds-edit-item-page> for accessibility issues |
| 22 | + testA11y('ds-edit-item-page'); |
| 23 | + }); |
| 24 | +}); |
| 25 | + |
| 26 | +describe('Edit Item > Status tab', () => { |
| 27 | + |
| 28 | + it('should pass accessibility tests', () => { |
| 29 | + cy.get('a[data-test="status"]').click(); |
| 30 | + |
| 31 | + // <ds-item-status> tag must be loaded |
| 32 | + cy.get('ds-item-status').should('be.visible'); |
| 33 | + |
| 34 | + // Analyze for accessibility issues |
| 35 | + testA11y('ds-item-status'); |
| 36 | + }); |
| 37 | +}); |
| 38 | + |
| 39 | +describe('Edit Item > Bitstreams tab', () => { |
| 40 | + |
| 41 | + it('should pass accessibility tests', () => { |
| 42 | + cy.get('a[data-test="bitstreams"]').click(); |
| 43 | + |
| 44 | + // <ds-item-bitstreams> tag must be loaded |
| 45 | + cy.get('ds-item-bitstreams').should('be.visible'); |
| 46 | + |
| 47 | + // Table of item bitstreams must also be loaded |
| 48 | + cy.get('div.item-bitstreams').should('be.visible'); |
| 49 | + |
| 50 | + // Analyze for accessibility issues |
| 51 | + testA11y('ds-item-bitstreams', |
| 52 | + { |
| 53 | + rules: { |
| 54 | + // Currently Bitstreams page loads a pagination component per Bundle |
| 55 | + // and they all use the same 'id="p-dad"'. |
| 56 | + 'duplicate-id': { enabled: false }, |
| 57 | + } |
| 58 | + } as Options |
| 59 | + ); |
| 60 | + }); |
| 61 | +}); |
| 62 | + |
| 63 | +describe('Edit Item > Curate tab', () => { |
| 64 | + |
| 65 | + it('should pass accessibility tests', () => { |
| 66 | + cy.get('a[data-test="curate"]').click(); |
| 67 | + |
| 68 | + // <ds-item-curate> tag must be loaded |
| 69 | + cy.get('ds-item-curate').should('be.visible'); |
| 70 | + |
| 71 | + // Analyze for accessibility issues |
| 72 | + testA11y('ds-item-curate'); |
| 73 | + }); |
| 74 | +}); |
| 75 | + |
| 76 | +describe('Edit Item > Relationships tab', () => { |
| 77 | + |
| 78 | + it('should pass accessibility tests', () => { |
| 79 | + cy.get('a[data-test="relationships"]').click(); |
| 80 | + |
| 81 | + // <ds-item-relationships> tag must be loaded |
| 82 | + cy.get('ds-item-relationships').should('be.visible'); |
| 83 | + |
| 84 | + // Analyze for accessibility issues |
| 85 | + testA11y('ds-item-relationships'); |
| 86 | + }); |
| 87 | +}); |
| 88 | + |
| 89 | +describe('Edit Item > Version History tab', () => { |
| 90 | + |
| 91 | + it('should pass accessibility tests', () => { |
| 92 | + cy.get('a[data-test="versionhistory"]').click(); |
| 93 | + |
| 94 | + // <ds-item-version-history> tag must be loaded |
| 95 | + cy.get('ds-item-version-history').should('be.visible'); |
| 96 | + |
| 97 | + // Analyze for accessibility issues |
| 98 | + testA11y('ds-item-version-history'); |
| 99 | + }); |
| 100 | +}); |
| 101 | + |
| 102 | +describe('Edit Item > Access Control tab', () => { |
| 103 | + |
| 104 | + it('should pass accessibility tests', () => { |
| 105 | + cy.get('a[data-test="access-control"]').click(); |
| 106 | + |
| 107 | + // <ds-item-access-control> tag must be loaded |
| 108 | + cy.get('ds-item-access-control').should('be.visible'); |
| 109 | + |
| 110 | + // Analyze for accessibility issues |
| 111 | + testA11y('ds-item-access-control'); |
| 112 | + }); |
| 113 | +}); |
| 114 | + |
| 115 | +describe('Edit Item > Collection Mapper tab', () => { |
| 116 | + |
| 117 | + it('should pass accessibility tests', () => { |
| 118 | + cy.get('a[data-test="mapper"]').click(); |
| 119 | + |
| 120 | + // <ds-item-collection-mapper> tag must be loaded |
| 121 | + cy.get('ds-item-collection-mapper').should('be.visible'); |
| 122 | + |
| 123 | + // Analyze entire page for accessibility issues |
| 124 | + testA11y('ds-item-collection-mapper'); |
| 125 | + |
| 126 | + // Click on the "Map new collections" tab |
| 127 | + cy.get('li[data-test="mapTab"] a').click(); |
| 128 | + |
| 129 | + // Make sure search form is now visible |
| 130 | + cy.get('ds-search-form').should('be.visible'); |
| 131 | + |
| 132 | + // Analyze entire page (again) for accessibility issues |
| 133 | + testA11y('ds-item-collection-mapper'); |
| 134 | + }); |
| 135 | +}); |
0 commit comments