Skip to content

Commit

Permalink
[Test] fix tests e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 committed May 13, 2024
1 parent 42083d0 commit 1540385
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,23 @@ context('Side Window > Mission Form > Mission actions', () => {

// When
cy.fill('Thématique de contrôle', 'Espèce protégée') // id 103
cy.wait(250)
cy.wait(300)

cy.get('*[data-cy="envaction-subtheme-selector"]').click({ force: true })
cy.get('*[data-cy="envaction-theme-element"]')
.contains("Destruction, capture, arrachage d'espèces protégées")
.click({ force: true }) // id 117
cy.wait(300)
cy.get('*[data-cy="envaction-theme-element"]').contains('Détention des espèces protégées').click({ force: true }) // id 120

cy.wait(250)
cy.wait(300)
cy.get('*[data-cy="envaction-tags-selector"]').should('exist')
cy.get('*[data-cy="envaction-tags-selector"]').click({ force: true })
cy.get('*[data-cy="envaction-theme-element"]').contains('Habitat').click({ force: true }) // id 15
cy.get('*[data-cy="envaction-theme-element"]').contains('Oiseaux').click({ force: true }) // id 11
cy.wait(700)
cy.get('*[data-cy="envaction-theme-element"]').contains('Flore').click({ force: true }) // id 14
cy.wait(700)

cy.get('*[data-cy="envaction-theme-element"]').click('topLeft', { force: true })

/*
Expand All @@ -81,10 +86,9 @@ context('Side Window > Mission Form > Mission actions', () => {
["Destruction, capture, arrachage d'espèces protégées", 'Détention des espèces protégées'], // id 117 and 120
{ delay: 250 }
)
cy.fill('Précisions sur la thématique', ['Habitat', 'Oiseaux'], { delay: 250 }) // id 15 and 11
cy.fill('Précisions sur la thématique', ['Habitat', 'Flore'], { delay: 250 }) // id 15 and 14
*/
cy.get('*[data-cy="envaction-add-theme"]').should('not.exist')
cy.wait(500)

// Then
cy.waitForLastRequest(
Expand All @@ -93,13 +97,13 @@ context('Side Window > Mission Form > Mission actions', () => {
body: {
envActions: [
{
controlPlans: [{ subThemeIds: [117, 120], tagIds: [15, 11], themeId: 103 }],
controlPlans: [{ subThemeIds: [117, 120], tagIds: [14, 15], themeId: 103 }],
id: 'b8007c8a-5135-4bc3-816f-c69c7b75d807'
}
]
}
},
10,
7,
0,
response => {
expect(response && response.statusCode).equal(200)
Expand All @@ -114,7 +118,7 @@ context('Side Window > Mission Form > Mission actions', () => {
expect(controlPlans[0].subThemeIds[1]).equal(120)
expect(controlPlans[0].tagIds.length).equal(2)
expect(controlPlans[0].tagIds[0]).equal(15)
expect(controlPlans[0].tagIds[1]).equal(11)
expect(controlPlans[0].tagIds[1]).equal(14)
}
)
})
Expand Down Expand Up @@ -421,7 +425,7 @@ context('Side Window > Mission Form > Mission actions', () => {
cy.fill('Respect du code de la navigation sur le plan d’eau', false)
cy.fill('Gens de mer', false)
cy.fill('Equipement de sécurité et respect des normes', false)
cy.wait(200)
cy.wait(300)

cy.waitForLastRequest(
'@updateMission',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ context('Side Window > Mission Form > Mission dates', () => {
cy.get('[name="missionTypes0"]').click({ force: true })
cy.get('[name="missionTypes1"]').click({ force: true })

cy.fill('Unité 1', 'Cross Etel', { delay: 100 })
cy.fill('Unité 1', 'Cross Gris Nez', { delay: 100 })
cy.wait(250)
cy.get('*[data-cy="add-control-administration"]').contains('DIRM / DM')
cy.get('*[data-cy="add-control-unit"]').contains('Cross Etel')
cy.get('*[data-cy="add-control-unit"]').contains('Cross Gris Nez')

cy.wait(500)

Expand Down Expand Up @@ -179,11 +179,11 @@ context('Side Window > Mission Form > Mission dates', () => {
cy.get('[name="missionTypes0"]').click({ force: true })
cy.get('[name="missionTypes1"]').click({ force: true })

cy.fill('Unité 1', 'Cross Etel', { delay: 100 })
cy.fill('Unité 1', 'DF 61 Port-de-Bouc', { delay: 100 })
cy.clickOutside()
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('*[data-cy="add-control-administration"]').contains('Douane')
cy.get('*[data-cy="add-control-unit"]').contains('DF 61 Port-de-Bouc')
cy.wait(200)

cy.intercept('PUT', `/bff/v1/missions/*`).as('updateMission')
Expand Down Expand Up @@ -239,10 +239,10 @@ context('Side Window > Mission Form > Mission dates', () => {
cy.get('[name="missionTypes0"]').click({ force: true })
cy.get('[name="missionTypes1"]').click({ force: true })

cy.fill('Unité 1', 'Cross Etel', { delay: 100 })
cy.fill('Unité 1', 'Cultures marines – DDTM 40', { delay: 100 })
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('*[data-cy="add-control-administration"]').contains('DDTM')
cy.get('*[data-cy="add-control-unit"]').contains('Cultures marines – DDTM 40')

cy.wait(250)

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/domain/use_cases/missions/saveMission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const saveMission =
} = getState()
const selectedMissions = getState().missionForms.missions

const sortedActions = values.envActions.sort((a, b) => a.id - b.id)
const actions = [...values.envActions]
const sortedActions = actions.sort((a, b) => a.id - b.id)
const valuesToSave = omit({ ...values, envActions: sortedActions }, [
'attachedReportings',
'detachedReportings',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/missions/MissionForm/MissionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export function MissionForm({
}

dispatch(saveMission(nextValues, false, false))
}, 300)
}, 350)

useEffect(() => {
if (isNewMission && !engagedControlUnit && previousEngagedControlUnit !== engagedControlUnit) {
Expand Down

0 comments on commit 1540385

Please sign in to comment.