Skip to content

Commit

Permalink
Stub http request to fix dependent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Feb 7, 2024
1 parent a76995b commit 894203d
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions frontend/cypress/e2e/side_window/mission_form/main_form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,26 @@ context('Side Window > Mission Form > Main Form', () => {

const expectedStartDateTimeUtc = new RegExp(`${customDayjs().utc().format('YYYY-MM-DDTHH')}:\\d{2}:00\\.000Z`)

cy.intercept('POST', '/api/v1/missions', cy.spy().as('createMissionSpy')).as('createMission')

cy.get('@createMissionSpy').should('not.have.been.called')
cy.intercept('POST', '/api/v1/missions', {
body: {
createdAtUtc: customDayjs().utc().format('YYYY-MM-DDTHH:mm:ss.000Z'),
id: 1,
updatedAtUtc: customDayjs().utc().format('YYYY-MM-DDTHH:mm:ss.000Z')
},
statusCode: 201
}).as('createMission')
cy.intercept('GET', '/api/v1/missions/1', {
body: {
id: 1
},
statusCode: 201
}).as('getCreatedMission')

cy.fill('Types de mission', ['Mer'])

cy.fill('Administration 1', 'DDTM')
cy.fill('Unité 1', 'Cultures marines – DDTM 40')

cy.get('@createMissionSpy').should('have.been.called')

cy.wait('@createMission').then(interception => {
if (!interception.response) {
assert.fail('`interception.response` is undefined.')
Expand Down Expand Up @@ -401,6 +410,12 @@ context('Side Window > Mission Form > Main Form', () => {
})

it('Should close a new mission', () => {
cy.intercept('DELETE', '/bff/v1/mission_actions/2', {
body: {
id: 2
},
statusCode: 200
}).as('updateMissionAction')
cy.intercept('POST', '/api/v1/missions/1', {
body: {
id: 1,
Expand Down

0 comments on commit 894203d

Please sign in to comment.