-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] create test for close mission validation
- Loading branch information
1 parent
0bba122
commit 087bc34
Showing
16 changed files
with
293 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...press/e2e/04_map_create_reporting.spec.ts → ...window/reporting/create_reporting.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
frontend/cypress/e2e/side_window/mission/close_mission_validation.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
}) | ||
}) |
File renamed without changes.
163 changes: 163 additions & 0 deletions
163
frontend/cypress/e2e/side_window/mission/mission_actions.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
/// <reference types="cypress" /> | ||
|
||
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) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.