Skip to content

Commit

Permalink
[Mission] Résolution du bug de la date de surveillance identique à la…
Browse files Browse the repository at this point in the history
… date de mission (#1068)

## Related Pull Requests & Issues

- Resolve #1067

----

- [x] Tests E2E (Cypress)
  • Loading branch information
claire2212 committed Dec 19, 2023
2 parents f74fd08 + a0ed00a commit 3d1e46f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,55 @@ context('Mission dates', () => {
})
})

it('A mission should be created with same surveillance and mission dates', () => {
// Given
cy.wait(200)
cy.get('*[data-cy="add-mission"]').click()

// When
cy.fill('Début de mission (UTC)', [2024, 5, 26, 12, 0])
cy.fill('Fin de mission (UTC)', [2024, 5, 28, 14, 15])

cy.get('[name="missionTypes0"]').click({ force: true })
cy.get('[name="missionTypes1"]').click({ force: true })

cy.get('*[data-cy="add-control-unit"]').click()
cy.get('.rs-picker-search-bar-input').type('Cross{enter}')
cy.get('*[data-cy="control-unit-contact"]').type('Contact 012345')
cy.wait(200)
cy.get('*[data-cy="add-control-administration"]').contains('DIRM / DM')
cy.get('*[data-cy="add-control-unit"]').contains('Cross Etel')

cy.get('[name="openBy"]').scrollIntoView().type('PCF')

// Add a second surveillance
cy.clickButton('Ajouter')
cy.clickButton('Ajouter une surveillance')

cy.getDataCy('surveillance-duration-matches-mission').should('have.class', 'rs-checkbox-checked')

cy.intercept('PUT', `/bff/v1/missions`).as('createMission')
cy.clickButton('Enregistrer et quitter')

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

const surveillance = response?.body.envActions[0]
expect(surveillance.actionStartDateTimeUtc).equal(response?.body.startDateTimeUtc)
expect(surveillance.actionEndDateTimeUtc).equal(response?.body.endDateTimeUtc)

const id = response?.body.id

// clean
cy.getDataCy(`edit-mission-${id}`).click({ force: true })
cy.getDataCy('action-card').eq(0).click()
cy.getDataCy('surveillance-duration-matches-mission').should('have.class', 'rs-checkbox-checked')
cy.clickButton('Supprimer la mission')
cy.clickButton('Confirmer la suppression')
})
})

it('A mission should be created with valid dates for control action', () => {
// Given
cy.wait(200)
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/features/missions/Missions.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,7 @@ export const missionFactory = (
action.actionStartDateTimeUtc === mission?.startDateTimeUtc
)
: -1
if (
surveillanceWithSamePeriodIndex &&
surveillanceWithSamePeriodIndex !== -1 &&
envActions &&
envActions?.length > 0
) {
if (surveillanceWithSamePeriodIndex !== -1 && envActions?.length > 0) {
const envActionsUpdated: EnvAction[] = [...envActions]
const surveillance: EnvActionSurveillance = {
...(envActionsUpdated[surveillanceWithSamePeriodIndex] as EnvActionSurveillance),
Expand Down

0 comments on commit 3d1e46f

Please sign in to comment.