diff --git a/cypress/e2e/submission-ui.cy.ts b/cypress/e2e/submission-ui.cy.ts index f52c78517e4..3c1d580e43d 100644 --- a/cypress/e2e/submission-ui.cy.ts +++ b/cypress/e2e/submission-ui.cy.ts @@ -186,7 +186,7 @@ describe('Create a new submission', () => { createItemProcess.checkLicenseSelectionValue('Public Domain Mark (PD)'); }); - it('should select the license from the license selection dropdown and change status', { + it.skip('should select the license from the license selection dropdown and change status', { retries: { runMode: 6, openMode: 6, @@ -194,6 +194,7 @@ describe('Create a new submission', () => { defaultCommandTimeout: 10000 },() => { createItemProcess.checkLicenseResourceStep(); + // check default value in the license dropdown selection createItemProcess.checkLicenseSelectionValue('Select a License ...'); // check step status - it should be as warning @@ -208,7 +209,7 @@ describe('Create a new submission', () => { createItemProcess.checkResourceLicenseStatus('Valid'); }); - it('should show warning messages if was selected non-supported license', { + it.skip('should show warning messages if was selected non-supported license', { retries: { runMode: 6, openMode: 6, @@ -216,6 +217,7 @@ describe('Create a new submission', () => { defaultCommandTimeout: 10000 },() => { createItemProcess.checkLicenseResourceStep(); + // check default value in the license dropdown selection createItemProcess.checkLicenseSelectionValue('Select a License ...'); // check step status - it should be as warning @@ -233,6 +235,71 @@ describe('Create a new submission', () => { createItemProcess.showErrorNotSupportedLicense(); }); + it('should require license validation when file is uploaded', { + retries: { + runMode: 6, + openMode: 6, + }, + defaultCommandTimeout: 10000 + }, () => { + // Navigate to license step + createItemProcess.checkLicenseResourceStep(); + + // Upload a file to trigger license requirement + cy.get('ds-uploader').trigger('dragover'); + cy.intercept('POST', '/server/api/submission/workspaceitems/*').as('upload'); + cy.get('div.ds-document-drop-zone').selectFile('src/assets/images/dspace-logo.png', { + action: 'drag-drop' + }); + cy.wait('@upload'); + + // Allow frontend to propagate validation state to the header icon + cy.wait(1000); + cy.get('div[id="section_clarin-license"]').find('.card-header').should('be.visible'); + + // Now license is required - should see warnings + createItemProcess.checkLicenseSelectionValue('Select a License ...'); + createItemProcess.checkResourceLicenseStatus('Errors'); + + // Select a valid license + createItemProcess.clickOnLicenseSelectionButton(); + createItemProcess.selectValueFromLicenseSelection(2); // GNU GPL v2 + createItemProcess.checkLicenseSelectionValue('GNU General Public License, version 2'); + + // Status should change to Valid + createItemProcess.checkResourceLicenseStatus('Valid'); + }); + + it('should not show validation warnings when no file is uploaded (metadata-only)', { + retries: { + runMode: 6, + openMode: 6, + }, + defaultCommandTimeout: 10000 + }, () => { + // Navigate to license step + createItemProcess.checkLicenseResourceStep(); + + // DON'T upload any file - just check the license section is accessible + createItemProcess.checkLicenseSelectionValue('Select a License ...'); + + // Verify warning and error icons do NOT exist + cy.get('div[id="section_clarin-license"]') + .find('.card-header') + .find('.fa-exclamation-circle.text-warning') + .should('not.exist'); + + cy.get('div[id="section_clarin-license"]') + .find('.card-header') + .find('.fa-exclamation-circle.text-danger') + .should('not.exist'); + + cy.get('div[id="section_clarin-license"]') + .find('.card-header') + .find('.fa-check-circle.text-success') + .should('be.visible'); + }); + it('The submission should not have the Notice Step', { retries: { runMode: 6, diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index e7fbeecf151..bbc9e60bbfd 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -343,7 +343,17 @@ export const createItemProcess = { cy.get('ds-submission-section-clarin-license input[id = "aspect_submission_StepTransformer_field_license"]').click(); }, checkResourceLicenseStatus(statusTitle: string) { - cy.get('div[id = "clarin-license-header"] button i[title = "' + statusTitle + '"]').should('be.visible'); + // cy.get('div[id = "clarin-license-header"] button i[title = "' + statusTitle + '"]').should('be.visible'); + const iconMap = { + 'Warnings': '.fa-exclamation-circle.text-warning', + 'Errors': '.fa-exclamation-circle.text-danger', + 'Valid': '.fa-check-circle.text-success' + }; + const iconSelector = iconMap[statusTitle]; + cy.get('div[id="section_clarin-license"]') + .find('.card-header') + .find(iconSelector) + .should('be.visible'); }, showErrorMustChooseLicense() { cy.get('div[id = "sectionGenericError_clarin-license"] ds-alert').contains('You must choose one of the resource licenses.');