From ba40cfe75ae971428890d96c0ac0f484ff39a4fb Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Fri, 4 Feb 2022 14:46:31 -0600 Subject: [PATCH] Enhance Search results tests (stabilize). Add more MyDSpace tests, including starting a submission --- cypress.json | 4 +- cypress/integration/my-dspace.spec.ts | 101 ++++++++++++++++++---- cypress/integration/search-navbar.spec.ts | 4 +- cypress/integration/search-page.spec.ts | 10 ++- cypress/support/index.ts | 2 + 5 files changed, 101 insertions(+), 20 deletions(-) diff --git a/cypress.json b/cypress.json index 549485eb9e..725f02fcb7 100644 --- a/cypress.json +++ b/cypress.json @@ -16,6 +16,8 @@ "DSPACE_TEST_ADMIN_PASSWORD": "dspace", "DSPACE_TEST_COMMUNITY": "0958c910-2037-42a9-81c7-dca80e3892b4", "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" } } \ No newline at end of file diff --git a/cypress/integration/my-dspace.spec.ts b/cypress/integration/my-dspace.spec.ts index 6348185065..970255dd5a 100644 --- a/cypress/integration/my-dspace.spec.ts +++ b/cypress/integration/my-dspace.spec.ts @@ -1,29 +1,52 @@ 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'; 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); - // 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.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 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 for accessibility issues testA11y('ds-my-dspace-page', { @@ -35,4 +58,50 @@ describe('My DSpace page', () => { } 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 (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'); + }); + }); diff --git a/cypress/integration/search-navbar.spec.ts b/cypress/integration/search-navbar.spec.ts index 53e713412e..3aa8e7248d 100644 --- a/cypress/integration/search-navbar.spec.ts +++ b/cypress/integration/search-navbar.spec.ts @@ -1,3 +1,5 @@ +import { TEST_SEARCH_TERM } from 'cypress/support'; + const page = { fillOutQueryInNavBar(query) { // Click the magnifying glass @@ -15,7 +17,7 @@ const page = { describe('Search from Navigation Bar', () => { // 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)', () => { cy.visit('/'); diff --git a/cypress/integration/search-page.spec.ts b/cypress/integration/search-page.spec.ts index 0765884952..cbd518b97c 100644 --- a/cypress/integration/search-page.spec.ts +++ b/cypress/integration/search-page.spec.ts @@ -17,12 +17,15 @@ describe('Search Page', () => { cy.url().should('include', 'query=' + encodeURI(queryString)); }); - it('should pass accessibility tests', () => { + it('should load results and pass accessibility tests', () => { cy.visit('/search'); // tag must be loaded 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 // (As we want to scan filter section for accessibility issues as well) 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'); // Click button in sidebar to display grid view @@ -54,6 +57,9 @@ describe('Search Page', () => { // tag must be loaded 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 for accessibility issues testA11y('ds-search-page', { diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 442f00b9fe..0213cfe55b 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -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_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_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_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';