diff --git a/cypress.config.ts b/cypress.config.ts index 253644deabe..dbbbae24d8d 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -37,7 +37,9 @@ export default defineConfig({ DSPACE_TEST_SUBMIT_USER_UUID: '914955b1-cf2e-4884-8af7-a166aa24cf73', DSPACE_TEST_SUBMIT_USER_PASSWORD: 'dspace', // Administrator users group - DSPACE_ADMINISTRATOR_GROUP: 'e59f5659-bff9-451e-b28f-439e7bd467e4' + DSPACE_ADMINISTRATOR_GROUP: 'e59f5659-bff9-451e-b28f-439e7bd467e4', + //Collection to send and test workflow item + DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME: '1-step Workflow collection', }, e2e: { // Setup our plugins for e2e tests diff --git a/cypress/e2e/my-dspace.cy.ts b/cypress/e2e/my-dspace.cy.ts index 7f30eeb9bba..cb8552802d8 100644 --- a/cypress/e2e/my-dspace.cy.ts +++ b/cypress/e2e/my-dspace.cy.ts @@ -131,4 +131,151 @@ describe('My DSpace page', () => { testA11y('ds-submission-import-external'); }); + it('should let you filter to only archived items', () => { + cy.visit('/mydspace'); + + //To wait filter be ready + cy.intercept({ + method: 'GET', + url: '/server/api/discover/facets/namedresourcetype**', + }).as('facetNamedResourceType'); + + //This page is restricted, so we will be shown the login form. Fill it in and submit it + cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD')); + + //Wait for the page to display + cy.wait('@facetNamedResourceType'); + + //Open all filters + cy.get('.filter-toggle').click({ multiple: true }); + + //The authority filter should be visible. + cy.get('ds-search-authority-filter').scrollIntoView().should('be.visible'); + + //Intercept the request to filter and the request of filter. + cy.intercept({ + method: 'GET', + url: '/server/api/discover/search/objects**', + }).as('filterByItem'); + + //Apply the filter to the “archived” items. + cy.get('ds-search-authority-filter a[href*="f.namedresourcetype=item,authority"]').find('input[type="checkbox"]').click(); + + //Wait for the response. + cy.wait('@filterByItem'); + + //Check that we have at least one item and that they all have the archived badge. + cy.get('ds-item-search-result-list-element-submission').should('exist'); + cy.get('ds-item-search-result-list-element-submission') + .each(($item) => { + cy.wrap($item) + .find('.badge-archived') + .should('exist'); + }); + }); + + //This test also generate an item to validate workflow task section + it('should upload a file via drag & drop, display it in the UI and submit the item', () => { + const fileName = 'example.pdf'; + const currentYear = new Date().getFullYear(); + + cy.visit('/mydspace'); + + //This page is restricted, so we will be shown the login form. Fill it in and submit it + cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD')); + + //Wait for the page to display + cy.get('ds-my-dspace-page').should('be.visible'); + + //Select the uploader and perform the drag-and-drop action. + cy.get('ds-uploader .well').selectFile(`cypress/fixtures/${fileName}`, { action: 'drag-drop' }); + + //Validate that the file appears in the UI + cy.get('ds-uploader .filename').should('exist').and('contain.text', fileName); + + //Validate that there is now exactly 1 file in the queue + cy.get('ds-uploader .upload-item-top').should('have.length', 1); + + // This should display the (popup window) + cy.get('ds-collection-dropdown').should('be.visible'); + + // Type in a known Collection name in the search box + cy.get('ds-collection-dropdown input[type="search"]').type(Cypress.env('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME')); + + // Click on the button matching that known Collection name + cy.get('ds-collection-dropdown li[title="'.concat(Cypress.env('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME')).concat('"]')).click(); + + // New URL should include /workspaceitems, as we've started a new submission + cy.url().should('include', '/workspaceitems'); + + //Fill required fields + cy.get('#dc_title').type('Workflow test item'); + cy.get('#dc_date_issued_year').type(currentYear.toString()); + cy.get('input[name="dc.type"]').click(); + cy.get('.dropdown-menu').should('be.visible').contains('button', 'Other').click(); + cy.get('#granted').check(); + + //Press deposit button + cy.get('button[data-test="deposit"]').click(); + + //validate that URL is /mydspace + cy.url().should('include', '/mydspace'); + + }); + + it('should let you take task from workflow', () => { + cy.visit('/mydspace'); + + //This page is restricted, so we will be shown the login form. Fill it in and submit it + cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD')); + + //Wait for the page to display + cy.get('ds-my-dspace-page').should('be.visible'); + + //And wait to list is ready + cy.get('[data-test="objects"]').should('be.visible'); + + //Intercept to await backend response + cy.intercept({ + method: 'GET', + url: '/server/api/discover/search/objects**', + }).as('workflowSearch'); + + //Change view to see workflow tasks + cy.get('ds-search-switch-configuration select option[data-test="workflow"]') + .should('exist') + .invoke('attr', 'value') + .then(value => { + cy.get('ds-search-switch-configuration select').select(value); + }); + + //Await backend search response + cy.wait('@workflowSearch'); + + //Validate URL + cy.url().should('include', 'configuration=workflow'); + + //Wait to render the list and at leat one item + cy.get('[data-test="list-object"]').should('have.length.greaterThan', 0); + cy.get('[data-test="claim-button"]').should('exist'); + + //Check that we have at least one item in worflow search, the item have claim-button and can click in it. + cy.get('[data-test="list-object"]') + .then(($items) => { + const itemWithClaim = [...$items].find(item => + item.querySelector('[data-test="claim-button"]'), + ); + cy.wrap(itemWithClaim).should('exist'); + cy.wrap(itemWithClaim).as('selectedItem'); + cy.wrap(itemWithClaim).within(() => { + cy.get('ds-pool-task-actions').should('exist'); + cy.get('[data-test="claim-button"]').click(); + }); + }); + + //Finally, when you click the ‘Claim’ button, the actions for the selected item change + cy.get('@selectedItem').within(() => { + cy.get('ds-claimed-task-actions').should('exist'); + }); + }); }); diff --git a/cypress/fixtures/example.pdf b/cypress/fixtures/example.pdf new file mode 100644 index 00000000000..c01805e89c1 Binary files /dev/null and b/cypress/fixtures/example.pdf differ diff --git a/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.html b/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.html index 7df692c69f8..b79127d4ea5 100644 --- a/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.html +++ b/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.html @@ -1,5 +1,5 @@