Enhance Search results tests (stabilize). Add more MyDSpace tests, including starting a submission

This commit is contained in:
Tim Donohue
2022-02-04 14:46:31 -06:00
parent ad32dbb864
commit ba40cfe75a
5 changed files with 101 additions and 20 deletions

View File

@@ -16,6 +16,8 @@
"DSPACE_TEST_ADMIN_PASSWORD": "dspace", "DSPACE_TEST_ADMIN_PASSWORD": "dspace",
"DSPACE_TEST_COMMUNITY": "0958c910-2037-42a9-81c7-dca80e3892b4", "DSPACE_TEST_COMMUNITY": "0958c910-2037-42a9-81c7-dca80e3892b4",
"DSPACE_TEST_COLLECTION": "282164f5-d325-4740-8dd1-fa4d6d3e7200", "DSPACE_TEST_COLLECTION": "282164f5-d325-4740-8dd1-fa4d6d3e7200",
"DSPACE_TEST_ENTITY_PUBLICATION": "e98b0f27-5c19-49a0-960d-eb6ad5287067" "DSPACE_TEST_COLLECTION_NAME": "Sample Collection",
"DSPACE_TEST_ENTITY_PUBLICATION": "e98b0f27-5c19-49a0-960d-eb6ad5287067",
"DSPACE_TEST_SEARCH_TERM": "test"
} }
} }

View File

@@ -1,29 +1,52 @@
import { Options } from 'cypress-axe'; import { Options } from 'cypress-axe';
import { TEST_ADMIN_USER, TEST_ADMIN_PASSWORD } from 'cypress/support'; import { TEST_ADMIN_USER, TEST_ADMIN_PASSWORD, TEST_COLLECTION_NAME } from 'cypress/support';
import { testA11y } from 'cypress/support/utils'; import { testA11y } from 'cypress/support/utils';
describe('My DSpace page', () => { describe('My DSpace page', () => {
it('should display recent submissions', () => { it('should display recent submissions and pass accessibility tests', () => {
cy.login(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD); cy.login(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
// This is the GET command that will automatically search for recent submissions
cy.intercept('GET', '/server/api/discover/search/objects*').as('search-results');
cy.visit('/mydspace');
// Wait for search results to come back from the above GET command
cy.wait('@search-results');
// At least one recent submission should be displayed
cy.get('ds-item-search-result-list-element-submission').should('be.visible');
});
it('should pass accessibility tests', () => {
cy.login(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
cy.visit('/mydspace'); cy.visit('/mydspace');
cy.get('ds-my-dspace-page').should('exist'); cy.get('ds-my-dspace-page').should('exist');
// At least one recent submission should be displayed
cy.get('ds-item-search-result-list-element-submission').should('be.visible');
// Click each filter toggle to open *every* filter
// (As we want to scan filter section for accessibility issues as well)
cy.get('.filter-toggle').click({ multiple: true });
// Analyze <ds-my-dspace-page> for accessibility issues
testA11y(
{
include: ['ds-my-dspace-page'],
exclude: [
['nouislider'] // Date filter slider is missing ARIA labels. Will be fixed by #1175
],
},
{
rules: {
// Search filters fail these two "moderate" impact rules
'heading-order': { enabled: false },
'landmark-unique': { enabled: false }
}
} as Options
);
});
it('should have a working detailed view that passes accessibility tests', () => {
cy.login(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
cy.visit('/mydspace');
cy.get('ds-my-dspace-page').should('exist');
// Click button in sidebar to display detailed view
cy.get('ds-search-sidebar [data-e2e="detail-view"]').click();
cy.get('ds-object-detail').should('exist');
// Analyze <ds-search-page> for accessibility issues // Analyze <ds-search-page> for accessibility issues
testA11y('ds-my-dspace-page', testA11y('ds-my-dspace-page',
{ {
@@ -35,4 +58,50 @@ describe('My DSpace page', () => {
} as Options } as Options
); );
}); });
it('should let you start a new submission', () => {
cy.login(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
cy.visit('/mydspace');
// Open the New Submission dropdown
cy.get('#dropdownSubmission').click();
// Click on the "Item" type in that dropdown
cy.get('#entityControlsDropdownMenu button[title="none"]').click();
// This should display the <ds-create-item-parent-selector> (popup window)
cy.get('ds-create-item-parent-selector').should('be.visible');
// Type in a known Collection name in the search box
cy.get('ds-authorized-collection-selector input[type="search"]').type(TEST_COLLECTION_NAME);
// Click on the button matching that known Collection name
cy.get('ds-authorized-collection-selector button[title="' + TEST_COLLECTION_NAME + '"]').click();
// New URL should include /workspaceitems, as we've started a new submission
cy.url().should('include', '/workspaceitems');
// The Submission edit form tag should be visible
cy.get('ds-submission-edit').should('be.visible');
// A Collection menu button should exist & it's value should be the selected collection
cy.get('#collectionControlsMenuButton span').should('have.text', TEST_COLLECTION_NAME);
});
it('should let you import from external sources', () => {
cy.login(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
cy.visit('/mydspace');
// Open the New Import dropdown
cy.get('#dropdownImport').click();
// Click on the "Item" type in that dropdown
cy.get('#importControlsDropdownMenu button[title="none"]').click();
// New URL should include /import-external, as we've moved to the import page
cy.url().should('include', '/import-external');
// The external import searchbox should be visible
cy.get('ds-submission-import-external-searchbar').should('be.visible');
});
}); });

View File

@@ -1,3 +1,5 @@
import { TEST_SEARCH_TERM } from 'cypress/support';
const page = { const page = {
fillOutQueryInNavBar(query) { fillOutQueryInNavBar(query) {
// Click the magnifying glass // Click the magnifying glass
@@ -15,7 +17,7 @@ const page = {
describe('Search from Navigation Bar', () => { describe('Search from Navigation Bar', () => {
// NOTE: these tests currently assume this query will return results! // NOTE: these tests currently assume this query will return results!
const query = 'test'; const query = TEST_SEARCH_TERM;
it('should go to search page with correct query if submitted (from home)', () => { it('should go to search page with correct query if submitted (from home)', () => {
cy.visit('/'); cy.visit('/');

View File

@@ -17,12 +17,15 @@ describe('Search Page', () => {
cy.url().should('include', 'query=' + encodeURI(queryString)); cy.url().should('include', 'query=' + encodeURI(queryString));
}); });
it('should pass accessibility tests', () => { it('should load results and pass accessibility tests', () => {
cy.visit('/search'); cy.visit('/search');
// <ds-search-page> tag must be loaded // <ds-search-page> tag must be loaded
cy.get('ds-search-page').should('exist'); cy.get('ds-search-page').should('exist');
// At least one search result should be displayed
cy.get('ds-item-search-result-list-element').should('be.visible');
// Click each filter toggle to open *every* filter // Click each filter toggle to open *every* filter
// (As we want to scan filter section for accessibility issues as well) // (As we want to scan filter section for accessibility issues as well)
cy.get('.filter-toggle').click({ multiple: true }); cy.get('.filter-toggle').click({ multiple: true });
@@ -45,7 +48,7 @@ describe('Search Page', () => {
); );
}); });
it('should pass accessibility tests in Grid view', () => { it('should have a working grid view that passes accessibility tests', () => {
cy.visit('/search'); cy.visit('/search');
// Click button in sidebar to display grid view // Click button in sidebar to display grid view
@@ -54,6 +57,9 @@ describe('Search Page', () => {
// <ds-search-page> tag must be loaded // <ds-search-page> tag must be loaded
cy.get('ds-search-page').should('exist'); cy.get('ds-search-page').should('exist');
// At least one grid element (card) should be displayed
cy.get('ds-item-search-result-grid-element').should('be.visible');
// Analyze <ds-search-page> for accessibility issues // Analyze <ds-search-page> for accessibility issues
testA11y('ds-search-page', testA11y('ds-search-page',
{ {

View File

@@ -37,5 +37,7 @@ export const TEST_REST_BASE_URL = Cypress.env('DSPACE_TEST_REST_BASE_URL') || 'h
export const TEST_ADMIN_USER = Cypress.env('DSPACE_TEST_ADMIN_USER') || 'dspacedemo+admin@gmail.com'; export const TEST_ADMIN_USER = Cypress.env('DSPACE_TEST_ADMIN_USER') || 'dspacedemo+admin@gmail.com';
export const TEST_ADMIN_PASSWORD = Cypress.env('DSPACE_TEST_ADMIN_PASSWORD') || 'dspace'; export const TEST_ADMIN_PASSWORD = Cypress.env('DSPACE_TEST_ADMIN_PASSWORD') || 'dspace';
export const TEST_COLLECTION = Cypress.env('DSPACE_TEST_COLLECTION') || '282164f5-d325-4740-8dd1-fa4d6d3e7200'; export const TEST_COLLECTION = Cypress.env('DSPACE_TEST_COLLECTION') || '282164f5-d325-4740-8dd1-fa4d6d3e7200';
export const TEST_COLLECTION_NAME = Cypress.env('DSPACE_TEST_COLLECTION_NAME') || 'Sample Collection';
export const TEST_COMMUNITY = Cypress.env('DSPACE_TEST_COMMUNITY') || '0958c910-2037-42a9-81c7-dca80e3892b4'; export const TEST_COMMUNITY = Cypress.env('DSPACE_TEST_COMMUNITY') || '0958c910-2037-42a9-81c7-dca80e3892b4';
export const TEST_ENTITY_PUBLICATION = Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION') || 'e98b0f27-5c19-49a0-960d-eb6ad5287067'; export const TEST_ENTITY_PUBLICATION = Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION') || 'e98b0f27-5c19-49a0-960d-eb6ad5287067';
export const TEST_SEARCH_TERM = Cypress.env('DSPACE_TEST_SEARCH_TERM') || 'test';