Skip to content
Open
6 changes: 6 additions & 0 deletions cypress/e2e/collection-create.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ it('should show loading component while saving', () => {
const title = 'Test Collection Title';
cy.get('#title').type(title);

// the spinner hides as soon as the save is done, so hold the reply
cy.intercept('POST', '**/api/core/collections*', (req) => {
req.on('response', (res) => {
res.setDelay(2000);
});
});
cy.get('button[type="submit"]').click();

cy.get('ds-loading').should('be.visible');
Expand Down
6 changes: 6 additions & 0 deletions cypress/e2e/community-create.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ it('should show loading component while saving', () => {
const title = 'Test Community Title';
cy.get('#title').type(title);

// the spinner hides as soon as the save is done, so hold the reply
cy.intercept('POST', '**/api/core/communities*', (req) => {
req.on('response', (res) => {
res.setDelay(2000);
});
});
cy.get('button[type="submit"]').click();

cy.get('ds-loading').should('be.visible');
Expand Down
14 changes: 6 additions & 8 deletions cypress/e2e/my-dspace.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,12 @@ describe('My DSpace page', () => {
//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');
});
//Check that we have at least one result and that every result row has the archived badge.
//The list renders again after the response, so retry the check on the current list.
cy.get('ds-search-results [data-test="list-object"]').should(($rows) => {
expect($rows).to.have.length.greaterThan(0);
expect($rows.filter(':not(:has(.badge-archived))')).to.have.length(0);
});
});

//This test also generate an item to validate workflow task section
Expand Down
40 changes: 0 additions & 40 deletions cypress/e2e/submission.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,46 +148,6 @@ describe('New Submission page', () => {
});
});

it('should allow for deposit if all required fields completed & file uploaded', () => {
// Create a new submission
cy.visit('/submit?collection='.concat(Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_UUID')).concat('&entityType=none'));

// This page is restricted, so we will be shown the login form. Fill it out & submit.
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));

// Fill out all required fields (Title, Date)
cy.get('input#dc_title').type('DSpace logo uploaded via e2e tests');
cy.get('input#dc_date_issued_year').type('2022');

// Confirm the required license by checking checkbox
// (NOTE: requires "force:true" cause Cypress claims this checkbox is covered by its own <span>)
cy.get('ds-clarin-license-distribution ng-toggle').click();

// Before using Cypress drag & drop, we have to manually trigger the "dragover" event.
// This ensures our UI displays the dropzone that covers the entire submission page.
// (For some reason Cypress drag & drop doesn't trigger this even itself & upload won't work without this trigger)
cy.get('ds-uploader').trigger('dragover');

// This is the POST command that will upload the file
cy.intercept('POST', '/server/api/submission/workspaceitems/*').as('upload');

// Upload our DSpace logo via drag & drop onto submission form
// cy.get('div#section_upload')
cy.get('div.ds-document-drop-zone').selectFile('src/assets/images/dspace-logo.svg', {
action: 'drag-drop',
});

// Wait for upload to complete before proceeding
cy.wait('@upload');

// Wait for deposit button to not be disabled & click it.
cy.get('button#deposit').should('not.be.disabled').click();

// No warnings should exist. Instead, just successful deposit alert is displayed
cy.get('ds-notification div.alert-warning').should('not.exist');
cy.get('ds-notification div.alert-success').should('be.visible');
});

it('is possible to submit a new "Person" and that form passes accessibility', () => {
// To submit a different entity type, we'll start from MyDSpace
cy.visit('/mydspace');
Expand Down
7 changes: 7 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,15 @@ function loginViaForm(email: string, password: string): void {
cy.get('[data-test="email"]').should('be.visible').type(email);
// Enter password
cy.get('[data-test="password"]').should('be.visible').type(password);
// The app reloads itself after login and renders the page again once it starts,
// so wait for the new page and for the app to leave /reload/.
cy.window().then((win) => {
(win as any).dsBeforeLogin = true;
});
// Click login button
cy.get('[data-test="login-button"]').click();
cy.window({ timeout: 20000 }).should('not.have.property', 'dsBeforeLogin');
cy.location('pathname', { timeout: 20000 }).should('not.contain', '/reload/');
}
// Add as a Cypress command (i.e. assign to 'cy.loginViaForm')
Cypress.Commands.add('loginViaForm', loginViaForm);
Expand Down
7 changes: 1 addition & 6 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ import { DSPACE_XSRF_COOKIE } from 'src/app/core/xsrf/xsrf.constants';

// Known flaky tests, skipped until they are fixed. Remove an entry once its test is fixed.
// Each entry is '<spec file name> > <full test title>'.
const QUARANTINED_TESTS = [
'collection-create.cy.ts > should show loading component while saving',
'community-create.cy.ts > should show loading component while saving',
'my-dspace.cy.ts > My DSpace page should let you filter to only archived items',
'submission.cy.ts > New Submission page should allow for deposit if all required fields completed & file uploaded',
];
const QUARANTINED_TESTS: string[] = [];

beforeEach(function () {
if (QUARANTINED_TESTS.includes(`${Cypress.spec.name} > ${this.currentTest.fullTitle()}`)) {
Expand Down
Loading