Skip to content

Commit 1c782b2

Browse files
authored
Merge pull request DSpace#2711 from tdonohue/add_accessibility_tests
Add more automated accessibility scanning to e2e tests & fix a few minor accessibility bugs
2 parents 55c191e + a5a89a4 commit 1c782b2

36 files changed

Lines changed: 728 additions & 236 deletions

cypress.config.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ export default defineConfig({
99
openMode: 0,
1010
},
1111
env: {
12-
// Global constants used in DSpace e2e tests (see also ./cypress/support/e2e.ts)
13-
// May be overridden in our cypress.json config file using specified environment variables.
12+
// Global DSpace environment variables used in all our Cypress e2e tests
13+
// May be modified in this config, or overridden in a variety of ways.
14+
// See Cypress environment variable docs: https://docs.cypress.io/guides/guides/environment-variables
1415
// Default values listed here are all valid for the Demo Entities Data set available at
1516
// https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
1617
// (This is the data set used in our CI environment)
@@ -21,12 +22,14 @@ export default defineConfig({
2122
// Community/collection/publication used for view/edit tests
2223
DSPACE_TEST_COMMUNITY: '0958c910-2037-42a9-81c7-dca80e3892b4',
2324
DSPACE_TEST_COLLECTION: '282164f5-d325-4740-8dd1-fa4d6d3e7200',
24-
DSPACE_TEST_ENTITY_PUBLICATION: 'e98b0f27-5c19-49a0-960d-eb6ad5287067',
25+
DSPACE_TEST_ENTITY_PUBLICATION: '6160810f-1e53-40db-81ef-f6621a727398',
2526
// Search term (should return results) used in search tests
2627
DSPACE_TEST_SEARCH_TERM: 'test',
27-
// Collection used for submission tests
28+
// Main Collection used for submission tests. Should be able to accept normal Item objects
2829
DSPACE_TEST_SUBMIT_COLLECTION_NAME: 'Sample Collection',
2930
DSPACE_TEST_SUBMIT_COLLECTION_UUID: '9d8334e9-25d3-4a67-9cea-3dffdef80144',
31+
// Collection used for Person entity submission tests. MUST be configured with EntityType=Person.
32+
DSPACE_TEST_SUBMIT_PERSON_COLLECTION_NAME: 'People',
3033
// Account used to test basic submission process
3134
DSPACE_TEST_SUBMIT_USER: 'dspacedemo+submit@gmail.com',
3235
DSPACE_TEST_SUBMIT_USER_PASSWORD: 'dspace',

cypress/e2e/admin-sidebar.cy.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Options } from 'cypress-axe';
2+
import { testA11y } from 'cypress/support/utils';
3+
4+
describe('Admin Sidebar', () => {
5+
beforeEach(() => {
6+
// Must login as an Admin for sidebar to appear
7+
cy.visit('/login');
8+
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
9+
});
10+
11+
it('should be pinnable and pass accessibility tests', () => {
12+
// Pin the sidebar open
13+
cy.get('#sidebar-collapse-toggle').click();
14+
15+
// Click on every expandable section to open all menus
16+
cy.get('ds-expandable-admin-sidebar-section').click({multiple: true});
17+
18+
// Analyze <ds-admin-sidebar> for accessibility
19+
testA11y('ds-admin-sidebar',
20+
{
21+
rules: {
22+
// Currently all expandable sections have nested interactive elements
23+
// See https://github.com/DSpace/dspace-angular/issues/2178
24+
'nested-interactive': { enabled: false },
25+
}
26+
} as Options);
27+
});
28+
});

cypress/e2e/breadcrumbs.cy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
21
import { testA11y } from 'cypress/support/utils';
32

43
describe('Breadcrumbs', () => {
54
it('should pass accessibility tests', () => {
65
// Visit an Item, as those have more breadcrumbs
7-
cy.visit('/entities/publication/'.concat(TEST_ENTITY_PUBLICATION));
6+
cy.visit('/entities/publication/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION')));
87

98
// Wait for breadcrumbs to be visible
109
cy.get('ds-breadcrumbs').should('be.visible');

cypress/e2e/collection-edit.cy.ts

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import { testA11y } from 'cypress/support/utils';
2+
3+
const COLLECTION_EDIT_PAGE = '/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')).concat('/edit');
4+
5+
beforeEach(() => {
6+
// All tests start with visiting the Edit Collection Page
7+
cy.visit(COLLECTION_EDIT_PAGE);
8+
9+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
10+
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
11+
});
12+
13+
describe('Edit Collection > Edit Metadata tab', () => {
14+
it('should pass accessibility tests', () => {
15+
// <ds-edit-collection> tag must be loaded
16+
cy.get('ds-edit-collection').should('be.visible');
17+
18+
// Analyze <ds-edit-collection> for accessibility issues
19+
testA11y('ds-edit-collection');
20+
});
21+
});
22+
23+
describe('Edit Collection > Assign Roles tab', () => {
24+
25+
it('should pass accessibility tests', () => {
26+
cy.get('a[data-test="roles"]').click();
27+
28+
// <ds-collection-roles> tag must be loaded
29+
cy.get('ds-collection-roles').should('be.visible');
30+
31+
// Analyze for accessibility issues
32+
testA11y('ds-collection-roles');
33+
});
34+
});
35+
36+
describe('Edit Collection > Content Source tab', () => {
37+
38+
it('should pass accessibility tests', () => {
39+
cy.get('a[data-test="source"]').click();
40+
41+
// <ds-collection-source> tag must be loaded
42+
cy.get('ds-collection-source').should('be.visible');
43+
44+
// Check the external source checkbox (to display all fields on the page)
45+
cy.get('#externalSourceCheck').check();
46+
47+
// Wait for the source controls to appear
48+
cy.get('ds-collection-source-controls').should('be.visible');
49+
50+
// Analyze entire page for accessibility issues
51+
testA11y('ds-collection-source');
52+
});
53+
});
54+
55+
describe('Edit Collection > Curate tab', () => {
56+
57+
it('should pass accessibility tests', () => {
58+
cy.get('a[data-test="curate"]').click();
59+
60+
// <ds-collection-curate> tag must be loaded
61+
cy.get('ds-collection-curate').should('be.visible');
62+
63+
// Analyze for accessibility issues
64+
testA11y('ds-collection-curate');
65+
});
66+
});
67+
68+
describe('Edit Collection > Access Control tab', () => {
69+
70+
it('should pass accessibility tests', () => {
71+
cy.get('a[data-test="access-control"]').click();
72+
73+
// <ds-collection-access-control> tag must be loaded
74+
cy.get('ds-collection-access-control').should('be.visible');
75+
76+
// Analyze for accessibility issues
77+
testA11y('ds-collection-access-control');
78+
});
79+
});
80+
81+
describe('Edit Collection > Authorizations tab', () => {
82+
83+
it('should pass accessibility tests', () => {
84+
cy.get('a[data-test="authorizations"]').click();
85+
86+
// <ds-collection-authorizations> tag must be loaded
87+
cy.get('ds-collection-authorizations').should('be.visible');
88+
89+
// Analyze for accessibility issues
90+
testA11y('ds-collection-authorizations');
91+
});
92+
});
93+
94+
describe('Edit Collection > Item Mapper tab', () => {
95+
96+
it('should pass accessibility tests', () => {
97+
cy.get('a[data-test="mapper"]').click();
98+
99+
// <ds-collection-item-mapper> tag must be loaded
100+
cy.get('ds-collection-item-mapper').should('be.visible');
101+
102+
// Analyze entire page for accessibility issues
103+
testA11y('ds-collection-item-mapper');
104+
105+
// Click on the "Map new Items" tab
106+
cy.get('li[data-test="mapTab"] a').click();
107+
108+
// Make sure search form is now visible
109+
cy.get('ds-search-form').should('be.visible');
110+
111+
// Analyze entire page (again) for accessibility issues
112+
testA11y('ds-collection-item-mapper');
113+
});
114+
});
115+
116+
117+
describe('Edit Collection > Delete page', () => {
118+
119+
it('should pass accessibility tests', () => {
120+
cy.get('a[data-test="delete-button"]').click();
121+
122+
// <ds-delete-collection> tag must be loaded
123+
cy.get('ds-delete-collection').should('be.visible');
124+
125+
// Analyze for accessibility issues
126+
testA11y('ds-delete-collection');
127+
});
128+
});

cypress/e2e/collection-page.cy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { TEST_COLLECTION } from 'cypress/support/e2e';
21
import { testA11y } from 'cypress/support/utils';
32

43
describe('Collection Page', () => {
54

65
it('should pass accessibility tests', () => {
7-
cy.visit('/collections/'.concat(TEST_COLLECTION));
6+
cy.visit('/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')));
87

98
// <ds-collection-page> tag must be loaded
109
cy.get('ds-collection-page').should('be.visible');

cypress/e2e/collection-statistics.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_COLLECTION } from 'cypress/support/e2e';
1+
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
22
import { testA11y } from 'cypress/support/utils';
33

44
describe('Collection Statistics Page', () => {
5-
const COLLECTIONSTATISTICSPAGE = '/statistics/collections/'.concat(TEST_COLLECTION);
5+
const COLLECTIONSTATISTICSPAGE = '/statistics/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION'));
66

77
it('should load if you click on "Statistics" from a Collection page', () => {
8-
cy.visit('/collections/'.concat(TEST_COLLECTION));
8+
cy.visit('/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')));
99
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
1010
cy.location('pathname').should('eq', COLLECTIONSTATISTICSPAGE);
1111
});
@@ -18,7 +18,7 @@ describe('Collection Statistics Page', () => {
1818
it('should contain a "Total visits per month" section', () => {
1919
cy.visit(COLLECTIONSTATISTICSPAGE);
2020
// Check just for existence because this table is empty in CI environment as it's historical data
21-
cy.get('.'.concat(TEST_COLLECTION).concat('_TotalVisitsPerMonth')).should('exist');
21+
cy.get('.'.concat(Cypress.env('DSPACE_TEST_COLLECTION')).concat('_TotalVisitsPerMonth')).should('exist');
2222
});
2323

2424
it('should pass accessibility tests', () => {

cypress/e2e/community-edit.cy.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { testA11y } from 'cypress/support/utils';
2+
3+
const COMMUNITY_EDIT_PAGE = '/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')).concat('/edit');
4+
5+
beforeEach(() => {
6+
// All tests start with visiting the Edit Community Page
7+
cy.visit(COMMUNITY_EDIT_PAGE);
8+
9+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
10+
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
11+
});
12+
13+
describe('Edit Community > Edit Metadata tab', () => {
14+
it('should pass accessibility tests', () => {
15+
// <ds-edit-community> tag must be loaded
16+
cy.get('ds-edit-community').should('be.visible');
17+
18+
// Analyze <ds-edit-community> for accessibility issues
19+
testA11y('ds-edit-community');
20+
});
21+
});
22+
23+
describe('Edit Community > Assign Roles tab', () => {
24+
25+
it('should pass accessibility tests', () => {
26+
cy.get('a[data-test="roles"]').click();
27+
28+
// <ds-community-roles> tag must be loaded
29+
cy.get('ds-community-roles').should('be.visible');
30+
31+
// Analyze for accessibility issues
32+
testA11y('ds-community-roles');
33+
});
34+
});
35+
36+
describe('Edit Community > Curate tab', () => {
37+
38+
it('should pass accessibility tests', () => {
39+
cy.get('a[data-test="curate"]').click();
40+
41+
// <ds-community-curate> tag must be loaded
42+
cy.get('ds-community-curate').should('be.visible');
43+
44+
// Analyze for accessibility issues
45+
testA11y('ds-community-curate');
46+
});
47+
});
48+
49+
describe('Edit Community > Access Control tab', () => {
50+
51+
it('should pass accessibility tests', () => {
52+
cy.get('a[data-test="access-control"]').click();
53+
54+
// <ds-community-access-control> tag must be loaded
55+
cy.get('ds-community-access-control').should('be.visible');
56+
57+
// Analyze for accessibility issues
58+
testA11y('ds-community-access-control');
59+
});
60+
});
61+
62+
describe('Edit Community > Authorizations tab', () => {
63+
64+
it('should pass accessibility tests', () => {
65+
cy.get('a[data-test="authorizations"]').click();
66+
67+
// <ds-community-authorizations> tag must be loaded
68+
cy.get('ds-community-authorizations').should('be.visible');
69+
70+
// Analyze for accessibility issues
71+
testA11y('ds-community-authorizations');
72+
});
73+
});
74+
75+
describe('Edit Community > Delete page', () => {
76+
77+
it('should pass accessibility tests', () => {
78+
cy.get('a[data-test="delete-button"]').click();
79+
80+
// <ds-delete-community> tag must be loaded
81+
cy.get('ds-delete-community').should('be.visible');
82+
83+
// Analyze for accessibility issues
84+
testA11y('ds-delete-community');
85+
});
86+
});

cypress/e2e/community-page.cy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { TEST_COMMUNITY } from 'cypress/support/e2e';
21
import { testA11y } from 'cypress/support/utils';
32

43
describe('Community Page', () => {
54

65
it('should pass accessibility tests', () => {
7-
cy.visit('/communities/'.concat(TEST_COMMUNITY));
6+
cy.visit('/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')));
87

98
// <ds-community-page> tag must be loaded
109
cy.get('ds-community-page').should('be.visible');
1110

1211
// Analyze <ds-community-page> for accessibility issues
13-
testA11y('ds-community-page',);
12+
testA11y('ds-community-page');
1413
});
1514
});

cypress/e2e/community-statistics.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_COMMUNITY } from 'cypress/support/e2e';
1+
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
22
import { testA11y } from 'cypress/support/utils';
33

44
describe('Community Statistics Page', () => {
5-
const COMMUNITYSTATISTICSPAGE = '/statistics/communities/'.concat(TEST_COMMUNITY);
5+
const COMMUNITYSTATISTICSPAGE = '/statistics/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY'));
66

77
it('should load if you click on "Statistics" from a Community page', () => {
8-
cy.visit('/communities/'.concat(TEST_COMMUNITY));
8+
cy.visit('/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')));
99
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
1010
cy.location('pathname').should('eq', COMMUNITYSTATISTICSPAGE);
1111
});
@@ -18,7 +18,7 @@ describe('Community Statistics Page', () => {
1818
it('should contain a "Total visits per month" section', () => {
1919
cy.visit(COMMUNITYSTATISTICSPAGE);
2020
// Check just for existence because this table is empty in CI environment as it's historical data
21-
cy.get('.'.concat(TEST_COMMUNITY).concat('_TotalVisitsPerMonth')).should('exist');
21+
cy.get('.'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')).concat('_TotalVisitsPerMonth')).should('exist');
2222
});
2323

2424
it('should pass accessibility tests', () => {

cypress/e2e/homepage-statistics.cy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
1+
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
22
import { testA11y } from 'cypress/support/utils';
33
import '../support/commands';
44

@@ -11,8 +11,8 @@ describe('Site Statistics Page', () => {
1111

1212
it('should pass accessibility tests', () => {
1313
// generate 2 view events on an Item's page
14-
cy.generateViewEvent(TEST_ENTITY_PUBLICATION, 'item');
15-
cy.generateViewEvent(TEST_ENTITY_PUBLICATION, 'item');
14+
cy.generateViewEvent(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'), 'item');
15+
cy.generateViewEvent(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'), 'item');
1616

1717
cy.visit('/statistics');
1818

0 commit comments

Comments
 (0)