Skip to content

Commit 8d61fa6

Browse files
committed
Improve accessibility testing on Submission page
1 parent a581219 commit 8d61fa6

1 file changed

Lines changed: 85 additions & 2 deletions

File tree

cypress/e2e/submission.cy.ts

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD, TEST_SUBMIT_COLLECTION_NAME, TEST_SUBMIT_COLLECTION_UUID } from 'cypress/support/e2e';
1+
import { testA11y } from 'cypress/support/utils';
2+
import { TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD, TEST_SUBMIT_COLLECTION_NAME, TEST_SUBMIT_COLLECTION_UUID, TEST_ADMIN_USER, TEST_ADMIN_PASSWORD } from 'cypress/support/e2e';
3+
import { Options } from 'cypress-axe';
24

35
describe('New Submission page', () => {
4-
// NOTE: We already test that new submissions can be started from MyDSpace in my-dspace.spec.ts
56

7+
// NOTE: We already test that new Item submissions can be started from MyDSpace in my-dspace.spec.ts
68
it('should create a new submission when using /submit path & pass accessibility', () => {
79
// Test that calling /submit with collection & entityType will create a new submission
810
cy.visit('/submit?collection='.concat(TEST_SUBMIT_COLLECTION_UUID).concat('&entityType=none'));
@@ -25,6 +27,22 @@ describe('New Submission page', () => {
2527
cy.get('div#section_upload').should('be.visible');
2628
cy.get('div#section_license').should('be.visible');
2729

30+
// Test entire page for accessibility
31+
testA11y('ds-submission-edit',
32+
{
33+
rules: {
34+
// Author & Subject fields have invalid "aria-multiline" attrs, see #1272
35+
'aria-allowed-attr': { enabled: false },
36+
// All panels are accordians & fail "aria-required-children" and "nested-interactive". Seem to require updating ng-bootstrap and #2216
37+
'aria-required-children': { enabled: false },
38+
'nested-interactive': { enabled: false },
39+
// All select boxes fail to have a name / aria-label. This is a bug in ng-dynamic-forms and may require #2216
40+
'select-name': { enabled: false },
41+
}
42+
43+
} as Options
44+
);
45+
2846
// Discard button should work
2947
// Clicking it will display a confirmation, which we will confirm with another click
3048
cy.get('button#discard').click();
@@ -131,4 +149,69 @@ describe('New Submission page', () => {
131149
cy.get('ds-notification div.alert-success').should('be.visible');
132150
});
133151

152+
it('is possible to submit a new "Person" and that form passes accessibility', () => {
153+
// To submit a different entity type, we'll start from MyDSpace
154+
cy.visit('/mydspace');
155+
156+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
157+
// NOTE: At this time, we MUST login as admin to submit Person objects
158+
cy.loginViaForm(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
159+
160+
// Open the New Submission dropdown
161+
cy.get('button[data-test="submission-dropdown"]').click();
162+
// Click on the "Person" type in that dropdown
163+
cy.get('#entityControlsDropdownMenu button[title="Person"]').click();
164+
165+
// This should display the <ds-create-item-parent-selector> (popup window)
166+
cy.get('ds-create-item-parent-selector').should('be.visible');
167+
168+
// Click on the first Collection button to seelect a collection (actual collection doesn't matter)
169+
cy.get('ds-authorized-collection-selector button:first-child').click();
170+
171+
// New URL should include /workspaceitems, as we've started a new submission
172+
cy.url().should('include', '/workspaceitems');
173+
174+
// The Submission edit form tag should be visible
175+
cy.get('ds-submission-edit').should('be.visible');
176+
177+
// 3 sections should be visible by default
178+
cy.get('div#section_personStep').should('be.visible');
179+
cy.get('div#section_upload').should('be.visible');
180+
cy.get('div#section_license').should('be.visible');
181+
182+
// Test entire page for accessibility
183+
testA11y('ds-submission-edit',
184+
{
185+
rules: {
186+
// All panels are accordians & fail "aria-required-children" and "nested-interactive". Seem to require updating ng-bootstrap and #2216
187+
'aria-required-children': { enabled: false },
188+
'nested-interactive': { enabled: false },
189+
}
190+
191+
} as Options
192+
);
193+
194+
// Click the lookup button next to "Publication" field
195+
cy.get('button[data-test="lookup-button"]').click();
196+
197+
// A popup modal window should be visible
198+
cy.get('ds-dynamic-lookup-relation-modal').should('be.visible');
199+
200+
// Popup modal should also pass accessibility tests
201+
//testA11y('ds-dynamic-lookup-relation-modal');
202+
testA11y({
203+
include: ['ds-dynamic-lookup-relation-modal'],
204+
exclude: [
205+
['ul.nav-tabs'] // Tabs at top of model have several issues which seem to be caused by ng-bootstrap
206+
],
207+
});
208+
209+
// Close popup window
210+
cy.get('ds-dynamic-lookup-relation-modal button.close').click();
211+
212+
// Back on the form, click the discard button to remove new submission
213+
// Clicking it will display a confirmation, which we will confirm with another click
214+
cy.get('button#discard').click();
215+
cy.get('button#discard_submit').click();
216+
});
134217
});

0 commit comments

Comments
 (0)