diff --git a/frontend/cypress/e2e/side_window/mission_form/sea_control.spec.ts b/frontend/cypress/e2e/side_window/mission_form/sea_control.spec.ts index 78dee22582..e79077ae53 100644 --- a/frontend/cypress/e2e/side_window/mission_form/sea_control.spec.ts +++ b/frontend/cypress/e2e/side_window/mission_form/sea_control.spec.ts @@ -290,7 +290,7 @@ context('Side Window > Mission Form > Sea Control', () => { // Clôturé par // TODO Handle multiple inputs with same label via an `index` in monitor-ui. - cy.get('[name="closedBy"]').eq(1).type('Alice') + cy.get('[name="closedBy"]').eq(1).type('Alice', { force: true }) cy.wait(500) diff --git a/frontend/cypress/e2e/side_window/mission_form/sea_control_edition.spec.ts b/frontend/cypress/e2e/side_window/mission_form/sea_control_edition.spec.ts index e79ccbacb6..109547801a 100644 --- a/frontend/cypress/e2e/side_window/mission_form/sea_control_edition.spec.ts +++ b/frontend/cypress/e2e/side_window/mission_form/sea_control_edition.spec.ts @@ -1,4 +1,6 @@ import { editSideWindowMission } from './utils' +import { customDayjs } from '../../utils/customDayjs' +import { getUtcDateInMultipleFormats } from '../../utils/getUtcDateInMultipleFormats' context('Side Window > Mission Form > Sea Control Edition', () => { beforeEach(() => { @@ -213,4 +215,52 @@ context('Side Window > Mission Form > Sea Control Edition', () => { .its('response.statusCode') .should('eq', 201) }) + + it( + 'Should update actions When auto save is not enabled', + { + env: { + FRONTEND_MISSION_FORM_AUTO_SAVE_ENABLED: false + } + }, + () => { + cy.intercept('PUT', '/bff/v1/mission_actions/4', { + body: { + id: 4 + }, + statusCode: 201 + }).as('updateMissionAction') + + // ------------------------------------------------------------------------- + // Form + const endDate = getUtcDateInMultipleFormats(customDayjs().utc().add(7, 'day').toISOString()) + cy.fill('Fin de mission', endDate.utcDateTupleWithTime) + + cy.get('*[data-cy="action-list-item"]').click() + cy.wait(500) + + cy.fill( + 'Observations (hors infractions) sur les obligations déclaratives / autorisations', + 'Une nouvelle observation' + ) + // We need to wait for some time because there is a throttle on the form + cy.wait(500) + cy.clickButton('Enregistrer') + + // ------------------------------------------------------------------------- + // Request + + cy.waitForLastRequest( + '@updateMissionAction', + { + body: { + licencesAndLogbookObservations: 'Une nouvelle observation' + } + }, + 5 + ) + .its('response.statusCode') + .should('eq', 201) + } + ) }) diff --git a/frontend/src/features/Mission/useCases/saveMissionAndMissionActionsByDiff.ts b/frontend/src/features/Mission/useCases/saveMissionAndMissionActionsByDiff.ts index dff560bacb..f89f22dc70 100644 --- a/frontend/src/features/Mission/useCases/saveMissionAndMissionActionsByDiff.ts +++ b/frontend/src/features/Mission/useCases/saveMissionAndMissionActionsByDiff.ts @@ -36,15 +36,17 @@ export const saveMissionAndMissionActionsByDiff = if (missionActionData.id === undefined) { await dispatch(missionActionApi.endpoints.createMissionAction.initiate(missionActionData)).unwrap() } else { - missionActionApi.endpoints.updateMissionAction.initiate({ - ...missionActionData, - id: missionActionData.id, - /** - * This field is not used in the backend use-case, we add this property to - * respected the MissionAction type (using `portName` when fetching missions actions). - */ - portName: undefined - }) + await dispatch( + missionActionApi.endpoints.updateMissionAction.initiate({ + ...missionActionData, + id: missionActionData.id, + /** + * This field is not used in the backend use-case, we add this property to + * respected the MissionAction type (using `portName` when fetching missions actions). + */ + portName: undefined + }) + ) } }) ])