diff --git a/frontend/cypress/e2e/import/constants/selectors.js b/frontend/cypress/e2e/import/constants/selectors.js index 2993fb258a..f58a23a071 100644 --- a/frontend/cypress/e2e/import/constants/selectors.js +++ b/frontend/cypress/e2e/import/constants/selectors.js @@ -55,6 +55,8 @@ export const SELECTOR_IMPORT_FIELDMAPPING_OBSERVERS = export const SELECTOR_IMPORT_FIELDMAPPING_NOM_CITE = '[data-qa=import-fieldmapping-theme-nom_cite]'; export const SELECTOR_IMPORT_FIELDMAPPING_WKT = '[data-qa=import-fieldmapping-theme-WKT]'; export const SELECTOR_IMPORT_FIELDMAPPING_CD_NOM = '[data-qa=import-fieldmapping-theme-cd_nom]'; +export const SELECTOR_IMPORT_FIELDMAPPING_DATASET = + '[data-qa=import-fieldmapping-theme-unique_dataset_id]'; export const SELECTOR_IMPORT_FIELDMAPPING_VALIDATE = '[data-qa=import-new-fieldmapping-model-validate]'; export const SELECTOR_IMPORT_FIELDMAPPING_BUTTON_DELETE = @@ -88,7 +90,6 @@ export const SELECTOR_IMPORT_LIST_TOOLBAR_DESTINATIONS = export const SELECTOR_IMPORT_LIST_TOOLBAR_SEARCH = '[data-qa=import-list-toolbar-search]'; export const SELECTOR_DESTINATIONS = '[data-qa=destinations]'; export const SELECTOR_IMPORT = '[data-qa=gn-sidenav-link-IMPORT]'; -export const SELECTOR_IMPORT_UPLOAD_DATASET = '[data-qa=import-new-upload-datasets]'; export const SELECTOR_IMPORT_UPLOAD_FILE = '[data-qa=import-new-upload-file]'; export const SELECTOR_IMPORT_UPLOAD_VALIDATE = '[data-qa=import-new-upload-validate]'; export const SELECTOR_IMPORT_CONTENTMAPPING_STEP_BUTTON = diff --git a/frontend/cypress/e2e/import/list-table-jdd-modify-delete-spec.js b/frontend/cypress/e2e/import/list-table-jdd-modify-delete-spec.js index 4c26312171..5855766a99 100644 --- a/frontend/cypress/e2e/import/list-table-jdd-modify-delete-spec.js +++ b/frontend/cypress/e2e/import/list-table-jdd-modify-delete-spec.js @@ -61,10 +61,9 @@ describe('Tests actions on active/inactive list JDD ', () => { it('Should be able to modify a finished import, but still active JDD', () => { cy.startImport(); cy.pickDestination(); - cy.pickDataset(user.dataset); cy.loadImportFile(FILES.synthese.valid.fixture); cy.configureImportFile(); - cy.configureImportFieldMapping(); + cy.configureImportFieldMapping(user.dataset); cy.configureImportContentMapping(); cy.verifyImport(); cy.executeImport(); diff --git a/frontend/cypress/e2e/import/navigation-check-back-each-steps-spec.js b/frontend/cypress/e2e/import/navigation-check-back-each-steps-spec.js index 880fcfd40f..baaae9cb85 100644 --- a/frontend/cypress/e2e/import/navigation-check-back-each-steps-spec.js +++ b/frontend/cypress/e2e/import/navigation-check-back-each-steps-spec.js @@ -69,7 +69,6 @@ describe('Import Process Navigation', () => { cy.pickDestination(DESTINATION); // STEP 1 - UPLOAD - cy.pickDataset(FIELDS_CONTENT_STEP_UPLOAD.datasetField.defaultValue); cy.loadImportFile(FIELDS_CONTENT_STEP_UPLOAD.fileUploadField.defaultValue); cy.wait(TIMEOUT_WAIT); cy.url().then((url) => { @@ -119,7 +118,6 @@ describe('Import Process Navigation', () => { expect(defaultValue).to.include(expectedValue); }); // Change values in upload step - cy.pickDataset(FIELDS_CONTENT_STEP_UPLOAD.datasetField.newValue); cy.loadImportFile(FIELDS_CONTENT_STEP_UPLOAD.fileUploadField.newValue); cy.get(SELECTOR_NAVIGATION_STEP_DECODE_FILE.back_btn_selector) .should('be.visible') diff --git a/frontend/cypress/e2e/import/navigation-mappings-cancel-save-spec.js b/frontend/cypress/e2e/import/navigation-mappings-cancel-save-spec.js index 003cffe2b4..7165732fd5 100644 --- a/frontend/cypress/e2e/import/navigation-mappings-cancel-save-spec.js +++ b/frontend/cypress/e2e/import/navigation-mappings-cancel-save-spec.js @@ -6,6 +6,7 @@ import { getSelectorImportListTableRowId, SELECTOR_IMPORT_CONTENTMAPPING_STEP_BUTTON, SELECTOR_IMPORT_FIELDMAPPING_CD_NOM, + SELECTOR_IMPORT_FIELDMAPPING_DATASET, SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN, SELECTOR_IMPORT_FIELDMAPPING_NOM_CITE, SELECTOR_IMPORT_FIELDMAPPING_OBSERVERS, @@ -22,14 +23,13 @@ function runTheProcessUntilFieldMapping(user) { cy.visitImport(); cy.startImport(); cy.pickDestination(); - cy.pickDataset(user.dataset); cy.loadImportFile(FILES.synthese.valid.fixture); cy.configureImportFile(); } function runTheProcessUntilContentMapping(user) { runTheProcessUntilFieldMapping(user); - cy.configureImportFieldMapping(); + cy.configureImportFieldMapping(user.dataset); cy.wait(500); } @@ -67,14 +67,14 @@ function selectContentMappingField(dataQa, value) { cy.get(`[data-qa=import-contentmapping-theme-${dataQa}]`).should('exist').select(value); } -function fillTheFieldMappingFormRaw() { +function fillTheFieldMappingFormRaw(datasetName) { selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN, 'date_debut'); selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_OBSERVERS, 'date_debut'); selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_NOM_CITE, 'date_debut'); selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_WKT, 'date_debut'); selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_CD_NOM, 'date_debut'); + selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_DATASET, datasetName); } - // //////////////////////////////////////////////////////////////////////////// // Create a mapping with dummy values // //////////////////////////////////////////////////////////////////////////// @@ -97,7 +97,7 @@ describe('Navigation - cancel and save', () => { const parts = url.split('/'); const importID = parts[parts.length - 2]; // Get the penultimate element - fillTheFieldMappingFormRaw(); + fillTheFieldMappingFormRaw(user.dataset); cy.get(SELECTOR_IMPORT_FOOTER_DELETE).should('be.enabled').click(); cy.wait(TIMEOUT_WAIT); cy.checkCurrentPageIsImport(); @@ -112,7 +112,7 @@ describe('Navigation - cancel and save', () => { const parts = url.split('/'); const importID = parts[parts.length - 2]; // Get the penultimate element - fillTheFieldMappingFormRaw(); + fillTheFieldMappingFormRaw(user.dataset); cy.visitImport(); checkImportIsFirstInList(importID); clickOnFirstLineEdit(); @@ -133,7 +133,7 @@ describe('Navigation - cancel and save', () => { // Extract the ID using string manipulation const parts = url.split('/'); const importID = parts[parts.length - 2]; // Get the penultimate element - fillTheFieldMappingFormRaw(); + fillTheFieldMappingFormRaw(user.dataset); cy.get(SELECTOR_IMPORT_FOOTER_SAVE).should('be.enabled').click(); checkImportIsFirstInList(importID); clickOnFirstLineEdit(); diff --git a/frontend/cypress/e2e/import/propcess-import-in-synthese-spec.js b/frontend/cypress/e2e/import/propcess-import-in-synthese-spec.js index c1e2f5d20b..b3cfea90b1 100644 --- a/frontend/cypress/e2e/import/propcess-import-in-synthese-spec.js +++ b/frontend/cypress/e2e/import/propcess-import-in-synthese-spec.js @@ -23,10 +23,9 @@ describe('Import - create a new import', () => { it('Should be able to import a valid-file in synthese', () => { cy.startImport(); cy.pickDestination(); - cy.pickDataset(USER.dataset); cy.loadImportFile(FILES.synthese.valid.fixture); cy.configureImportFile(); - cy.configureImportFieldMapping(); + cy.configureImportFieldMapping(USER.dataset); cy.configureImportContentMapping(); cy.verifyImport(); cy.executeImport(); diff --git a/frontend/cypress/e2e/import/step1-upload-spec.js b/frontend/cypress/e2e/import/step1-upload-spec.js index b2ec1e5aac..e22d9a7f2f 100644 --- a/frontend/cypress/e2e/import/step1-upload-spec.js +++ b/frontend/cypress/e2e/import/step1-upload-spec.js @@ -2,7 +2,6 @@ import { USERS } from './constants/users'; import { VIEWPORTS } from './constants/common'; import { FILES } from './constants/files'; import { - SELECTOR_IMPORT_UPLOAD_DATASET, SELECTOR_IMPORT_UPLOAD_FILE, SELECTOR_IMPORT_UPLOAD_VALIDATE, } from './constants/selectors'; @@ -29,38 +28,8 @@ describe('Import - Upload step', () => { cy.get(SELECTOR_IMPORT_UPLOAD_VALIDATE).should('exist').should('be.disabled'); }); - it('Should be able to select a jdd', () => { - cy.pickDataset(USER.dataset); - cy.get(`${SELECTOR_IMPORT_UPLOAD_DATASET} > ng-select`) - .should('have.class', 'ng-valid') - .find('.ng-value-label') - .should('exist') - .should('contains.text', USER.dataset); - - cy.get(SELECTOR_IMPORT_UPLOAD_DATASET).find('.ng-clear-wrapper').should('exist').click(); - - cy.get(`${SELECTOR_IMPORT_UPLOAD_DATASET} > ng-select`).should('have.class', 'ng-invalid'); - - cy.pickDataset(USER.dataset); - - cy.get(`${SELECTOR_IMPORT_UPLOAD_DATASET} > ng-select`) - .should('have.class', 'ng-valid') - .find('.ng-value-label') - .should('exist') - .should('contains.text', USER.dataset); - }); - - it('Should access jdd only filtered based on permissions ', () => { - cy.get(`${SELECTOR_IMPORT_UPLOAD_DATASET} > ng-select`) - .click() - .get('.ng-option') - .should('have.length', 1) - .should('contain', USER.dataset); - }); - it('Should throw error if file is empty', () => { // required to trigger file validation - cy.pickDataset(USER.dataset); const file = FILES.synthese.empty; cy.get(file.formErrorElement).should('not.exist'); cy.loadImportFile(file.fixture); @@ -70,7 +39,6 @@ describe('Import - Upload step', () => { it('Should throw error if csv is not valid', () => { // required to trigger file validation - cy.pickDataset(USER.dataset); const file = FILES.synthese.bad; cy.get(file.formErrorElement).should('not.exist'); cy.fixture(file.fixture, null).as('import_file'); diff --git a/frontend/cypress/e2e/import/step3-field-mapping-spec.js b/frontend/cypress/e2e/import/step3-field-mapping-spec.js index 79317eb885..ce557fa422 100644 --- a/frontend/cypress/e2e/import/step3-field-mapping-spec.js +++ b/frontend/cypress/e2e/import/step3-field-mapping-spec.js @@ -7,6 +7,7 @@ import { SELECTOR_IMPORT_FIELDMAPPING_BUTTON_DELETE, SELECTOR_IMPORT_FIELDMAPPING_BUTTON_DELETE_OK, SELECTOR_IMPORT_FIELDMAPPING_CD_NOM, + SELECTOR_IMPORT_FIELDMAPPING_DATASET, SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN, SELECTOR_IMPORT_FIELDMAPPING_MODAL, SELECTOR_IMPORT_FIELDMAPPING_MODAL_CLOSE, @@ -66,6 +67,18 @@ function deleteCurrentMapping() { cy.wait(TIMEOUT_WAIT); } +function pickDataset(datasetName) { + cy.get(SELECTOR_IMPORT_FIELDMAPPING_DATASET) + .should('exist') + .click() + .get('ng-dropdown-panel') + .get('.ng-option') + .contains(datasetName) + .then((dataset) => { + cy.wrap(dataset).should('exist').click(); + }); +} + // //////////////////////////////////////////////////////////////////////////// // Create a mapping with dummy values // //////////////////////////////////////////////////////////////////////////// @@ -96,6 +109,8 @@ function fillTheForm() { selectField(SELECTOR_IMPORT_FIELDMAPPING_CD_NOM, 'date_debut'); + pickDataset(user.dataset); + // Every mandatory field is filled: should be able to validate cy.get(SELECTOR_IMPORT_FIELDMAPPING_VALIDATE).should('exist').should('be.enabled').click(); @@ -117,7 +132,6 @@ function runTheProcess(user) { cy.visitImport(); cy.startImport(); cy.pickDestination(); - cy.pickDataset(user.dataset); cy.loadImportFile(FILES.synthese.valid.fixture); cy.configureImportFile(); } @@ -173,6 +187,14 @@ describe('Import - Field mapping step', () => { cy.get('[data-qa="import-new-fieldmapping-form"]').should('exist'); }); + it('Should access jdd only filtered based on permissions ', () => { + cy.get(`${SELECTOR_IMPORT_UPLOAD_DATASET} > ng-select`) + .click() + .get('.ng-option') + .should('have.length', 1) + .should('contain', USER.dataset); + }); + it('Should be able to create a new field mapping, rename it, and delete it', () => { fillTheForm(); restartTheProcess(USER_ADMIN); diff --git a/frontend/cypress/e2e/import/step4-content-mapping-spec.js b/frontend/cypress/e2e/import/step4-content-mapping-spec.js index 352dc0ae82..8b032a09a6 100644 --- a/frontend/cypress/e2e/import/step4-content-mapping-spec.js +++ b/frontend/cypress/e2e/import/step4-content-mapping-spec.js @@ -114,25 +114,24 @@ function runTheProcess(user) { cy.visitImport(); cy.startImport(); cy.pickDestination(); - cy.pickDataset(user.dataset); cy.loadImportFile(FILES.synthese.valid.fixture); cy.configureImportFile(); - cy.configureImportFieldMapping(); + cy.configureImportFieldMapping(user.dataset); } function runTheProcessForOcchab(user) { cy.visitImport(); cy.startImport(); cy.pickDestination('Occhab'); - cy.pickDataset(user.dataset); cy.loadImportFile(FILES.synthese.valid.fixture); cy.configureImportFile(); - // cy.configureImportFieldMapping(); + // cy.configureImportFieldMapping(user.dataset); selectFieldMappingField('import-fieldmapping-theme-date_min', 'error'); selectFieldMappingField('import-fieldmapping-theme-WKT', 'error'); cy.get('#mat-tab-label-0-1').click(); selectFieldMappingField('import-fieldmapping-theme-nom_cite', 'error'); selectFieldMappingField('import-fieldmapping-theme-cd_hab', 'error'); + selectFieldMappingField('import-fieldmapping-theme-unique_dataset_id', 'error'); cy.get('[data-qa="import-new-fieldmapping-model-validate"]').click(); cy.get('[data-qa="import-fieldmapping-saving-modal-cancel"]', { force: true }).click(); diff --git a/frontend/cypress/e2e/import/step5-recaptiulatif-spec.js b/frontend/cypress/e2e/import/step5-recaptiulatif-spec.js index 1ff9303e8e..999bacae31 100644 --- a/frontend/cypress/e2e/import/step5-recaptiulatif-spec.js +++ b/frontend/cypress/e2e/import/step5-recaptiulatif-spec.js @@ -17,10 +17,9 @@ function runTheProcess(user) { cy.visitImport(); cy.startImport(); cy.pickDestination(); - cy.pickDataset(user.dataset); cy.loadImportFile(FILES.synthese.valid.fixture); cy.configureImportFile(); - cy.configureImportFieldMapping(); + cy.configureImportFieldMapping(user.dataset); cy.configureImportContentMapping(); cy.triggerImportVerification(); } diff --git a/frontend/cypress/e2e/import/step6-report-spec.js b/frontend/cypress/e2e/import/step6-report-spec.js index 47c056db9a..0fd870d3d7 100644 --- a/frontend/cypress/e2e/import/step6-report-spec.js +++ b/frontend/cypress/e2e/import/step6-report-spec.js @@ -23,10 +23,9 @@ function runTheProcess(user) { cy.visitImport(); cy.startImport(); cy.pickDestination(); - cy.pickDataset(user.dataset); cy.loadImportFile(FILES.synthese.valid.fixture); cy.configureImportFile(); - cy.configureImportFieldMapping(); + cy.configureImportFieldMapping(user.dataset); cy.configureImportContentMapping(); cy.triggerImportVerification(); cy.executeImport(); diff --git a/frontend/cypress/support/import/configureImportFieldMapping.js b/frontend/cypress/support/import/configureImportFieldMapping.js index 53335b251a..b5d09cf250 100644 --- a/frontend/cypress/support/import/configureImportFieldMapping.js +++ b/frontend/cypress/support/import/configureImportFieldMapping.js @@ -1,6 +1,7 @@ const DEFAULT_MAPPING = 'Synthese GeoNature'; +const DEFAULT_DATASET = ''; -Cypress.Commands.add('configureImportFieldMapping', () => { +Cypress.Commands.add('configureImportFieldMapping', (datasetName) => { cy.get('[data-qa="import-fieldmapping-selection-select"]') .should('exist') .click() @@ -11,6 +12,16 @@ Cypress.Commands.add('configureImportFieldMapping', () => { cy.wrap(v).should('exist').click(); }); + cy.get('[data-qa="import-fieldmapping-theme-unique_dataset_id"]') + .should('exist') + .click() + .get('ng-dropdown-panel') + .get('.ng-option') + .contains(datasetName) + .then((dataset) => { + cy.wrap(dataset).should('exist').click(); + }); + // Every mandatory field is filled: should be able to validate cy.get('[data-qa="import-new-fieldmapping-model-validate"]') .should('exist') diff --git a/frontend/cypress/support/import/index.js b/frontend/cypress/support/import/index.js index aac0a74e1e..867cf09f00 100644 --- a/frontend/cypress/support/import/index.js +++ b/frontend/cypress/support/import/index.js @@ -17,7 +17,6 @@ import './getGlobalConfig'; import './getRowIndexByCellValue'; import './hasToastError'; import './loadImportFile'; -import './pickDataset'; import './pickDestination'; import './removeFirstImportInList'; import './startImport'; diff --git a/frontend/cypress/support/import/pickDataset.js b/frontend/cypress/support/import/pickDataset.js deleted file mode 100644 index 33ac7265a2..0000000000 --- a/frontend/cypress/support/import/pickDataset.js +++ /dev/null @@ -1,11 +0,0 @@ -Cypress.Commands.add('pickDataset', (datasetName) => { - cy.get('[data-qa="import-new-upload-datasets"]') - .should('exist') - .click() - .get('ng-dropdown-panel') - .get('.ng-option') - .contains(datasetName) - .then((dataset) => { - cy.wrap(dataset).should('exist').click(); - }); -});