diff --git a/frontend/config/cypress.config.ts b/frontend/config/cypress.config.ts index da2a093615..131dfd9c3a 100644 --- a/frontend/config/cypress.config.ts +++ b/frontend/config/cypress.config.ts @@ -19,15 +19,7 @@ export default defineConfig({ initCypressMousePositionPlugin(on) initPlugin(on, config) }, - specPattern: [ - 'cypress/e2e/00_side_window_missions.spec.ts', - 'cypress/e2e/01_side_window_mission.spec.ts', - 'cypress/e2e/02_side_window_mission_actions.spec.ts', - 'cypress/e2e/03_side_window_missions_navigation.spec.ts', - 'cypress/e2e/05_side_window_reportings.spec.ts', - // 'cypress/e2e/04_create_reporting.spec.ts', - 'cypress/e2e/**/*.spec.ts' - ] + specPattern: ['cypress/e2e/**/*.spec.ts'] }, env: { 'cypress-plugin-snapshots': { diff --git a/frontend/cypress/e2e/04_map_create_reporting.spec.ts b/frontend/cypress/e2e/main_window/reporting/create_reporting.spec.ts similarity index 94% rename from frontend/cypress/e2e/04_map_create_reporting.spec.ts rename to frontend/cypress/e2e/main_window/reporting/create_reporting.spec.ts index 2951ab7bfe..719975c63f 100644 --- a/frontend/cypress/e2e/04_map_create_reporting.spec.ts +++ b/frontend/cypress/e2e/main_window/reporting/create_reporting.spec.ts @@ -1,4 +1,4 @@ -import { FAKE_API_PUT_RESPONSE, FAKE_MAPBOX_RESPONSE } from './constants' +import { FAKE_API_PUT_RESPONSE, FAKE_MAPBOX_RESPONSE } from '../../constants' context('Reporting', () => { beforeEach(() => { diff --git a/frontend/cypress/e2e/side_window/mission/close_mission_validation.spec.ts b/frontend/cypress/e2e/side_window/mission/close_mission_validation.spec.ts new file mode 100644 index 0000000000..ae80b5d388 --- /dev/null +++ b/frontend/cypress/e2e/side_window/mission/close_mission_validation.spec.ts @@ -0,0 +1,92 @@ +context('Mission', () => { + beforeEach(() => { + cy.viewport(1280, 1024) + cy.visit(`/side_window`) + }) + + it('A new mission with control and surveillance can be closed with all required values', () => { + // Given + cy.get('*[data-cy="add-mission"]').click() + cy.clickButton(' Enregistrer et clôturer') + cy.wait(100) + + cy.get('*[data-cy="mission-errors"]').should('exist') + cy.contains('Date de fin requise').should('exist') + cy.contains('Type de mission').should('exist') + cy.contains('Administration requise').should('exist') + cy.contains('Unité requise').should('exist') + cy.contains("Trigramme d'ouverture requis").should('exist') + cy.contains('Trigramme de clôture requis').should('exist') + + // we fill all the required inputs + cy.fill('Début de mission (UTC)', [2023, 10, 11, 7, 35]) + cy.fill('Fin de mission (UTC)', [2023, 10, 12, 7, 35]) + cy.fill('Type de mission', ['Air']) + cy.get('*[data-cy="add-control-unit"]').click() + cy.get('.rs-picker-search-bar-input').type('Cross{enter}') + cy.fill('Ouvert par', 'PCF').scrollIntoView() + cy.fill('Clôturé par', 'PCF').scrollIntoView() + + cy.get('*[data-cy="mission-errors"]').should('not.exist') + + // we add a control + cy.clickButton('Ajouter') + cy.clickButton('Ajouter des contrôles') + cy.clickButton(' Enregistrer et clôturer') + cy.wait(100) + + cy.get('*[data-cy="mission-errors"]').should('exist') + cy.contains('Thème requis').should('exist') + cy.contains('Sous-thématique requise').should('exist') + cy.contains('Date requise').should('exist') + // can't test this one because there is map interaction + // cy.contains('Point de contrôle requis').should('exist') + + // we fill all the required inputs + cy.fill('Thématique de contrôle', 'Police des espèces protégées') + + // TODO understand why `cy.fill` doesn't work here + cy.get('*[data-cy="envaction-subtheme-selector"]').click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').contains("Perturbation d'animaux").click({ force: true }) + cy.get('*[data-cy="envaction-subtheme-selector"]').click('topLeft', { force: true }) + cy.fill('Date et heure du contrôle (UTC)', [2023, 10, 11, 12, 12]) + + cy.get('*[data-cy="point-picker-coordinates"]').should('not.exist') + cy.fill('Nombre total de contrôles', '2') + cy.fill('Type de cible', 'Personne morale') + + // we add an infraction + cy.clickButton('+ Ajouter un contrôle avec infraction') + cy.fill("Type d'infraction", 'Avec PV') + cy.fill('Mise en demeure', 'Oui') + cy.fill('NATINF', ["1508 - Execution d'un travail dissimule"]) + + cy.get('*[data-cy="mission-errors"]').should('not.exist') + + // we add a surveillance + cy.clickButton('Ajouter') + cy.clickButton('Ajouter une surveillance') + cy.clickButton(' Enregistrer et clôturer') + cy.wait(100) + + cy.get('*[data-cy="mission-errors"]').should('exist') + + cy.fill('Thématique de surveillance', 'Rejets illicites') + // TODO understand why `cy.fill` doesn't work here + cy.get('*[data-cy="envaction-subtheme-selector"]').click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').contains('Jet de déchet').click({ force: true }) + cy.get('*[data-cy="envaction-subtheme-selector"]').click('topLeft', { force: true }) + + cy.getDataCy('surveillance-zone-matches-mission').should('have.class', 'rs-checkbox-checked') + cy.get('*[data-cy="mission-errors"]').should('not.exist') + + // Then + cy.intercept('PUT', '/bff/v1/missions').as('createAndCloseMission') + cy.clickButton('Enregistrer et clôturer') + cy.wait(100) + + cy.wait('@createAndCloseMission').then(({ response }) => { + expect(response && response.statusCode).equal(200) + }) + }) +}) diff --git a/frontend/cypress/e2e/01_side_window_mission.spec.ts b/frontend/cypress/e2e/side_window/mission/create_mission.spec.ts similarity index 100% rename from frontend/cypress/e2e/01_side_window_mission.spec.ts rename to frontend/cypress/e2e/side_window/mission/create_mission.spec.ts diff --git a/frontend/cypress/e2e/side_window/mission/mission_actions.spec.ts b/frontend/cypress/e2e/side_window/mission/mission_actions.spec.ts new file mode 100644 index 0000000000..34ba079c7b --- /dev/null +++ b/frontend/cypress/e2e/side_window/mission/mission_actions.spec.ts @@ -0,0 +1,163 @@ +/// + +context('Mission actions', () => { + beforeEach(() => { + cy.viewport(1280, 1024) + cy.visit(`/side_window`) + }) + + it('An infraction Should be duplicated', () => { + // Given + cy.get('*[data-cy="edit-mission-34"]').click({ force: true }) + cy.get('*[data-cy="action-card"]').eq(1).click() + cy.get('*[data-cy="control-form-number-controls"]').type('{backspace}2') + cy.get('*[data-cy="infraction-form"]').should('not.exist') + + // When + cy.get('*[data-cy="duplicate-infraction"]').click({ force: true }) + cy.get('*[data-cy="infraction-form-registrationNumber"]').should('have.value', 'BALTIK') + cy.get('*[data-cy="infraction-form-validate"]').click({ force: true }) + cy.get('*[data-cy="duplicate-infraction"]').eq(1).should('be.disabled') + + cy.intercept('PUT', `/bff/v1/missions/34`).as('updateMission') + cy.get('form').submit() + + // Then + cy.wait('@updateMission').then(({ request, response }) => { + expect(response && response.statusCode).equal(200) + const { infractions } = request.body.envActions.find(a => a.id === 'c52c6f20-e495-4b29-b3df-d7edfb67fdd7') + expect(infractions.length).equal(2) + const duplicatedInfraction = infractions[1] + + expect(duplicatedInfraction.controlledPersonIdentity).equal('John Doe') + expect(duplicatedInfraction.formalNotice).equal('PENDING') + expect(duplicatedInfraction.infractionType).equal('WITH_REPORT') + expect(duplicatedInfraction.natinf.length).equal(2) + expect(duplicatedInfraction.observations).equal("Pas d'observations") + expect(duplicatedInfraction.registrationNumber).equal('BALTIK') + expect(duplicatedInfraction.relevantCourt).equal('LOCAL_COURT') + expect(duplicatedInfraction.toProcess).equal(false) + expect(duplicatedInfraction.vesselSize).equal('FROM_24_TO_46m') + expect(duplicatedInfraction.vesselType).equal('COMMERCIAL') + expect(duplicatedInfraction.id).not.equal('c52c6f20-e495-4b29-b3df-d7edfb67fdd7') + }) + }) + + it('allow only one theme and may be multiple subthemes in control actions', () => { + // Given + cy.get('*[data-cy="edit-mission-34"]').click({ force: true }) + cy.get('*[data-cy="action-card"]').eq(1).click() + cy.get('*[data-cy="envaction-theme-element"]').should('have.length', 1) + cy.get('*[data-cy="envaction-theme-selector"]').contains('Police des mouillages') + cy.get('*[data-cy="envaction-theme-element"]').contains('Mouillage individuel') + cy.get('*[data-cy="envaction-theme-element"]').contains('ZMEL') + cy.get('*[data-cy="envaction-protected-species-selector"]').should('not.exist') + // When + cy.get('*[data-cy="envaction-theme-selector"]').click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').contains('Police des espèces protégées').click() + + cy.get('*[data-cy="envaction-subtheme-selector"]').click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').contains('Perturbation').click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').contains('Atteinte aux habitats').click({ force: true }) + cy.get('*[data-cy="envaction-subtheme-selector"]').click({ force: true }) + + cy.get('*[data-cy="envaction-protected-species-selector"]').should('exist') + cy.get('*[data-cy="envaction-protected-species-selector"]').click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').contains('Habitat').click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').contains('Oiseaux').click({ force: true }) + cy.get('*[data-cy="envaction-protected-species-selector"]').click({ force: true }) + + cy.get('*[data-cy="envaction-add-theme"]').should('not.exist') + + cy.intercept('PUT', `/bff/v1/missions/34`).as('updateMission') + cy.get('form').submit() + + // Then + cy.wait('@updateMission').then(({ request, response }) => { + expect(response && response.statusCode).equal(200) + + const { themes } = request.body.envActions.find(a => a.id === 'c52c6f20-e495-4b29-b3df-d7edfb67fdd7') + expect(themes.length).equal(1) + expect(themes[0].theme).equal('Police des espèces protégées et de leurs habitats (faune et flore)') + expect(themes[0].subThemes.length).equal(2) + expect(themes[0].subThemes[0]).equal("Perturbation d'animaux") + expect(themes[0].subThemes[1]).equal("Atteinte aux habitats d'espèces protégées") + expect(themes[0].protectedSpecies.length).equal(2) + expect(themes[0].protectedSpecies[0]).equal('HABITAT') + expect(themes[0].protectedSpecies[1]).equal('BIRDS') + }) + }) + + it('save observations in control Actions', () => { + // Given + cy.get('*[data-cy="edit-mission-34"]').click({ force: true }) + cy.get('*[data-cy="action-card"]').eq(1).click() + cy.get('[id="envActions[1].observations"]').contains('RAS') + + // When + cy.get('[id="envActions[1].observations"]').type('{backspace}{backspace}Une observation importante', { + force: true + }) + + cy.intercept('PUT', `/bff/v1/missions/34`).as('updateMission') + cy.get('form').submit() + + // Then + cy.wait('@updateMission').then(({ request, response }) => { + expect(response && response.statusCode).equal(200) + + const { observations } = request.body.envActions.find(a => a.id === 'c52c6f20-e495-4b29-b3df-d7edfb67fdd7') + expect(observations).equal('RUne observation importante') + }) + }) + + it('allow multiple themes and may be multiple subthemes in surveillance actions', () => { + // Given + cy.get('*[data-cy="edit-mission-34"]').click({ force: true }) + cy.get('*[data-cy="action-card"]').eq(0).click() + cy.get('*[data-cy="envaction-theme-element"]').should('have.length', 2) + cy.get('*[data-cy="envaction-theme-selector"]') + .eq(0) + .contains('Police des espèces protégées et de leurs habitats (faune et flore)') + cy.get('*[data-cy="envaction-theme-element"]').contains('Destruction, capture, arrachage') + cy.get('*[data-cy="envaction-protected-species-selector"]').should('exist') + cy.get('*[data-cy="envaction-theme-element"]').contains('Flore') + cy.get('*[data-cy="envaction-theme-element"]').contains('Oiseaux') + + // When + cy.get('*[data-cy="envaction-theme-selector"]').eq(0).click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').eq(0).contains('Police des réserves naturelles').click() + + cy.get('*[data-cy="envaction-add-theme"]').click({ force: true }) + cy.get('*[data-cy="envaction-theme-selector"]').eq(2).click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').eq(2).contains('Rejets illicites').click() + + cy.get('*[data-cy="envaction-subtheme-selector"]').eq(2).click({ force: true }) + cy.get('*[data-cy="envaction-theme-element"]').eq(2).contains('Jet de déchet').click({ force: true }) + + cy.get('*[data-cy="envaction-protected-species-selector"]').should('have.length', 0) + + cy.intercept('PUT', `/bff/v1/missions/34`).as('updateMission') + cy.get('form').submit() + + // Then + cy.wait('@updateMission').then(({ response }) => { + expect(response && response.statusCode).equal(200) + + const { themes } = response && response.body.envActions.find(a => a.id === 'b8007c8a-5135-4bc3-816f-c69c7b75d807') + expect(themes.length).equal(3) + expect(themes[0].theme).equal('Police des réserves naturelles') + expect(themes[0].subThemes.length).equal(0) + expect(themes[0].protectedSpecies.length).equal(0) + expect(themes[1].theme).equal('Police des mouillages') + expect(themes[1].subThemes.length).equal(2) + expect(themes[1].subThemes[0]).equal('Mouillage individuel') + expect(themes[1].subThemes[1]).equal('ZMEL') + expect(themes[1].protectedSpecies.length).equal(0) + expect(themes[2].theme).equal('Rejets illicites') + expect(themes[2].subThemes.length).equal(1) + expect(themes[2].subThemes[0]).equal('Jet de déchet') + expect(themes[2].protectedSpecies.length).equal(0) + }) + }) +}) diff --git a/frontend/cypress/e2e/02_side_window_mission_actions.spec.ts b/frontend/cypress/e2e/side_window/mission/mission_dates_validation.spec.ts similarity index 51% rename from frontend/cypress/e2e/02_side_window_mission_actions.spec.ts rename to frontend/cypress/e2e/side_window/mission/mission_dates_validation.spec.ts index fa88928349..efceb5e624 100644 --- a/frontend/cypress/e2e/02_side_window_mission_actions.spec.ts +++ b/frontend/cypress/e2e/side_window/mission/mission_dates_validation.spec.ts @@ -1,166 +1,11 @@ /// -context('Mission actions', () => { +context('Mission dates', () => { beforeEach(() => { cy.viewport(1280, 1024) cy.visit(`/side_window`) }) - it('An infraction Should be duplicated', () => { - // Given - cy.get('*[data-cy="edit-mission-34"]').click({ force: true }) - cy.get('*[data-cy="action-card"]').eq(1).click() - cy.get('*[data-cy="control-form-number-controls"]').type('{backspace}2') - cy.get('*[data-cy="infraction-form"]').should('not.exist') - - // When - cy.get('*[data-cy="duplicate-infraction"]').click({ force: true }) - cy.get('*[data-cy="infraction-form-registrationNumber"]').should('have.value', 'BALTIK') - cy.get('*[data-cy="infraction-form-validate"]').click({ force: true }) - cy.get('*[data-cy="duplicate-infraction"]').eq(1).should('be.disabled') - - cy.intercept('PUT', `/bff/v1/missions/34`).as('updateMission') - cy.get('form').submit() - - // Then - cy.wait('@updateMission').then(({ request, response }) => { - expect(response && response.statusCode).equal(200) - const { infractions } = request.body.envActions.find(a => a.id === 'c52c6f20-e495-4b29-b3df-d7edfb67fdd7') - expect(infractions.length).equal(2) - const duplicatedInfraction = infractions[1] - - expect(duplicatedInfraction.controlledPersonIdentity).equal('John Doe') - expect(duplicatedInfraction.formalNotice).equal('PENDING') - expect(duplicatedInfraction.infractionType).equal('WITH_REPORT') - expect(duplicatedInfraction.natinf.length).equal(2) - expect(duplicatedInfraction.observations).equal("Pas d'observations") - expect(duplicatedInfraction.registrationNumber).equal('BALTIK') - expect(duplicatedInfraction.relevantCourt).equal('LOCAL_COURT') - expect(duplicatedInfraction.toProcess).equal(false) - expect(duplicatedInfraction.vesselSize).equal('FROM_24_TO_46m') - expect(duplicatedInfraction.vesselType).equal('COMMERCIAL') - expect(duplicatedInfraction.id).not.equal('c52c6f20-e495-4b29-b3df-d7edfb67fdd7') - }) - }) - - it('allow only one theme and may be multiple subthemes in control actions', () => { - // Given - cy.get('*[data-cy="edit-mission-34"]').click({ force: true }) - cy.get('*[data-cy="action-card"]').eq(1).click() - cy.get('*[data-cy="envaction-theme-element"]').should('have.length', 1) - cy.get('*[data-cy="envaction-theme-selector"]').contains('Police des mouillages') - cy.get('*[data-cy="envaction-theme-element"]').contains('Mouillage individuel') - cy.get('*[data-cy="envaction-theme-element"]').contains('ZMEL') - cy.get('*[data-cy="envaction-protected-species-selector"]').should('not.exist') - // When - cy.get('*[data-cy="envaction-theme-selector"]').click({ force: true }) - cy.get('*[data-cy="envaction-theme-element"]').contains('Police des espèces protégées').click() - - cy.get('*[data-cy="envaction-subtheme-selector"]').click({ force: true }) - cy.get('*[data-cy="envaction-theme-element"]').contains('Perturbation').click({ force: true }) - cy.get('*[data-cy="envaction-theme-element"]').contains('Atteinte aux habitats').click({ force: true }) - cy.get('*[data-cy="envaction-subtheme-selector"]').click({ force: true }) - - cy.get('*[data-cy="envaction-protected-species-selector"]').should('exist') - cy.get('*[data-cy="envaction-protected-species-selector"]').click({ force: true }) - cy.get('*[data-cy="envaction-theme-element"]').contains('Habitat').click({ force: true }) - cy.get('*[data-cy="envaction-theme-element"]').contains('Oiseaux').click({ force: true }) - cy.get('*[data-cy="envaction-protected-species-selector"]').click({ force: true }) - - cy.get('*[data-cy="envaction-add-theme"]').should('not.exist') - - cy.intercept('PUT', `/bff/v1/missions/34`).as('updateMission') - cy.get('form').submit() - - // Then - cy.wait('@updateMission').then(({ request, response }) => { - expect(response && response.statusCode).equal(200) - - const { themes } = request.body.envActions.find(a => a.id === 'c52c6f20-e495-4b29-b3df-d7edfb67fdd7') - expect(themes.length).equal(1) - expect(themes[0].theme).equal('Police des espèces protégées et de leurs habitats (faune et flore)') - expect(themes[0].subThemes.length).equal(2) - expect(themes[0].subThemes[0]).equal("Perturbation d'animaux") - expect(themes[0].subThemes[1]).equal("Atteinte aux habitats d'espèces protégées") - expect(themes[0].protectedSpecies.length).equal(2) - expect(themes[0].protectedSpecies[0]).equal('HABITAT') - expect(themes[0].protectedSpecies[1]).equal('BIRDS') - }) - }) - - it('save observations in control Actions', () => { - // Given - cy.get('*[data-cy="edit-mission-34"]').click({ force: true }) - cy.get('*[data-cy="action-card"]').eq(1).click() - cy.get('[id="envActions[1].observations"]').contains('RAS') - - // When - cy.get('[id="envActions[1].observations"]').type('{backspace}{backspace}Une observation importante', { - force: true - }) - - cy.intercept('PUT', `/bff/v1/missions/34`).as('updateMission') - cy.get('form').submit() - - // Then - cy.wait('@updateMission').then(({ request, response }) => { - expect(response && response.statusCode).equal(200) - - const { observations } = request.body.envActions.find(a => a.id === 'c52c6f20-e495-4b29-b3df-d7edfb67fdd7') - expect(observations).equal('RUne observation importante') - }) - }) - - it('allow multiple themes and may be multiple subthemes in surveillance actions', () => { - // Given - cy.get('*[data-cy="edit-mission-34"]').click({ force: true }) - cy.get('*[data-cy="action-card"]').eq(0).click() - cy.get('*[data-cy="envaction-theme-element"]').should('have.length', 2) - cy.get('*[data-cy="envaction-theme-selector"]') - .eq(0) - .contains('Police des espèces protégées et de leurs habitats (faune et flore)') - cy.get('*[data-cy="envaction-theme-element"]').contains('Destruction, capture, arrachage') - cy.get('*[data-cy="envaction-protected-species-selector"]').should('exist') - cy.get('*[data-cy="envaction-theme-element"]').contains('Flore') - cy.get('*[data-cy="envaction-theme-element"]').contains('Oiseaux') - - // When - cy.get('*[data-cy="envaction-theme-selector"]').eq(0).click({ force: true }) - cy.get('*[data-cy="envaction-theme-element"]').eq(0).contains('Police des réserves naturelles').click() - - cy.get('*[data-cy="envaction-add-theme"]').click({ force: true }) - cy.get('*[data-cy="envaction-theme-selector"]').eq(2).click({ force: true }) - cy.get('*[data-cy="envaction-theme-element"]').eq(2).contains('Rejets illicites').click() - - cy.get('*[data-cy="envaction-subtheme-selector"]').eq(2).click({ force: true }) - cy.get('*[data-cy="envaction-theme-element"]').eq(2).contains('Jet de déchet').click({ force: true }) - - cy.get('*[data-cy="envaction-protected-species-selector"]').should('have.length', 0) - - cy.intercept('PUT', `/bff/v1/missions/34`).as('updateMission') - cy.get('form').submit() - - // Then - cy.wait('@updateMission').then(({ response }) => { - expect(response && response.statusCode).equal(200) - - const { themes } = response && response.body.envActions.find(a => a.id === 'b8007c8a-5135-4bc3-816f-c69c7b75d807') - expect(themes.length).equal(3) - expect(themes[0].theme).equal('Police des réserves naturelles') - expect(themes[0].subThemes.length).equal(0) - expect(themes[0].protectedSpecies.length).equal(0) - expect(themes[1].theme).equal('Police des mouillages') - expect(themes[1].subThemes.length).equal(2) - expect(themes[1].subThemes[0]).equal('Mouillage individuel') - expect(themes[1].subThemes[1]).equal('ZMEL') - expect(themes[1].protectedSpecies.length).equal(0) - expect(themes[2].theme).equal('Rejets illicites') - expect(themes[2].subThemes.length).equal(1) - expect(themes[2].subThemes[0]).equal('Jet de déchet') - expect(themes[2].protectedSpecies.length).equal(0) - }) - }) - it('A mission should be created and closed with surveillances and valid dates', () => { // Given cy.wait(200) diff --git a/frontend/cypress/e2e/00_side_window_missions.spec.ts b/frontend/cypress/e2e/side_window/mission_list/missions.spec.ts similarity index 100% rename from frontend/cypress/e2e/00_side_window_missions.spec.ts rename to frontend/cypress/e2e/side_window/mission_list/missions.spec.ts diff --git a/frontend/cypress/e2e/03_side_window_missions_navigation.spec.ts b/frontend/cypress/e2e/side_window/mission_list/missions_navigation.spec.ts similarity index 100% rename from frontend/cypress/e2e/03_side_window_missions_navigation.spec.ts rename to frontend/cypress/e2e/side_window/mission_list/missions_navigation.spec.ts diff --git a/frontend/cypress/e2e/05_side_window_reportings.spec.ts b/frontend/cypress/e2e/side_window/reporting/reportings.spec.ts similarity index 100% rename from frontend/cypress/e2e/05_side_window_reportings.spec.ts rename to frontend/cypress/e2e/side_window/reporting/reportings.spec.ts diff --git a/frontend/src/features/missions/MissionForm/ActionForm/SurveillanceForm.tsx b/frontend/src/features/missions/MissionForm/ActionForm/SurveillanceForm.tsx index 57cfdacffa..6c2bb706ca 100644 --- a/frontend/src/features/missions/MissionForm/ActionForm/SurveillanceForm.tsx +++ b/frontend/src/features/missions/MissionForm/ActionForm/SurveillanceForm.tsx @@ -125,6 +125,7 @@ export function SurveillanceForm({ currentActionIndex, remove, setCurrentActionI name={`envActions[${currentActionIndex}].geom`} /> ( + const [administrationField, administrationMeta, administrationHelpers] = useField( `controlUnits.${controlUnitIndex}.administration` ) const [unitField, , unitHelpers] = useField(`controlUnits.${controlUnitIndex}.id`) - const [, , unitNameHelpers] = useField(`controlUnits.${controlUnitIndex}.name`) + const [, unitNameMeta, unitNameHelpers] = useField(`controlUnits.${controlUnitIndex}.name`) const [resourcesField, , resourcesHelpers] = useField( `controlUnits.${controlUnitIndex}.resources` ) @@ -118,6 +118,7 @@ export function ControlUnitSelector({ controlUnitIndex, controlUnitPath, removeC )} + {administrationMeta.error && {administrationMeta.error}} @@ -136,6 +137,7 @@ export function ControlUnitSelector({ controlUnitIndex, controlUnitPath, removeC key={unitField.value} /> + {unitNameMeta.error && {unitNameMeta.error}} @@ -176,8 +178,7 @@ const RessourceUnitWrapper = styled.div` const FormGroupFixed = styled.div` display: flex; - flex-direction: row; - height: 52px; + flex-direction: column; width: 100%; :not(:last-child) { diff --git a/frontend/src/features/missions/MissionForm/GeneralInformationsForm.tsx b/frontend/src/features/missions/MissionForm/GeneralInformationsForm.tsx index 28ee19daa9..8db1247cbd 100644 --- a/frontend/src/features/missions/MissionForm/GeneralInformationsForm.tsx +++ b/frontend/src/features/missions/MissionForm/GeneralInformationsForm.tsx @@ -86,20 +86,24 @@ export function GeneralInformationsForm() { {errors.endDateTimeUtc && {errors.endDateTimeUtc}} - - - {(missionSourceField.value === MissionSourceEnum.MONITORFISH || - missionSourceField.value === MissionSourceEnum.POSEIDON_CNSP) && ( - - )} - +
+ + + + {(missionSourceField.value === MissionSourceEnum.MONITORFISH || + missionSourceField.value === MissionSourceEnum.POSEIDON_CNSP) && ( + + )} + + {errors.missionTypes && {errors.missionTypes}} +
{(missionSourceField.value === MissionSourceEnum.MONITORFISH || missionSourceField.value === MissionSourceEnum.POSEIDON_CNSP) && ( val && !_.isEmpty(val?.coordinates) }) @@ -66,7 +66,7 @@ export const getClosedEnvActionControlSchema = (ctx: any): Yup.SchemaOf = Yup.object().shape({ protectedSpecies: Yup.array().of(Yup.string().optional()).nullable().optional(), - subThemes: Yup.array() - .of(Yup.string().required()) - .ensure() - .required() - .min(1, 'Sélectionnez au moins une sous thématique'), - theme: Yup.string().nullable().required('Sélectionnez un thème') + subThemes: Yup.array().of(Yup.string().required()).ensure().required().min(1, 'Sous-thématique requise'), + theme: Yup.string().nullable().required('Thème requis') }) diff --git a/frontend/src/features/missions/MissionForm/Schemas/index.ts b/frontend/src/features/missions/MissionForm/Schemas/index.ts index 8eb76a520b..bea338d65a 100644 --- a/frontend/src/features/missions/MissionForm/Schemas/index.ts +++ b/frontend/src/features/missions/MissionForm/Schemas/index.ts @@ -19,7 +19,7 @@ const shouldUseAlternateValidationInTestEnvironment = process.env.NODE_ENV === ' const MissionTypesSchema = Yup.array() .of(Yup.mixed().oneOf(Object.values(MissionTypeEnum)).required()) .ensure() - .min(1, 'Requis') + .min(1, 'Type de mission requis') const ControlResourceSchema: Yup.SchemaOf = Yup.object() .shape({ @@ -30,7 +30,7 @@ const ControlResourceSchema: Yup.SchemaOf = Yup const ControlUnitSchema: Yup.SchemaOf = Yup.object() .shape({ - administration: Yup.string().required(), + administration: Yup.string().required('Administration requise'), contact: Yup.string() .nullable() .test({ @@ -45,7 +45,7 @@ const ControlUnitSchema: Yup.SchemaOf = Yup.object() } }), id: Yup.number().required(), - name: Yup.string().required(), + name: Yup.string().required('Unité requise'), resources: Yup.array().ensure().of(ControlResourceSchema).required() }) .defined() @@ -119,7 +119,7 @@ const NewMissionSchema: Yup.SchemaOf = Yup.object() .min(3, 'le Trigramme doit comporter 3 lettres') .max(3, 'le Trigramme doit comporter 3 lettres') .nullable() - .required('Trigramme requis'), + .required("Trigramme d'ouverture requis"), startDateTimeUtc: Yup.date().required('Date de début requise') }) .required() @@ -129,7 +129,7 @@ const ClosedMissionSchema = NewMissionSchema.shape({ .min(3, 'Minimum 3 lettres pour le Trigramme') .max(3, 'Maximum 3 lettres pour le Trigramme') .nullable() - .required('Trigramme requis'), + .required('Trigramme de clôture requis'), controlUnits: Yup.array().of(ClosedControlUnitSchema).ensure().defined().min(1), envActions: Yup.array() .of(ClosedEnvActionSchema as any) diff --git a/frontend/src/features/missions/MultiPointPicker.tsx b/frontend/src/features/missions/MultiPointPicker.tsx index 223e5393ca..604eb7accc 100644 --- a/frontend/src/features/missions/MultiPointPicker.tsx +++ b/frontend/src/features/missions/MultiPointPicker.tsx @@ -90,7 +90,7 @@ export function MultiPointPicker({ addButtonLabel, label = undefined, name }: Mu > {addButtonLabel} - {!!meta.error && Veuillez définir un point de contrôle} + {!!meta.error && {meta.error}} <> {points.map((coordinates, index) => (