diff --git a/cypress/e2e/collection-create.cy.ts b/cypress/e2e/collection-create.cy.ts index 29f7dd5cacb..f24fe2df3ea 100644 --- a/cypress/e2e/collection-create.cy.ts +++ b/cypress/e2e/collection-create.cy.ts @@ -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'); diff --git a/cypress/e2e/community-create.cy.ts b/cypress/e2e/community-create.cy.ts index 96bc003ba2a..6f0c3c4dfe4 100644 --- a/cypress/e2e/community-create.cy.ts +++ b/cypress/e2e/community-create.cy.ts @@ -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'); diff --git a/cypress/e2e/my-dspace.cy.ts b/cypress/e2e/my-dspace.cy.ts index 7455beb5853..18746e25f40 100644 --- a/cypress/e2e/my-dspace.cy.ts +++ b/cypress/e2e/my-dspace.cy.ts @@ -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 diff --git a/cypress/e2e/submission.cy.ts b/cypress/e2e/submission.cy.ts index 16aa5b2d472..133a4421d81 100644 --- a/cypress/e2e/submission.cy.ts +++ b/cypress/e2e/submission.cy.ts @@ -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 ) - 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'); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 8f81fa871d7..73af5737d44 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -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); diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index 5181ebf2d5b..115842a3e4e 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -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 ' > '. -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()}`)) {