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

[Missions] Rafraichissement & Enregistrement automatique (UPDATE ENV VAR) #2720

Merged
merged 34 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
41b8df6
Add SSE updates of missions in mission form
louptheron Nov 15, 2023
2b1164f
Test another SSE url
louptheron Nov 16, 2023
6d76d56
Log SSE URL
louptheron Nov 16, 2023
b6caa27
Add another logger
louptheron Nov 16, 2023
e2f0b37
Remove .only
louptheron Nov 16, 2023
8c48710
improve logging
louptheron Nov 16, 2023
696bd02
improve logging
louptheron Nov 16, 2023
685bb87
Use a global SSE channel
louptheron Nov 20, 2023
a9cda82
Fix sse cypress url
louptheron Nov 20, 2023
9e169b1
Modify api file after rebase
louptheron Nov 23, 2023
9a2c975
wip: add auto-save on mission form
louptheron Nov 23, 2023
840419d
wip: remove mission draft slice
louptheron Dec 5, 2023
c61f121
wip: use diff to auto-refresh
louptheron Dec 6, 2023
06e1165
Add working auto-save and fix few cypress tests
louptheron Dec 8, 2023
276ac64
Fix ts types
louptheron Dec 11, 2023
0b7e7af
wip: re-add draft state
louptheron Dec 12, 2023
e353a0c
Fix few cypress tests
louptheron Dec 13, 2023
df3f116
Fix cypress tests
louptheron Dec 13, 2023
7a04e9b
Remove remaining rtk-query cache getter
louptheron Dec 13, 2023
2c2ba52
Fix cypress test because of update request
louptheron Dec 14, 2023
2104f3b
Fix SSE url in remote
louptheron Dec 14, 2023
8758334
Fix few cypress tests
louptheron Dec 15, 2023
c1de03e
Stub mission actions in cypress test
louptheron Dec 15, 2023
0f3260e
Add more wait in cypress tests
louptheron Dec 15, 2023
36ba107
Remove param
louptheron Dec 15, 2023
55980c2
Increment cy.wait
louptheron Dec 18, 2023
3bfbd09
Add mission auto-update feature flag
louptheron Dec 18, 2023
f8663b6
Add comment of usage of window.Cypress
louptheron Dec 18, 2023
ea6f931
Apply linter
louptheron Dec 18, 2023
76e2ac5
Fix control overlay test coordinates
louptheron Dec 18, 2023
6fb535d
Apply linter
louptheron Dec 18, 2023
ac9ceb6
Set isDirty when the form is not in auto save
louptheron Dec 18, 2023
7daf482
Disable auto svae when mission is closed
louptheron Dec 18, 2023
bd480f2
FIx import of customDayjs
louptheron Dec 22, 2023
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
1 change: 1 addition & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ FRONTEND_OIDC_REDIRECT_URI=
FRONTEND_SENTRY_DSN=
FRONTEND_SHOM_KEY=
VITE_SMALL_CHAT_SNIPPET=
FRONTEND_MISSION_AUTO_SAVE_ENABLED=
1 change: 1 addition & 0 deletions frontend/config/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default defineConfig({
specPattern: 'cypress/e2e/**/*.spec.ts'
},
env: {
FRONTEND_MISSION_AUTO_SAVE_ENABLED: true,
'cypress-plugin-snapshots': {
imageConfig: {
threshold: 20,
Expand Down
1 change: 1 addition & 0 deletions frontend/cypress/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ services:
- FRONTEND_SENTRY_DSN=https://a5f3272efa794bb9ada2ffea90f2fec5@sentry.incubateur.net/8
- FRONTEND_SHOM_KEY=rg8ele7cft4ujkwjspsmtwas
- VITE_SMALL_CHAT_SNIPPET=
- FRONTEND_MISSION_AUTO_SAVE_ENABLED=true
ports:
- 8880:8880
- 8000:8000
Expand Down
117 changes: 54 additions & 63 deletions frontend/cypress/e2e/side_window/mission_form/action_list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,63 +24,60 @@ context('Side Window > Mission Form > Action List', () => {

cy.wait(250)

cy.clickButton('Enregistrer et quitter')

cy.wait('@createMissionAction').then(interception => {
if (!interception.response) {
assert.fail('`interception.response` is undefined.')
}

assert.isString(interception.request.body.actionDatetimeUtc)
assert.deepInclude(interception.request.body, {
actionType: 'SEA_CONTROL',
closedBy: null,
controlQualityComments: null,
controlUnits: [],
emitsAis: null,
emitsVms: 'NOT_APPLICABLE',
externalReferenceNumber: null,
facade: 'MEMN',
faoAreas: ['27.8.a'],
feedbackSheetRequired: false,
flagState: 'FR',
flightGoals: [],
gearInfractions: [],
gearOnboard: [],
hasSomeGearsSeized: false,
hasSomeSpeciesSeized: false,
id: null,
internalReferenceNumber: 'U_W0NTFINDME',
ircs: null,
latitude: 53.35,
licencesAndLogbookObservations: null,
licencesMatchActivity: 'NOT_APPLICABLE',
logbookInfractions: [],
logbookMatchesActivity: 'NOT_APPLICABLE',
longitude: -10.85,
missionId: 4,
numberOfVesselsFlownOver: null,
otherComments: 'Commentaires post contrôle',
otherInfractions: [],
portLocode: null,
segments: [],
seizureAndDiversion: false,
seizureAndDiversionComments: null,
separateStowageOfPreservedSpecies: 'NO',
speciesInfractions: [],
speciesObservations: null,
speciesOnboard: [],
speciesSizeControlled: null,
speciesWeightControlled: null,
unitWithoutOmegaGauge: false,
userTrigram: 'JKL',
vesselId: 2,
vesselName: 'MALOTRU',
vesselTargeted: 'YES'
})
})

cy.get('h1').should('contain.text', 'Missions et contrôles')
cy.waitForLastRequest(
'@createMissionAction',
{
body: {
actionType: 'SEA_CONTROL',
closedBy: null,
controlQualityComments: null,
controlUnits: [],
emitsAis: null,
emitsVms: 'NOT_APPLICABLE',
externalReferenceNumber: null,
facade: 'MEMN',
faoAreas: ['27.8.a'],
feedbackSheetRequired: false,
flagState: 'FR',
flightGoals: [],
gearInfractions: [],
gearOnboard: [],
hasSomeGearsSeized: false,
hasSomeSpeciesSeized: false,
id: null,
internalReferenceNumber: 'U_W0NTFINDME',
ircs: null,
latitude: 53.35,
licencesAndLogbookObservations: null,
licencesMatchActivity: 'NOT_APPLICABLE',
logbookInfractions: [],
logbookMatchesActivity: 'NOT_APPLICABLE',
longitude: -10.85,
missionId: 4,
numberOfVesselsFlownOver: null,
otherComments: 'Commentaires post contrôle',
otherInfractions: [],
portLocode: null,
segments: [],
seizureAndDiversion: false,
seizureAndDiversionComments: null,
separateStowageOfPreservedSpecies: 'NO',
speciesInfractions: [],
speciesObservations: null,
speciesOnboard: [],
speciesSizeControlled: null,
speciesWeightControlled: null,
unitWithoutOmegaGauge: false,
userTrigram: 'JKL',
vesselId: 2,
vesselName: 'MALOTRU',
vesselTargeted: 'YES'
}
},
5
)
.its('response.statusCode')
.should('eq', 201)

// And we delete this action

Expand All @@ -89,8 +86,6 @@ context('Side Window > Mission Form > Action List', () => {
cy.clickButton('Supprimer l’action', { index: 1 })

cy.wait(250)

cy.clickButton('Enregistrer et quitter')
})

it('Should send the expected data to the API when deleting a mission action', () => {
Expand All @@ -115,17 +110,13 @@ context('Side Window > Mission Form > Action List', () => {

cy.wait(250)

cy.clickButton('Enregistrer et quitter')

cy.wait('@deleteMissionAction9').then(interception => {
if (!interception.response) {
assert.fail('`interception.response` is undefined.')
}

assert.isEmpty(interception.request.body)
})

cy.get('h1').should('contain.text', 'Missions et contrôles')
})

it('Should show the expected infraction tags', () => {
Expand Down
146 changes: 67 additions & 79 deletions frontend/cypress/e2e/side_window/mission_form/air_control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ context('Side Window > Mission Form > Air Control', () => {

it('Should fill the form and send the expected data to the API', () => {
const now = getUtcDateInMultipleFormats()
cy.intercept('POST', '/bff/v1/mission_actions').as('createMissionAction')
cy.intercept('PUT', '/bff/v1/mission_actions/2', {
body: {
id: 1
},
statusCode: 201
}).as('updateMissionAction')

// -------------------------------------------------------------------------
// Form
Expand Down Expand Up @@ -51,70 +58,63 @@ context('Side Window > Mission Form > Air Control', () => {
// -------------------------------------------------------------------------
// Request

cy.intercept('POST', '/bff/v1/mission_actions').as('createMissionAction')

cy.clickButton('Enregistrer et quitter')

cy.wait('@createMissionAction').then(interception => {
if (!interception.response) {
assert.fail('`interception.response` is undefined.')
}

assert.include(interception.request.body.actionDatetimeUtc, now.utcDateAsShortString)
assert.deepInclude(interception.request.body, {
// actionDatetimeUtc: '2023-02-20T10:38:49.095Z',
actionType: 'AIR_CONTROL',
closedBy: 'Alice',
controlQualityComments: null,
controlUnits: [],
districtCode: 'AY',
emitsAis: null,
emitsVms: null,
externalReferenceNumber: 'DONTSINK',
facade: null,
feedbackSheetRequired: null,
flagState: 'FR',
gearInfractions: [],
gearOnboard: [],
id: null,
internalReferenceNumber: 'FAK000999999',
ircs: 'CALLME',
latitude: 47.084,
licencesAndLogbookObservations: null,
licencesMatchActivity: null,
logbookInfractions: [],
logbookMatchesActivity: null,
longitude: -3.872,
missionId: 1,
numberOfVesselsFlownOver: null,
otherComments: 'Une autre observation.',
otherInfractions: [
{ comments: 'Une observation sur l’infraction.', infractionType: 'WITH_RECORD', natinf: 23581 }
],
portLocode: null,
segments: [],
seizureAndDiversion: null,
seizureAndDiversionComments: null,
separateStowageOfPreservedSpecies: null,
speciesInfractions: [],
speciesObservations: null,
speciesOnboard: [],
speciesSizeControlled: null,
speciesWeightControlled: null,
unitWithoutOmegaGauge: null,
userTrigram: 'Marlin',
vesselId: 1,
vesselName: 'PHENOMENE',
vesselTargeted: null
})

cy.get('h1').should('contain.text', 'Missions et contrôles')
})
cy.waitForLastRequest(
'@updateMissionAction',
{
body: {
actionType: 'AIR_CONTROL',
closedBy: 'Alice',
controlQualityComments: null,
controlUnits: [],
districtCode: 'AY',
emitsAis: null,
emitsVms: null,
externalReferenceNumber: 'DONTSINK',
facade: null,
feedbackSheetRequired: null,
flagState: 'FR',
gearInfractions: [],
gearOnboard: [],
id: 2,
internalReferenceNumber: 'FAK000999999',
ircs: 'CALLME',
latitude: 47.084,
licencesAndLogbookObservations: null,
licencesMatchActivity: null,
logbookInfractions: [],
logbookMatchesActivity: null,
longitude: -3.872,
missionId: 1,
numberOfVesselsFlownOver: null,
otherComments: 'Une autre observation.',
otherInfractions: [
{ comments: 'Une observation sur l’infraction.', infractionType: 'WITH_RECORD', natinf: 23581 }
],
portLocode: null,
segments: [],
seizureAndDiversion: null,
seizureAndDiversionComments: null,
separateStowageOfPreservedSpecies: null,
speciesInfractions: [],
speciesObservations: null,
speciesOnboard: [],
speciesSizeControlled: null,
speciesWeightControlled: null,
unitWithoutOmegaGauge: null,
userTrigram: 'Marlin',
vesselId: 1,
vesselName: 'PHENOMENE',
vesselTargeted: null
}
},
5
)
.its('response.statusCode')
.should('eq', 201)
})

it('Should only close mission once the form closure validation has passed', () => {
const getSaveButton = () => cy.get('button').contains('Enregistrer et quitter').parent()
const getSaveAndCloseButton = () => cy.get('button').contains('Enregistrer et clôturer').parent()
const getCloseButton = () => cy.get('button').contains('Clôturer').parent()

// -------------------------------------------------------------------------
// Form Live Validation
Expand All @@ -124,8 +124,7 @@ context('Side Window > Mission Form > Air Control', () => {
cy.contains('Veuillez indiquer votre trigramme dans "Saisi par".').should('exist')

cy.contains('Veuillez corriger les éléments en rouge').should('exist')
getSaveButton().should('be.disabled')
getSaveAndCloseButton().should('be.disabled')
getCloseButton().should('be.disabled')

// Navire
cy.get('input[placeholder="Rechercher un navire..."]').type('mal')
Expand All @@ -140,16 +139,16 @@ context('Side Window > Mission Form > Air Control', () => {
cy.contains('Veuillez compléter les champs manquants dans cette action de contrôle.').should('not.exist')

cy.contains('Veuillez corriger les éléments en rouge').should('not.exist')
getSaveButton().should('be.enabled')
getSaveAndCloseButton().should('be.enabled')
getCloseButton().should('be.enabled')

cy.clickButton('Enregistrer et clôturer').wait(500)
cy.clickButton('Clôturer').wait(500)

// -------------------------------------------------------------------------
// Form Closure Validation

cy.contains('Veuillez compléter les champs manquants dans cette action de contrôle.').should('exist')
cy.contains('Veuillez indiquer votre trigramme dans "Clôturé par".').should('exist')
cy.contains('Ré-ouvrir la mission').should('not.exist')

// Clôturé par
// TODO Handle multiple inputs with same label via an `index` in monitor-ui.
Expand All @@ -159,20 +158,9 @@ context('Side Window > Mission Form > Air Control', () => {
// Mission is now valid for closure
cy.contains('Veuillez compléter les champs manquants dans cette action de contrôle.').should('not.exist')
cy.contains('Veuillez corriger les éléments en rouge').should('not.exist')
getSaveButton().should('be.enabled')
getSaveAndCloseButton().should('be.enabled')

cy.clickButton('Enregistrer et clôturer')

// -------------------------------------------------------------------------
// Request

cy.intercept('POST', '/bff/v1/mission_actions', {
body: {
id: 1
},
statusCode: 201
}).as('createMissionAction')
cy.wait(500)
cy.clickButton('Clôturer')

cy.get('h1').should('contain.text', 'Missions et contrôles')
})
Expand Down
Loading
Loading