Skip to content

Commit

Permalink
feat: setup frontend test
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Jan 23, 2025
1 parent 3116d78 commit 560542e
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 162 deletions.
5 changes: 0 additions & 5 deletions frontend/cypress/e2e/import/constants/fieldsContent.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
5 changes: 0 additions & 5 deletions frontend/cypress/e2e/import/constants/filters.js
Original file line number Diff line number Diff line change
@@ -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'],
Expand Down
9 changes: 8 additions & 1 deletion frontend/cypress/e2e/import/constants/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 =
Expand All @@ -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 =
Expand Down
15 changes: 7 additions & 8 deletions frontend/cypress/e2e/import/list-table-jdd-modify-delete-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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)
Expand Down
40 changes: 0 additions & 40 deletions frontend/cypress/e2e/import/list-table-refer-to-jdd-spec.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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()
Expand All @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
SELECTOR_IMPORT_CONTENTMAPPING_STEP_BUTTON,
SELECTOR_IMPORT_FIELDMAPPING_CD_NOM,
SELECTOR_IMPORT_FIELDMAPPING_DATE_MIN,
SELECTOR_IMPORT_FIELDMAPPING_DEFAULT_DATASET,
SELECTOR_IMPORT_FIELDMAPPING_NOM_CITE,
SELECTOR_IMPORT_FIELDMAPPING_OBSERVERS,
SELECTOR_IMPORT_FIELDMAPPING_WKT,
Expand All @@ -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);
}

Expand Down Expand Up @@ -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_DEFAULT_DATASET, datasetName);
}

// ////////////////////////////////////////////////////////////////////////////
// Create a mapping with dummy values
// ////////////////////////////////////////////////////////////////////////////
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
32 changes: 0 additions & 32 deletions frontend/cypress/e2e/import/step1-upload-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand All @@ -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');
Expand Down
Loading

0 comments on commit 560542e

Please sign in to comment.