Skip to content

Commit

Permalink
Préavis – Consulter le détail des signalements à partir des tags sign…
Browse files Browse the repository at this point in the history
…alements de la liste (#3813)

## Linked issues

- Resolve #2868
- Resolve #3386
- Resolve #3772
- Resolve #3762
- Resolve #3386

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
ivangabriele authored Nov 11, 2024
2 parents abb3534 + 5b21b3f commit c2183c2
Show file tree
Hide file tree
Showing 67 changed files with 886 additions and 785 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data class ManualPriorNotificationDraftDataOutput(
val sentAt: ZonedDateTime?,
val purpose: LogbookMessagePurpose?,
val tripGearCodes: List<String>,
val vesselId: Int?,
val vesselIdentity: VesselIdentityDataOutput,
) {
companion object {
/**
Expand All @@ -42,8 +42,8 @@ data class ManualPriorNotificationDraftDataOutput(
.map { tripGear -> requireNotNull(tripGear.gear) { "`it.gear` is null." } }
} ?: emptyList()

val hasPortEntranceAuthorization = pnoValue.hasPortEntranceAuthorization ?: true
val hasPortLandingAuthorization = pnoValue.hasPortLandingAuthorization ?: true
val hasPortEntranceAuthorization = pnoValue.hasPortEntranceAuthorization != false
val hasPortLandingAuthorization = pnoValue.hasPortLandingAuthorization != false
// In Frontend form, manual prior notifications can:
// - either have a single global FAO area field
// - or have an FAO area field per fishing catch
Expand All @@ -65,6 +65,12 @@ data class ManualPriorNotificationDraftDataOutput(
!hasGlobalFaoArea,
)
}
val vesselIdentity =
VesselIdentityDataOutput.fromVessel(
requireNotNull(priorNotification.vessel) {
"`priorNotification.vessel` is null."
},
)

return ManualPriorNotificationDraftDataOutput(
authorTrigram = pnoValue.authorTrigram,
Expand All @@ -80,7 +86,7 @@ data class ManualPriorNotificationDraftDataOutput(
sentAt = priorNotification.sentAt,
purpose = pnoValue.purpose,
tripGearCodes = tripGearCodes,
vesselId = priorNotification.vessel?.id,
vesselIdentity = vesselIdentity,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ data class ManualPriorNotificationFormDataOutput(
val purpose: LogbookMessagePurpose,
val tripGearCodes: List<String>,
val updatedAt: String,
val vesselId: Int,
val vesselIdentity: VesselIdentityDataOutput,
) {
companion object {
fun fromPriorNotification(priorNotification: PriorNotification): ManualPriorNotificationFormDataOutput {
Expand Down Expand Up @@ -55,10 +55,9 @@ data class ManualPriorNotificationFormDataOutput(
) { "`priorNotification.updatedAt` is null." }.withZoneSameInstant(
ZoneOffset.UTC,
).toString()
val vesselId =
requireNotNull(priorNotification.vessel) {
"`priorNotification.vessel` is null."
}.id
requireNotNull(priorNotification.vessel) {
"`priorNotification.vessel` is null."
}.id

val hasPortEntranceAuthorization = pnoValue.hasPortEntranceAuthorization ?: true
val hasPortLandingAuthorization = pnoValue.hasPortLandingAuthorization ?: true
Expand All @@ -78,6 +77,12 @@ data class ManualPriorNotificationFormDataOutput(
pnoValue.catchOnboard.map {
ManualPriorNotificationFishingCatchDataOutput.fromLogbookFishingCatch(it, !hasGlobalFaoArea)
}
val vesselIdentity =
VesselIdentityDataOutput.fromVessel(
requireNotNull(priorNotification.vessel) {
"`priorNotification.vessel` is null."
},
)

return ManualPriorNotificationFormDataOutput(
reportId = reportId,
Expand All @@ -94,7 +99,7 @@ data class ManualPriorNotificationFormDataOutput(
purpose = purpose,
tripGearCodes = tripGearCodes,
updatedAt = updatedAt,
vesselId = vesselId,
vesselIdentity = vesselIdentity,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,47 @@ import fr.gouv.cnsp.monitorfish.domain.entities.vessel.Vessel
import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselAndBeacon

data class VesselIdentityDataOutput(
val internalReferenceNumber: String? = null,
val beaconNumber: String? = null,
val districtCode: String? = null,
val vesselId: Int,
val externalReferenceNumber: String? = null,
val flagState: CountryCode,
val imo: String? = null,
val mmsi: String? = null,
val internalReferenceNumber: String? = null,
val ircs: String? = null,
val externalReferenceNumber: String? = null,
val mmsi: String? = null,
val vesselId: Int,
val vesselLength: Double? = null,
val vesselName: String? = null,
val flagState: CountryCode,
val beaconNumber: String? = null,
) {
companion object {
fun fromVessel(vessel: Vessel): VesselIdentityDataOutput {
return VesselIdentityDataOutput(
internalReferenceNumber = vessel.internalReferenceNumber,
districtCode = vessel.districtCode,
vesselId = vessel.id,
externalReferenceNumber = vessel.externalReferenceNumber,
flagState = vessel.flagState,
imo = vessel.imo,
internalReferenceNumber = vessel.internalReferenceNumber,
ircs = vessel.ircs,
mmsi = vessel.mmsi,
externalReferenceNumber = vessel.externalReferenceNumber,
vesselId = vessel.id,
vesselLength = vessel.length,
vesselName = vessel.vesselName,
flagState = vessel.flagState,
)
}

fun fromVesselAndBeacon(vesselAndBeacon: VesselAndBeacon): VesselIdentityDataOutput {
return VesselIdentityDataOutput(
internalReferenceNumber = vesselAndBeacon.vessel.internalReferenceNumber,
beaconNumber = vesselAndBeacon.beacon?.beaconNumber,
districtCode = vesselAndBeacon.vessel.districtCode,
vesselId = vesselAndBeacon.vessel.id,
externalReferenceNumber = vesselAndBeacon.vessel.externalReferenceNumber,
flagState = vesselAndBeacon.vessel.flagState,
imo = vesselAndBeacon.vessel.imo,
internalReferenceNumber = vesselAndBeacon.vessel.internalReferenceNumber,
ircs = vesselAndBeacon.vessel.ircs,
mmsi = vesselAndBeacon.vessel.mmsi,
externalReferenceNumber = vesselAndBeacon.vessel.externalReferenceNumber,
vesselId = vesselAndBeacon.vessel.id,
vesselLength = vesselAndBeacon.vessel.length,
vesselName = vesselAndBeacon.vessel.vesselName,
flagState = vesselAndBeacon.vessel.flagState,
beaconNumber = vesselAndBeacon.beacon?.beaconNumber,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ context('Side Window > Logbook Prior Notification Card > Card', () => {
openSideWindowPriorNotificationCardAsUser(`L'ANCRE`, 'FAKE_OPERATION_109_COR')

// Title
cy.contains(`Préavis navire < 12 M`).should('be.visible')
cy.contains(`PRÉAVIS NAVIRE < 12 M`).should('be.visible')
cy.contains(`L'ANCRE SÈCHE (CFR106)`).should('be.visible')

// Message Header
Expand All @@ -26,7 +26,7 @@ context('Side Window > Logbook Prior Notification Card > Card', () => {
openSideWindowPriorNotificationCardAsUser(`BARS`, 'FAKE_OPERATION_107')

// Title
cy.contains(`Préavis navire ≥ 12 M`).should('be.visible')
cy.contains(`PRÉAVIS NAVIRE ≥ 12 M`).should('be.visible')
cy.contains(`DES BARS (CFR104)`).should('be.visible')

// Message Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ context('Side Window > Logbook Prior Notification Form > Form', () => {
cy.wait('@getPriorNotification')

cy.contains('AJOUTER UN NOUVEAU PRÉAVIS').should('be.visible')
cy.getDataCy('vessel-search-input').should('have.value', "LE POISSON D'AVRIL")
cy.getDataCy('VesselSearch-input').should('have.value', "LE POISSON D'AVRIL")
cy.getDataCy('ManualPriorNotificationForm-Body').contains('Débarquement').should('be.visible')
cy.getDataCy('ManualPriorNotificationForm-Body').contains('Vannes (FRVNE)').should('be.visible')
cy.getDataCy('ManualPriorNotificationForm-Body').contains('27.7.d').should('be.visible')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ export function getPriorNotificationFakeResponse({
internalReferenceNumber: 'CFR121',
ircs: 'IRCS121',
mmsi: 'MMSI121',
vesselId: null,
vesselIdentifier: null,
vesselLength: null,
vesselName: null
}
}
Expand All @@ -294,7 +296,19 @@ export function getPriorNotificationFakeResponse({
purpose: PriorNotification.PurposeCode.LAN,
sentAt: updatedAt,
tripGearCodes: ['OTT'],
vesselId: 121
vesselIdentity: {
beaconNumber: null,
districtCode: null,
externalReferenceNumber: 'EXTIMM121',
flagState: 'FRA',
internalReferenceNumber: 'CFR121',
ircs: 'IRCS121',
mmsi: 'MMSI121',
vesselId: 121,
vesselIdentifier: null,
vesselLength: null,
vesselName: null
}
},
asManualForm: null,
isManuallyCreated: false
Expand Down Expand Up @@ -322,7 +336,19 @@ export function getPriorNotificationFakeResponse({
sentAt: createdAt,
tripGearCodes: ['OTT'],
updatedAt,
vesselId: 121
vesselIdentity: {
beaconNumber: null,
districtCode: null,
externalReferenceNumber: 'EXTIMM121',
flagState: 'FRA',
internalReferenceNumber: 'CFR121',
ircs: 'IRCS121',
mmsi: 'MMSI121',
vesselId: 121,
vesselIdentifier: null,
vesselLength: null,
vesselName: null
}
},
isManuallyCreated: true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ context('Side Window > Manual Prior Notification Card > Card', () => {
openSideWindowPriorNotificationCardAsUser(`POISSON PAS NET`, '00000000-0000-4000-0000-000000000001')

// Title
cy.contains(`Préavis navire < 12 M`).should('be.visible')
cy.contains(`PRÉAVIS NAVIRE < 12 M`).should('be.visible')
cy.contains(`POISSON PAS NET (CFR112)`).should('be.visible')

// Message Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ context('Side Window > Manual Prior Notification Form > Behavior', () => {

addManualSideWindowPriorNotification()

cy.getDataCy('vessel-search-input').click().wait(500)
cy.getDataCy('vessel-search-input').type('PAGEOT JO', { delay: 100 })
cy.getDataCy('vessel-search-item').first().click()
cy.getDataCy('VesselSearch-input').type('PAGEOT JO')
cy.getDataCy('VesselSearch-item').first().click()
cy.wait(500)

cy.clickButton('Fermer')
Expand All @@ -50,7 +49,7 @@ context('Side Window > Manual Prior Notification Form > Behavior', () => {
cy.clickButton('Préavis de débarquement')
cy.contains('Tous les préavis').should('be.visible')
cy.contains('AJOUTER UN NOUVEAU PRÉAVIS').should('be.visible')
cy.getDataCy('vessel-search-input').should('have.value', 'PAGEOT JO')
cy.getDataCy('VesselSearch-input').should('have.value', 'PAGEOT JO')

cy.clickButton('Fermer')
cy.contains('Abandon de préavis').should('be.visible')
Expand Down Expand Up @@ -180,9 +179,8 @@ context('Side Window > Manual Prior Notification Form > Behavior', () => {

addManualSideWindowPriorNotification()

cy.getDataCy('vessel-search-input').click().wait(500)
cy.getDataCy('vessel-search-input').type('PHENO', { delay: 100 })
cy.getDataCy('vessel-search-item').first().click()
cy.getDataCy('VesselSearch-input').type('PHENOMENE')
cy.getDataCy('VesselSearch-item').first().click()

cy.fill("Date et heure estimées d'arrivée au port (UTC)", arrivalDateTupleWithTime)
cy.fill("équivalentes à celles de l'arrivée au port", true)
Expand Down Expand Up @@ -474,9 +472,8 @@ context('Side Window > Manual Prior Notification Form > Behavior', () => {

addManualSideWindowPriorNotification()

cy.getDataCy('vessel-search-input').click().wait(500)
cy.getDataCy('vessel-search-input').type('PHENO', { delay: 100 })
cy.getDataCy('vessel-search-item').first().click()
cy.getDataCy('VesselSearch-input').type('PHENOMENE')
cy.getDataCy('VesselSearch-item').first().click()

cy.fill("Date et heure estimées d'arrivée au port (UTC)", arrivalDateTupleWithTime)
cy.fill("équivalentes à celles de l'arrivée au port", true)
Expand Down
Loading

0 comments on commit c2183c2

Please sign in to comment.