Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mission] Allègement des champs en erreur #1249

Merged
merged 5 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ VALUES
( 38, 10002),
( 39, 10003),
( 40, 10033),
( 41, 10002),
( 41, 10080),
( 42, 10003),
( 44, 10003),
( 45, 10014),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class JpaMissionRepositoryITests : AbstractDBTests() {

@Test
@Transactional
fun `findAll Should return missions when filered by controlUnit`() {
fun `findAll Should return missions when filtered by controlUnit`() {
// When
val missions =
jpaMissionRepository.findAllFullMissions(
Expand All @@ -94,7 +94,7 @@ class JpaMissionRepositoryITests : AbstractDBTests() {
)
val queryCount = customQueryCountListener!!.getQueryCount()
println("Number of Queries Executed: $queryCount")
assertThat(missions).hasSize(27)
assertThat(missions).hasSize(26)
}

@Test
Expand Down Expand Up @@ -380,7 +380,7 @@ class JpaMissionRepositoryITests : AbstractDBTests() {
fun `findByControlUnitId should find the matching missions`() {
val foundMissions = jpaMissionRepository.findByControlUnitId(10002)

assertThat(foundMissions).hasSize(17)
assertThat(foundMissions).hasSize(16)

val queryCount = customQueryCountListener!!.getQueryCount()
println("Number of Queries Executed: $queryCount")
Expand Down
3 changes: 1 addition & 2 deletions frontend/cypress/e2e/main_window/search_places.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ context('Search Places', () => {
})

it('A user can search a place and zoom on it when it is selected', () => {
cy.fill('Rechercher un lieu', 'Nantes')
cy.get('.rs-auto-complete-item').first().click()
cy.fill('Rechercher un lieu', 'Nantes', { delay: 200 })
cy.url().should('include', '/#@-173695.64,5981051.92,12.96')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -91,38 +91,61 @@ context('Side Window > Mission Form > Attach action to reporting', () => {
})
})
it('A surveillance can be attached to multiple reportings', () => {
// Given
cy.intercept('GET', '/bff/v1/missions*').as('getMissions')

cy.wait(400)
cy.getDataCy('edit-mission-53').click({ force: true })
cy.getDataCy('action-card').eq(1).click()
cy.wait(200)
cy.getDataCy('surveillance-form-toggle-reporting').click({ force: true })
cy.wait(250)
cy.wait(200)

cy.fill('Signalements', ['9'])

cy.getDataCy('surveillance-attached-reportings-tags').should('exist')
cy.getDataCy('reporting-status-action-tag').should('have.length', 2)
cy.getDataCy('reporting-status-action-tag').contains('Srv faite')
cy.wait(500)

cy.wait(250)
cy.intercept('PUT', '/bff/v1/missions/53').as('updateMission')
cy.fill('Signalements', ['9', '11'])
cy.intercept('PUT', `/bff/v1/missions/53`).as('updateMission')
cy.getDataCy('reporting-status-action-tag').should('have.length', 3)

// Then
cy.wait('@updateMission').then(({ response }) => {
expect(response && response.statusCode).equal(200)
const surveillanceWithAttachedReportings = response?.body.envActions.find(
action => action.id === '9969413b-b394-4db4-985f-b00743ffb833'
)
const firstAttachedReporting = response?.body.attachedReportings.find(reporting => reporting.id === 9)
const secondAttachedReporting = response?.body.attachedReportings.find(reporting => reporting.id === 11)

expect(surveillanceWithAttachedReportings.reportingIds.length).equal(2)
expect(firstAttachedReporting.attachedEnvActionId).equal('9969413b-b394-4db4-985f-b00743ffb833')
expect(secondAttachedReporting.attachedEnvActionId).equal('9969413b-b394-4db4-985f-b00743ffb833')
})
cy.wait(500)

cy.waitForLastRequest(
'@updateMission',
{
body: {
envActions: [
{
id: '2cdcd429-19ab-45ed-a892-7c695bd256e2',
reportingIds: []
},
{
id: '3480657f-7845-4eb4-aa06-07b174b1da45',
reportingIds: [10]
},
{
id: '9969413b-b394-4db4-985f-b00743ffb833',
reportingIds: [9, 11]
}
]
}
},
5,
0,
response => {
expect(response && response.statusCode).equal(200)
const surveillanceWithAttachedReportings = response?.body.envActions.find(
action => action.id === '9969413b-b394-4db4-985f-b00743ffb833'
)
const firstAttachedReporting = response?.body.attachedReportings.find(reporting => reporting.id === 9)
const secondAttachedReporting = response?.body.attachedReportings.find(reporting => reporting.id === 11)

expect(surveillanceWithAttachedReportings.reportingIds.length).equal(2)
expect(firstAttachedReporting.attachedEnvActionId).equal('9969413b-b394-4db4-985f-b00743ffb833')
expect(secondAttachedReporting.attachedEnvActionId).equal('9969413b-b394-4db4-985f-b00743ffb833')
}
)
})

it('A control with infraction can be created from a reporting', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,32 @@ context('Side Window > Mission Form > Validation on close', () => {
cy.get('*[data-cy="add-mission"]').click()
cy.wait(500)

cy.contains('Date de fin requise').should('exist')
cy.contains('Type de mission').should('exist')
cy.contains('Administration requise').should('exist')
cy.contains('Unité requise').should('exist')
cy.contains("Trigramme d'ouverture requis").should('exist')

// we fill all the required inputs
cy.fill('Début de mission (UTC)', [2023, 10, 11, 7, 35])
cy.fill('Début de mission', [2023, 10, 11, 7, 35])
cy.wait(250)
cy.fill('Fin de mission (UTC)', [customDayjs().year() + 1, 10, 12, 7, 35])
cy.fill('Fin de mission', [customDayjs().year() + 1, 10, 12, 7, 35])
cy.wait(250)
cy.fill('Type de mission', ['Air'])
cy.wait(250)
cy.get('*[data-cy="add-control-unit"]').click()
cy.wait(250)
cy.get('.rs-picker-search-bar-input').type('Cross Gris{enter}')
cy.fill('Unité 1', 'Cross Gris Nez')
cy.clickOutside()
cy.wait(250)
cy.fill("Contact de l'unité 1", 'contact').scrollIntoView()
cy.fill("Contact de l'unité 1", 'contact')
cy.wait(250)
cy.fill('Ouvert par', 'PCF').scrollIntoView()
cy.fill('Ouvert par', 'PCF')
cy.wait(1000)

cy.clickButton('Clôturer')
cy.wait(500)

cy.contains('Trigramme de clôture requis').should('exist')
cy.fill('Clôturé par', 'PCF').scrollIntoView()
cy.fill('Clôturé par', 'PCF')
cy.wait(500)

// we add a control
cy.clickButton('Ajouter')
cy.clickButton('Ajouter des contrôles')
cy.wait(250)

cy.contains('Thème requis').should('exist')
cy.contains('Sous-thématique requise').should('exist')
cy.contains('Date requise').should('exist')
// can't test this one because there is map interaction
// cy.contains('Point de contrôle requis').should('exist')

Expand All @@ -66,10 +54,10 @@ context('Side Window > Mission Form > Validation on close', () => {
cy.wait(250)
cy.get('*[data-cy="envaction-subtheme-selector"]').click('topLeft', { force: true })
cy.wait(250)
cy.fill('Date et heure du contrôle (UTC)', [2023, 10, 11, 12, 12])
cy.fill('Date et heure du contrôle', [2023, 10, 11, 12, 12])
cy.wait(250)

cy.fill('Nombre total de contrôles', '2')
cy.fill('Nombre total de contrôles', 2)
cy.wait(250)
cy.fill('Type de cible', 'Personne morale')
cy.wait(250)
Expand Down Expand Up @@ -103,7 +91,6 @@ context('Side Window > Mission Form > Validation on close', () => {
// delete theme to test error
cy.fill('Thématique de surveillance', '')
cy.wait(250)
cy.contains('Thème requis').should('exist')

cy.fill('Thématique de surveillance', 'Rejets illicites')
cy.wait(250)
Expand All @@ -127,43 +114,30 @@ context('Side Window > Mission Form > Validation on close', () => {
cy.get('*[data-cy="add-mission"]').click()
cy.wait(500)

cy.contains('Date de fin requise').should('exist')
cy.contains('Type de mission').should('exist')
cy.contains('Administration requise').should('exist')
cy.contains('Unité requise').should('exist')
cy.contains("Trigramme d'ouverture requis").should('exist')

// we fill all the required inputs
cy.fill('Début de mission (UTC)', [2023, 10, 11, 7, 35])
cy.fill('Début de mission', [2023, 10, 11, 7, 35])
cy.wait(250)
cy.fill('Fin de mission (UTC)', [2023, 10, 12, 7, 35])
cy.fill('Fin de mission', [2023, 10, 12, 7, 35])
cy.wait(250)
cy.fill('Type de mission', ['Air'])
cy.wait(250)
cy.get('*[data-cy="add-control-unit"]').click()
cy.wait(250)
cy.get('.rs-picker-search-bar-input').type('Cross{enter}')
cy.fill('Unité 1', 'Cross Etel')
cy.clickOutside()
cy.wait(250)
cy.fill("Contact de l'unité 1", 'contact').scrollIntoView()
cy.fill("Contact de l'unité 1", 'contact')
cy.wait(250)
cy.fill('Ouvert par', 'PCF').scrollIntoView()
cy.fill('Ouvert par', 'PCF')

cy.wait(500)
cy.clickButton('Clôturer')
cy.wait(250)
cy.contains('Trigramme de clôture requis').should('exist')
cy.wait(250)
cy.fill('Clôturé par', 'PCF').scrollIntoView()
cy.fill('Clôturé par', 'PCF')

// we add a control
cy.clickButton('Ajouter')
cy.clickButton('Ajouter des contrôles')
cy.wait(250)

cy.contains('Thème requis').should('exist')
cy.contains('Sous-thématique requise').should('exist')
cy.contains('Date requise').should('exist')
// can't test this one because there is map interaction
// cy.contains('Point de contrôle requis').should('exist')

Expand All @@ -176,10 +150,10 @@ context('Side Window > Mission Form > Validation on close', () => {
cy.wait(250)
cy.get('*[data-cy="envaction-subtheme-selector"]').click('topLeft', { force: true })
cy.wait(250)
cy.fill('Date et heure du contrôle (UTC)', [2023, 10, 11, 12, 12])
cy.fill('Date et heure du contrôle', [2023, 10, 11, 12, 12])
cy.wait(250)

cy.fill('Nombre total de contrôles', '2')
cy.fill('Nombre total de contrôles', 2)
cy.wait(250)
cy.fill('Type de cible', 'Personne morale')
cy.wait(250)
Expand Down Expand Up @@ -213,7 +187,6 @@ context('Side Window > Mission Form > Validation on close', () => {
// delete theme to test error
cy.fill('Thématique de surveillance', '')
cy.wait(250)
cy.contains('Thème requis').should('exist')

cy.fill('Thématique de surveillance', 'Rejets illicites')
cy.wait(250)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ context('Side Window > Mission Form > Delete Mission', () => {
cy.fill('Clôturé par', 'PCF')

cy.wait(500)
cy.waitForLastRequest('@updateMission', {}, 5, undefined, missionResponse => {
cy.waitForLastRequest('@updateMission', {}, 5, 0, missionResponse => {
const attachedReportingId = missionResponse.body.attachedReportingIds[0]

cy.intercept({ method: 'GET', url: '/bff/v1/missions/34/can_delete?source=MONITORENV' }).as('canDeleteMission')
Expand Down
36 changes: 15 additions & 21 deletions frontend/cypress/e2e/side_window/mission_form/main_form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@ context('Side Window > Mission Form > Main Form', () => {
// cy.get('div').contains('Mission non enregistrée.')
cy.get('.Element-Tag').contains('Enregistrement auto. actif')
// When
cy.fill('Début de mission (UTC)', [2024, 5, 26, 12, 0])
cy.fill('Début de mission', [2024, 5, 26, 12, 0])

// with wrong end date of mission
cy.fill('Fin de mission (UTC)', [2024, 5, 25, 14, 15])
cy.fill('Fin de mission', [2024, 5, 25, 14, 15])
cy.get('form').submit()
cy.wait(100)
cy.get('.Element-FieldError').contains('La date de fin doit être postérieure à la date de début')

// with good date
cy.fill('Fin de mission (UTC)', [2024, 5, 28, 14, 15])
cy.fill('Fin de mission', [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.fill('Unité 1', 'Cross Etel')
cy.clickOutside()
cy.get('*[data-cy="control-unit-contact"]').type('Contact 012345')
cy.wait(200)
Expand Down Expand Up @@ -95,22 +94,20 @@ context('Side Window > Mission Form > Main Form', () => {
cy.wait(100)
cy.get('.Element-Tag').contains('Enregistrement auto. inactif')
// When
cy.fill('Début de mission (UTC)', [2024, 5, 26, 12, 0])
cy.fill('Début de mission', [2024, 5, 26, 12, 0])

// with wrong end date of mission
cy.fill('Fin de mission (UTC)', [2024, 5, 25, 14, 15])
cy.fill('Fin de mission', [2024, 5, 25, 14, 15])
cy.get('form').submit()
cy.wait(100)
cy.get('.Element-FieldError').contains('La date de fin doit être postérieure à la date de début')

// with good date
cy.fill('Fin de mission (UTC)', [2024, 5, 28, 14, 15])
cy.fill('Fin de mission', [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.clickOutside()
cy.fill('Unité 1', 'Cross Etel')
cy.get('*[data-cy="control-unit-contact"]').type('Contact 012345')
cy.wait(200)
cy.get('*[data-cy="add-control-administration"]').contains('DIRM / DM')
Expand Down Expand Up @@ -264,8 +261,7 @@ context('Side Window > Mission Form > Main Form', () => {

// When
cy.get('*[data-cy="add-mission"]').click()
cy.get('*[data-cy="add-control-unit"]').click()
cy.get('.rs-picker-search-bar-input').type('Jeanne{enter}')
cy.fill('Unité 1', 'PAM Jeanne Barret')
cy.wait('@getEngagedControlUnits')

// Then
Expand All @@ -285,14 +281,13 @@ context('Side Window > Mission Form > Main Form', () => {

cy.get('*[data-cy="add-mission"]').click()

cy.fill('Début de mission (UTC)', [2024, 5, 26, 12, 0])
cy.fill('Fin de mission (UTC)', [2024, 5, 28, 14, 15])
cy.fill('Début de mission', [2024, 5, 26, 12, 0])
cy.fill('Fin de mission', [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('Jeanne{enter}')
cy.fill('Unité 1', 'PAM Jeanne Barret')
cy.wait('@getEngagedControlUnits')
cy.get('body').contains('Une autre mission, ouverte par le CACEM, est en cours avec cette unité.')

Expand All @@ -302,8 +297,7 @@ context('Side Window > Mission Form > Main Form', () => {
// we want to test with a second engaged control unit
cy.getDataCy('add-other-control-unit').should('not.be.disabled')
cy.clickButton('Ajouter une autre unité')
cy.get('*[data-cy="add-control-unit"]').last().click()
cy.get('.rs-picker-search-bar-input').last().type('DML 2A{enter}')
cy.fill('Unité 2', 'DML 2A')
cy.wait(200)
cy.get('body').contains('Une autre mission, ouverte par le CACEM, est en cours avec cette unité.')
cy.clickButton('Oui, la conserver')
Expand Down Expand Up @@ -465,7 +459,7 @@ context('Side Window > Mission Form > Main Form', () => {

// We do that manually to keep the existing "Voiture" resource which is an archived one.
cy.intercept('PUT', '/bff/v1/missions/30').as('updateMission')
cy.contains('Moyen(s) 1').parent().find('.rs-picker-toggle-caret').forceClick().wait(250)
cy.contains('Moyen(s) 1').parent().find('.rs-picker-caret-icon').forceClick().wait(250)
cy.get('span[title="Semi-rigide 1"]').forceClick().wait(250)
cy.clickOutside()
cy.wait(250)
Expand Down Expand Up @@ -515,7 +509,7 @@ context('Side Window > Mission Form > Main Form', () => {

cy.wait('@getMission')

cy.contains('Moyen(s) 1').parent().find('.rs-picker-toggle-caret').forceClick().wait(250)
cy.contains('Moyen(s) 1').parent().find('.rs-picker-caret-icon').forceClick().wait(250)
cy.get('span[title="Semi-rigide 1"]').forceClick().wait(250) // Uncheck this resource
cy.clickOutside()
cy.wait(250)
Expand Down
Loading
Loading