Skip to content

Commit

Permalink
[Test] add test to attach mission and reinitialize selection when cre…
Browse files Browse the repository at this point in the history
…ate a reporting
  • Loading branch information
claire2212 committed Jan 4, 2024
1 parent d373ee3 commit 9cb8593
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ context('Reporting', () => {
cy.wait(1000)

// When
cy.getDataCy('add-semaphore-source').click({ force: true })
cy.get('div[role="option"]').contains('Sémaphore de Dieppe').click()
cy.fill('Nom du Sémaphore', 'Sémaphore de Dieppe')

cy.getDataCy('reporting-target-type').click({ force: true })
cy.get('div[role="option"]').contains('Personne morale').click()
Expand Down Expand Up @@ -73,8 +72,7 @@ context('Reporting', () => {
cy.intercept('PUT', '/bff/v1/reportings').as('createReporting')

// When
cy.get('*[data-cy="add-semaphore-source"]').click({ force: true })
cy.get('div[role="option"]').contains('Sémaphore de Dieppe').click()
cy.fill('Nom du Sémaphore', 'Sémaphore de Dieppe')

cy.get('*[data-cy="reporting-target-type"]').click({ force: true })
cy.get('div[role="option"]').contains('Personne morale').click()
Expand Down Expand Up @@ -111,6 +109,7 @@ context('Reporting', () => {
})
})
})

it('A mission can be detached from a reporting', () => {
// Given
cy.intercept('PUT', '/bff/v1/reportings/*').as('updateReporting')
Expand Down Expand Up @@ -143,4 +142,43 @@ context('Reporting', () => {
})
})
})

it('An attached mission can be reinitialze during reporting creation', () => {
// Given
cy.clickButton('Chercher des signalements')
cy.clickButton('Ajouter un signalement')
cy.intercept('PUT', '/bff/v1/reportings').as('createReporting')
cy.wait(1000)

// When
cy.fill('Nom du Sémaphore', 'Sémaphore de Dieppe')

cy.getDataCy('reporting-target-type').click({ force: true })
cy.get('div[role="option"]').contains('Personne morale').click()

cy.clickButton('Ajouter un point')
cy.get('#root').click(350, 690, { timeout: 10000 })
cy.clickButton('Valider le point')

cy.get('.rs-radio').find('label').contains('Infraction').click()

cy.fill('Saisi par', 'XYZ')
cy.fill('Date et heure (UTC)', [2024, 5, 26, 23, 35])

cy.clickButton('Lier à une mission existante')
cy.get('#root').click(582, 546)
cy.wait(1000)
cy.clickButton('Réinitialiser')
cy.wait(1000)

cy.clickButton('Valider le signalement')

// Then
cy.wait('@createReporting').then(({ response }) => {
expect(response && response.statusCode).equal(201)
const responseBody = response && response.body
expect(responseBody.missionId).equal(null)
expect(responseBody.attachedMission).equal(null)
})
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
context('Mission', () => {
context('Side Window > Mission Form > Attach action to reporting', () => {
beforeEach(() => {
cy.viewport(1280, 1024)
cy.visit(`/side_window`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
context('Mission', () => {
context('Side Window > Mission Form > Validation on close', () => {
beforeEach(() => {
cy.viewport(1280, 1024)
cy.visit(`/side_window`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Mission actions', () => {
context('Side Window > Mission Form > Mission actions', () => {
beforeEach(() => {
cy.viewport(1280, 1024)
cy.visit(`/side_window`).wait(1000)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Mission dates', () => {
context('Side Window > Mission Form > Mission dates', () => {
beforeEach(() => {
cy.viewport(1280, 1024)

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/features/map/draw/DrawModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export function DrawModal() {
},
[dispatch]
)
if (!listener) {
return null
}

return (
<MapInteraction
Expand Down

0 comments on commit 9cb8593

Please sign in to comment.