Skip to content

Commit

Permalink
[review] fix tests e2e idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
maximeperrault committed May 27, 2024
1 parent 0f5affc commit 70a14aa
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions frontend/cypress/e2e/side_window/mission_form/main_form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ context('Side Window > Mission Form > Main Form', () => {
cy.get('div').contains('Mission créée par le')
cy.get('div').contains('Dernière modification enregistrée')
cy.get('.Component-Banner').contains('La mission a bien été créée')
cy.clickButton('Supprimer la mission')
cy.get('*[name="delete-mission-modal-confirm"]').click()
})

it('A mission should be created When auto-save is not enabled', () => {
Expand Down Expand Up @@ -135,33 +137,22 @@ context('Side Window > Mission Form > Main Form', () => {
cy.clickButton('Enregistrer')

// Then
cy.waitForLastRequest(
'@createMission',
{
body: {
controlUnits: [
{
administration: 'DIRM / DM',
id: 10011,
name: 'Cross Etel'
}
],
missionTypes: ['SEA', 'LAND'],
openBy: 'PCF'
}
},
5
)
.its('response.statusCode')
.should('eq', 200)
cy.wait('@createMission').then(({ response }) => {
const id = response?.body.id
if (!response) {
assert.fail('response is undefined.')
}
assert.equal(response.statusCode, 200)

cy.wait('@getMissions')
cy.wait(500)
cy.get('*[data-cy="Missions-numberOfDisplayedMissions"]').then($el => {
const numberOfMissions = parseInt($el.text(), 10)
cy.get('@numberOfMissions').then(numberOfMissionsBefore => {
expect(numberOfMissions).equal(parseInt(numberOfMissionsBefore as unknown as string, 10) + 1)
cy.wait('@getMissions')
cy.wait(500)
cy.get('*[data-cy="Missions-numberOfDisplayedMissions"]').then($el => {
const numberOfMissions = parseInt($el.text(), 10)
cy.get('@numberOfMissions').then(numberOfMissionsBefore => {
expect(numberOfMissions).equal(parseInt(numberOfMissionsBefore as unknown as string, 10) + 1)
})
})
cy.get(`*[data-cy="edit-mission-${id}"]`).scrollIntoView().click({ force: true })
})
})

Expand Down

0 comments on commit 70a14aa

Please sign in to comment.