Skip to content
4 changes: 3 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
147 changes: 147 additions & 0 deletions cypress/e2e/my-dspace.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ds-collection-dropdown> (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');
});
});
});
Binary file added cypress/fixtures/example.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<button type="button" class="btn btn-info mt-1 mb-3"
ngbTooltip="{{'submission.workflow.tasks.pool.claim_help' | translate}}" [dsBtnDisabled]="(processing$ | async)"
ngbTooltip="{{'submission.workflow.tasks.pool.claim_help' | translate}}" data-test="claim-button" [dsBtnDisabled]="(processing$ | async)"
(click)="claim()">
@if ((processing$ | async)) {
<span><i class='fas fa-circle-notch fa-spin'></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h3 id="configuration-switch">{{ 'search.switch-configuration.title' | translate
[(ngModel)]="selectedOption"
(change)="onSelect()">
@for (option of configurationList; track option) {
<option [ngValue]="option">
<option [attr.data-test]="option.value" [ngValue]="option">
{{option.label | translate}}
</option>
}
Expand Down
Loading