Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 69 additions & 2 deletions cypress/e2e/submission-ui.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,15 @@ 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,
},
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
Expand All @@ -208,14 +209,15 @@ 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,
},
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
Expand All @@ -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,
Expand Down
12 changes: 11 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down