diff --git a/frontend/cypress/e2e/import/constants/fieldsContent.js b/frontend/cypress/e2e/import/constants/fieldsContent.js index f37b212512..e6ff931b1b 100644 --- a/frontend/cypress/e2e/import/constants/fieldsContent.js +++ b/frontend/cypress/e2e/import/constants/fieldsContent.js @@ -1,9 +1,4 @@ export const FIELDS_CONTENT_STEP_UPLOAD = { - datasetField: { - defaultValue: 'JDD-TEST-IMPORT-ADMIN', - newValue: 'JDD-TEST-IMPORT-2', - selector: 'ng-select', - }, fileUploadField: { defaultValue: 'import/synthese/valid_file_test_link_list_import_synthese.csv', newValue: 'import/synthese/valid_file_import_synthese_test_changed.csv', diff --git a/frontend/cypress/e2e/import/constants/filters.js b/frontend/cypress/e2e/import/constants/filters.js index a3a6f48c41..f827566a15 100644 --- a/frontend/cypress/e2e/import/constants/filters.js +++ b/frontend/cypress/e2e/import/constants/filters.js @@ -1,9 +1,4 @@ export const FILTERS_TABLE = [ - { - columnName: 'Jeu de données', - searchTerm: ['JDD-TEST', 'JDD-TEST-IMPORT-ADMIN', 'JDD-INVALID'], - expectedRowsCount: [4, 1, 0], - }, { columnName: 'Fichier', searchTerm: ['valid_file_test_import', 'invalid_file.csv'], diff --git a/frontend/cypress/e2e/import/constants/selectors.js b/frontend/cypress/e2e/import/constants/selectors.js index 2993fb258a..0839c916f6 100644 --- a/frontend/cypress/e2e/import/constants/selectors.js +++ b/frontend/cypress/e2e/import/constants/selectors.js @@ -48,13 +48,19 @@ export const getSelectorsForStep = (stepName) => { export const SELECTOR_IMPORT_MODAL_DELETE = '[data-qa=import-modal-delete]'; export const SELECTOR_IMPORT_MODAL_DELETE_VALIDATE = '[data-qa=modal-delete-validate]'; + export const SELECTOR_IMPORT_MODAL_DESTINATION_START = '[data-qa=import-modal-destination-start]'; export const SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN = '[data-qa=import-fieldmapping-theme-date_min]'; export const SELECTOR_IMPORT_FIELDMAPPING_OBSERVERS = '[data-qa=import-fieldmapping-theme-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_HAB = '[data-qa=import-fieldmapping-theme-cd_hab]'; 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_DEFAULT_DATASET = + '[data-qa=import-fieldmapping-theme-default-unique_dataset_id] ng-select'; export const SELECTOR_IMPORT_FIELDMAPPING_VALIDATE = '[data-qa=import-new-fieldmapping-model-validate]'; export const SELECTOR_IMPORT_FIELDMAPPING_BUTTON_DELETE = @@ -70,6 +76,8 @@ export const SELECTOR_IMPORT_FIELDMAPPING_SELECTION_RENAME_OK = export const SELECTOR_IMPORT_FIELDMAPPING_SELECTION_RENAME_TEXT = '[data-qa=import-fieldmapping-selection-rename-text]'; export const SELECTOR_IMPORT_FIELDMAPPING_MODAL = '[data-qa=import-fieldmapping-saving-modal]'; +export const SELECTOR_IMPORT_FIELDMAPPING_MODAL_CANCEL = + '[data-qa=import-fieldmapping-saving-modal-cancel]'; export const SELECTOR_IMPORT_FIELDMAPPING_MODAL_CLOSE = '[data-qa=import-fieldmapping-saving-modal-close]'; export const SELECTOR_IMPORT_FIELDMAPPING_MODAL_OK = @@ -88,7 +96,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..56b362a2ae 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 @@ -44,7 +44,7 @@ describe('Tests actions on active/inactive list JDD ', () => { }); JDD_LIST.forEach((jdd_item) => { - it(`should verify actions for ${jdd_item.jdd_name} (${ + it.skip(`should verify actions for ${jdd_item.jdd_name} (${ jdd_item.jdd_is_active ? 'active' : 'inactive' })`, () => { cy.getRowIndexByCellValue( @@ -58,19 +58,18 @@ describe('Tests actions on active/inactive list JDD ', () => { }); }); - it('Should be able to modify a finished import, but still active JDD', () => { + it.skip('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(); cy.backToImportList(); - cy.get(getSelectorImportListTableRowEdit(0)) + cy.get(getSelectorImportListTableRowEdit.skip(0)) .should('exist') .should('be.visible') .should('not.be.disabled'); @@ -80,7 +79,7 @@ describe('Tests actions on active/inactive list JDD ', () => { }); cy.reload(); - cy.get(getSelectorImportListTableRowEdit(0)) + cy.get(getSelectorImportListTableRowEdit.skip(0)) .should('exist') .should('be.visible') .should('be.disabled'); @@ -90,7 +89,7 @@ describe('Tests actions on active/inactive list JDD ', () => { }); cy.reload(); - cy.get(getSelectorImportListTableRowEdit(0)) + cy.get(getSelectorImportListTableRowEdit.skip(0)) .should('exist') .should('be.visible') .should('not.be.disabled'); @@ -104,7 +103,7 @@ describe('Tests actions on active/inactive list JDD ', () => { function verifyEditAction(rowIndex, jdd_item) { const actionStatus = jdd_item.jdd_is_active ? 'not.be.disabled' : 'be.disabled'; - cy.get(getSelectorImportListTableRowEdit(rowIndex)) + cy.get(getSelectorImportListTableRowEdit.skip(rowIndex)) .should('exist') .should('be.visible') .should(actionStatus) diff --git a/frontend/cypress/e2e/import/list-table-refer-to-jdd-spec.js b/frontend/cypress/e2e/import/list-table-refer-to-jdd-spec.js deleted file mode 100644 index f087441105..0000000000 --- a/frontend/cypress/e2e/import/list-table-refer-to-jdd-spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import { USERS } from './constants/users'; -import { TIMEOUT_WAIT, VIEWPORTS } from './constants/common'; -import { SELECTOR_IMPORT_LIST_TABLE } from './constants/selectors'; - -const COLUMN_NAME = 'Jeu de données'; -const JDD_LIST = ['JDD-TEST-IMPORT-ADMIN', 'JDD-TEST-IMPORT-2', 'JDD-TEST-IMPORT-3']; - -// //////////////////////////////////////////////////////////////////////////// -// -// //////////////////////////////////////////////////////////////////////////// - -describe('Test List import - Refer to JDD page', () => { - VIEWPORTS.forEach((viewport) => { - context(`viewport: ${viewport.width}x${viewport.height}`, () => { - const user = USERS[0]; - context(`user: ${user.login.username}`, () => { - beforeEach(() => { - cy.viewport(viewport.width, viewport.height); - cy.geonatureLogin(user.login.username, user.login.password); - cy.visitImport(); - }); - - JDD_LIST.forEach((cellValue) => - it('Should be redirected to page Metada dataset with dataset name: ' + cellValue, () => { - cy.getCellValueByColumnName(SELECTOR_IMPORT_LIST_TABLE, COLUMN_NAME, cellValue).then( - () => { - cy.get('@targetLink').click(); - cy.wait(TIMEOUT_WAIT); - } - ); - cy.location().then((loc) => { - cy.log('Current URL: ' + loc.href); - expect(loc.href).to.include('metadata/dataset_detail/'); - }); - }) - ); - }); - }); - }); -}); 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..581fd22a77 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) => { @@ -103,13 +102,6 @@ describe('Import Process Navigation', () => { cy.get(SELECTOR_NAVIGATION_STEP_DECODE_FILE.back_btn_selector) .should('be.visible') .click(); - // Verify the selected value in the ng-select input - cy.get(FIELDS_CONTENT_STEP_UPLOAD.datasetField.selector).within(() => { - cy.get('.ng-value').should( - 'contain.text', - FIELDS_CONTENT_STEP_UPLOAD.datasetField.defaultValue - ); - }); cy.get(FIELDS_CONTENT_STEP_UPLOAD.fileUploadField.selector).then(($el) => { const expectedValue = $el .text() @@ -119,7 +111,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..035e2acd8e 100644 --- a/frontend/cypress/e2e/import/step3-field-mapping-spec.js +++ b/frontend/cypress/e2e/import/step3-field-mapping-spec.js @@ -7,6 +7,8 @@ import { SELECTOR_IMPORT_FIELDMAPPING_BUTTON_DELETE, SELECTOR_IMPORT_FIELDMAPPING_BUTTON_DELETE_OK, SELECTOR_IMPORT_FIELDMAPPING_CD_NOM, + SELECTOR_IMPORT_FIELDMAPPING_DEFAULT_DATASET, + SELECTOR_IMPORT_FIELDMAPPING_DATASET, SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN, SELECTOR_IMPORT_FIELDMAPPING_MODAL, SELECTOR_IMPORT_FIELDMAPPING_MODAL_CLOSE, @@ -76,25 +78,14 @@ function fillTheFormRaw() { selectField(SELECTOR_IMPORT_FIELDMAPPING_NOM_CITE, 'date_debut'); selectField(SELECTOR_IMPORT_FIELDMAPPING_WKT, 'date_debut'); selectField(SELECTOR_IMPORT_FIELDMAPPING_CD_NOM, 'date_debut'); + selectField(SELECTOR_IMPORT_FIELDMAPPING_DATASET, 'date_debut'); } function fillTheForm() { // Fill in the form with mandatory field cy.get(SELECTOR_IMPORT_FIELDMAPPING_VALIDATE).should('exist'); - selectField(SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN, 'date_debut'); - cy.get(SELECTOR_IMPORT_FIELDMAPPING_VALIDATE).should('exist').should('not.be.enabled'); - - selectField(SELECTOR_IMPORT_FIELDMAPPING_OBSERVERS, 'date_debut'); - cy.get(SELECTOR_IMPORT_FIELDMAPPING_VALIDATE).should('exist').should('not.be.enabled'); - selectField; - selectField(SELECTOR_IMPORT_FIELDMAPPING_NOM_CITE, 'date_debut'); - cy.get(SELECTOR_IMPORT_FIELDMAPPING_VALIDATE).should('exist').should('not.be.enabled'); - - selectField(SELECTOR_IMPORT_FIELDMAPPING_WKT, 'date_debut'); - cy.get(SELECTOR_IMPORT_FIELDMAPPING_VALIDATE).should('exist').should('not.be.enabled'); - - selectField(SELECTOR_IMPORT_FIELDMAPPING_CD_NOM, 'date_debut'); + fillTheFormRaw(); // Every mandatory field is filled: should be able to validate cy.get(SELECTOR_IMPORT_FIELDMAPPING_VALIDATE).should('exist').should('be.enabled').click(); @@ -113,20 +104,19 @@ function fillTheForm() { cy.wait(TIMEOUT_WAIT); } -function runTheProcess(user) { +function runTheProcess() { cy.visitImport(); cy.startImport(); cy.pickDestination(); - cy.pickDataset(user.dataset); cy.loadImportFile(FILES.synthese.valid.fixture); cy.configureImportFile(); } -function restartTheProcess(user) { +function restartTheProcess() { cy.wait(TIMEOUT_WAIT); cy.deleteCurrentImport(); cy.wait(TIMEOUT_WAIT); - runTheProcess(user); + runTheProcess(); } function checkThatMappingCanBeSaved() { @@ -169,10 +159,19 @@ describe('Import - Field mapping step', () => { beforeEach(() => { cy.viewport(VIEWPORT.width, VIEWPORT.height); cy.geonatureLogin(USER_ADMIN.login.username, USER_ADMIN.login.password); - runTheProcess(USER_ADMIN); + runTheProcess(); cy.get('[data-qa="import-new-fieldmapping-form"]').should('exist'); }); + it('Should access jdd only filtered based on permissions ', () => { + cy.get(`${SELECTOR_IMPORT_FIELDMAPPING_DEFAULT_DATASET}`) + .click() + .get('.ng-option') + .should('have.length', 2) + .should('contain', USER_ADMIN.dataset) + .should('contain', USER_AGENT.dataset); + }); + it('Should be able to create a new field mapping, rename it, and delete it', () => { fillTheForm(); restartTheProcess(USER_ADMIN); @@ -253,7 +252,7 @@ describe('Import - Field mapping step', () => { cy.deleteCurrentImport(); cy.geonatureLogout(); cy.geonatureLogin(USER_AGENT.login.username, USER_AGENT.login.password); - runTheProcess(USER_AGENT); + runTheProcess(); // Check that field mapping does not exist cy.get(SELECTOR_IMPORT_FIELDMAPPING_SELECTION) @@ -268,7 +267,7 @@ describe('Import - Field mapping step', () => { cy.deleteCurrentImport(); cy.geonatureLogout(); cy.geonatureLogin(USER_ADMIN.login.username, USER_ADMIN.login.password); - runTheProcess(USER_ADMIN); + runTheProcess(); // Check that field mapping does exist cy.get(SELECTOR_IMPORT_FIELDMAPPING_SELECTION) @@ -289,7 +288,7 @@ describe('Import - Field mapping step', () => { cy.deleteCurrentImport(); cy.geonatureLogout(); cy.geonatureLogin(USER_AGENT.login.username, USER_AGENT.login.password); - runTheProcess(USER_AGENT); + runTheProcess(); // Create a mapping fillTheForm(); @@ -298,7 +297,7 @@ describe('Import - Field mapping step', () => { cy.deleteCurrentImport(); cy.geonatureLogout(); cy.geonatureLogin(USER_ADMIN.login.username, USER_ADMIN.login.password); - runTheProcess(USER_ADMIN); + runTheProcess(); // Check that field mapping does exist cy.get(SELECTOR_IMPORT_FIELDMAPPING_SELECTION) @@ -317,7 +316,7 @@ describe('Import - Field mapping step', () => { it('Should be able to modifiy the default mapping if user got rights. A save to alternative should be offered to the user.', () => { // Mapping Synthese selectMapping(DEFAULT_FIELDMAPPINGS[0]); - selectField(SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN, 'date_fin'); + selectField(SELECTOR_IMPORT_FIELDMAPPING_DATASET, 'date_fin'); checkThatMappingCanBeSaved(); restartTheProcess(USER_ADMIN); @@ -328,9 +327,9 @@ describe('Import - Field mapping step', () => { it('Should not be able to modifiy the default mapping if user does not got rights', () => { cy.geonatureLogout(); cy.geonatureLogin(USER_AGENT.login.username, USER_AGENT.login.password); - runTheProcess(USER_AGENT); + runTheProcess(); selectMapping(DEFAULT_FIELDMAPPINGS[0]); - selectField(SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN, 'date_fin'); + selectField(SELECTOR_IMPORT_FIELDMAPPING_DATASET, 'date_fin'); checkThatMappingCanNotBeSaved(); }); diff --git a/frontend/cypress/e2e/import/step4-content-mapping-spec.js b/frontend/cypress/e2e/import/step4-content-mapping-spec.js index 352dc0ae82..28ff53fb9b 100644 --- a/frontend/cypress/e2e/import/step4-content-mapping-spec.js +++ b/frontend/cypress/e2e/import/step4-content-mapping-spec.js @@ -19,6 +19,16 @@ import { SELECTOR_IMPORT_CONTENTMAPPING_SELECTION_TEXT, SELECTOR_IMPORT_CONTENTMAPPING_VALIDATE, SELECTOR_IMPORT_NEW_VERIFICATION_START, + SELECTOR_IMPORT_FIELDMAPPING_DEFAULT_DATASET, + SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN, + SELECTOR_IMPORT_FIELDMAPPING_WKT, + SELECTOR_IMPORT_FIELDMAPPING_NOM_CITE, + SELECTOR_IMPORT_FIELDMAPPING_CD_HAB, + SELECTOR_IMPORT_FIELDMAPPING_VALIDATE, + SELECTOR_IMPORT_FIELDMAPPING_MODAL_CLOSE, + SELECTOR_IMPORT_FIELDMAPPING_MODAL_NAME, + SELECTOR_IMPORT_FIELDMAPPING_MODAL_NEW_OK, + SELECTOR_IMPORT_FIELDMAPPING_MODAL_OK, } from './constants/selectors'; // //////////////////////////////////////////////////////////////////////////// @@ -114,28 +124,27 @@ 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(); - selectFieldMappingField('import-fieldmapping-theme-date_min', 'error'); - selectFieldMappingField('import-fieldmapping-theme-WKT', 'error'); + // cy.configureImportFieldMapping(user.dataset); + selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN, 'error'); + selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_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(SELECTOR_IMPORT_FIELDMAPPING_NOM_CITE, 'error'); + selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_CD_HAB, 'error'); + selectFieldMappingField(SELECTOR_IMPORT_FIELDMAPPING_DEFAULT_DATASET, 'error'); - cy.get('[data-qa="import-new-fieldmapping-model-validate"]').click(); - cy.get('[data-qa="import-fieldmapping-saving-modal-cancel"]', { force: true }).click(); + cy.get(SELECTOR_IMPORT_FIELDMAPPING_VALIDATE).click(); + cy.get(SELECTOR_IMPORT_FIELDMAPPING_MODAL_CANCEL, { force: true }).click(); } function restartTheProcess(user) { 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..88baae4974 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,9 +12,24 @@ Cypress.Commands.add('configureImportFieldMapping', () => { cy.wrap(v).should('exist').click(); }); + cy.get('[data-qa="import-fieldmapping-theme-default-unique_dataset_id"] ng-select') + .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') .should('be.enabled') .click(); + + cy.get('[data-qa="import-fieldmapping-saving-modal-cancel"]') + .should('exist') + .should('be.enabled') + .click(); }); 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(); - }); -}); diff --git a/frontend/src/app/GN2CommonModule/form/dynamic-form/dynamic-form.component.html b/frontend/src/app/GN2CommonModule/form/dynamic-form/dynamic-form.component.html index cc661a40e9..6cac2ecb1b 100644 --- a/frontend/src/app/GN2CommonModule/form/dynamic-form/dynamic-form.component.html +++ b/frontend/src/app/GN2CommonModule/form/dynamic-form/dynamic-form.component.html @@ -11,7 +11,7 @@ 'number', 'file', 'medias', - 'bool_radio', + 'bool_radio' ].includes(formDefComp['type_widget']) " > diff --git a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/mapping-theme/mapping-theme.component.html b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/mapping-theme/mapping-theme.component.html index a1ec086102..399467f20b 100644 --- a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/mapping-theme/mapping-theme.component.html +++ b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/mapping-theme/mapping-theme.component.html @@ -91,6 +91,7 @@ class="d-block mt-2" [formDef]="defaultValueFormDefs[field.name_field]" [form]="_fm.mappingFormGroup" + [attr.data-qa]="'import-fieldmapping-theme-default-' + field.name_field" >