Skip to content

Commit

Permalink
[Mission] Résolution du bug à l'enregistrement d'une mission clôturée (
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 committed Oct 27, 2023
2 parents 3c255ed + c6e353f commit a9dd0ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,33 @@ context('Mission', () => {
cy.get('*[data-cy="SideWindowHeader-title"]').contains('Missions et contrôles')
})

it('A closed mission can be saved and stay closed', () => {
// Given
cy.wait(200)
cy.get('*[data-cy="edit-mission-43"]').click({ force: true })
cy.intercept('PUT', '/bff/v1/missions/43').as('updateMission')
cy.clickButton('Enregistrer et quitter')

// Then
cy.wait('@updateMission').then(({ response }) => {
expect(response && response.statusCode).equal(200)
expect(response && response.body.isClosed).equal(true)
})
})

it('A warning should be displayed When a control unit is already engaged in a mission ', () => {
// Given
cy.wait(200)
cy.intercept('GET', '/api/v1/missions/engaged_control_units').as('getEngagedControlUnits')

// When
cy.get('*[data-cy="edit-mission-43"]').click({ force: true })
cy.wait('@getEngagedControlUnits')

// Then
cy.get('body').contains('Cette unité est actuellement sélectionnée dans une autre mission en cours.')
})

it('A mission from monitorFish cannot be deleted', () => {
// Given
cy.wait(200)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/features/missions/MissionForm/MissionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ export function MissionForm({ id, isNewMission, selectedMission, setShouldValida
const submitMission = () => {
setShouldValidateOnChange(false)

validateForm({ ...values, isClosed: false }).then(errors => {
validateForm().then(errors => {
if (_.isEmpty(errors)) {
dispatch(saveMission({ ...values, isClosed: false }))
dispatch(saveMission(values))

return
}
Expand Down

0 comments on commit a9dd0ee

Please sign in to comment.