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

Signalements – Mettre les signalements en cours et l'historique des signalements dans le même onglet #4054

Merged
merged 3 commits into from
Jan 29, 2025
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
@@ -1,6 +1,6 @@
package fr.gouv.cnsp.monitorfish.domain.entities.reporting

data class ReportingSummary(
data class ReportingTwelveMonthsSummary(
val infractionSuspicionsSummary: List<ReportingTitleAndNumberOfOccurrences>,
val numberOfInfractionSuspicions: Int,
val numberOfObservations: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.reporting
typealias Year = Int

class VesselReportings(
val summary: ReportingSummary,
val summary: ReportingTwelveMonthsSummary,
val current: List<ReportingAndOccurrences>,
val archived: Map<Year, List<ReportingAndOccurrences>>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,26 @@ class GetVesselReportings(
}
logger.info("TIME_RECORD - 'archivedYearsToReportings' took $archivedYearsToReportingsTimeTaken")

val twelveMonthsAgo = ZonedDateTime.now().minusMonths(12)
val lastTwelveMonthsReportings = reportings.filter { reporting ->
reporting.validationDate?.isAfter(twelveMonthsAgo)
?: reporting.creationDate.isAfter(twelveMonthsAgo)
}

val (infractionSuspicionsSummary, infractionSuspicionsSummaryTimeTaken) =
measureTimedValue {
getInfractionSuspicionsSummary(reportings.filter { it.isArchived })
getInfractionSuspicionsSummary(lastTwelveMonthsReportings.filter { it.isArchived })
}
logger.info("TIME_RECORD - 'infractionSuspicionsSummary' took $infractionSuspicionsSummaryTimeTaken")

val numberOfInfractionSuspicions = infractionSuspicionsSummary.sumOf { it.numberOfOccurrences }
val numberOfObservation =
reportings
lastTwelveMonthsReportings
.filter { it.isArchived && it.type == ReportingType.OBSERVATION }
.size

val reportingSummary =
ReportingSummary(
val reportingTwelveMonthsSummary =
ReportingTwelveMonthsSummary(
infractionSuspicionsSummary = infractionSuspicionsSummary,
numberOfInfractionSuspicions = numberOfInfractionSuspicions,
numberOfObservations = numberOfObservation,
Expand All @@ -98,7 +105,7 @@ class GetVesselReportings(
return VesselReportings(
current = current,
archived = archivedYearsToReportings,
summary = reportingSummary,
summary = reportingTwelveMonthsSummary,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs

import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingSummary
import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingTwelveMonthsSummary

data class ReportingSummaryDataOutput(
val infractionSuspicionsSummary: List<ReportingTitleAndNumberOfOccurrencesDataOutput>,
val numberOfInfractionSuspicions: Int,
val numberOfObservations: Int,
) {
companion object {
fun fromReportingSummary(reportingSummary: ReportingSummary) =
fun fromReportingSummary(reportingTwelveMonthsSummary: ReportingTwelveMonthsSummary) =
ReportingSummaryDataOutput(
infractionSuspicionsSummary =
reportingSummary.infractionSuspicionsSummary.map {
reportingTwelveMonthsSummary.infractionSuspicionsSummary.map {
ReportingTitleAndNumberOfOccurrencesDataOutput.fromReportingTitleAndNumberOfOccurrences(it)
},
numberOfInfractionSuspicions = reportingSummary.numberOfInfractionSuspicions,
numberOfObservations = reportingSummary.numberOfObservations,
numberOfInfractionSuspicions = reportingTwelveMonthsSummary.numberOfInfractionSuspicions,
numberOfObservations = reportingTwelveMonthsSummary.numberOfObservations,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class GetVesselReportingsUTests {
val alertReporting1 =
createCurrentReporting(
id = 11223,
validationDate = ZonedDateTime.parse("2024-01-01T12:00:00Z"),
validationDate = ZonedDateTime.now().minusMonths(11),
internalReferenceNumber = "FR55667788",
type = ReportingType.ALERT,
alertType = AlertTypeMapping.TWELVE_MILES_FISHING_ALERT,
Expand All @@ -324,7 +324,7 @@ class GetVesselReportingsUTests {
val alertReporting2 =
createCurrentReporting(
id = 22334,
validationDate = ZonedDateTime.parse("2024-02-01T12:00:00Z"),
validationDate = ZonedDateTime.now().minusMonths(11),
internalReferenceNumber = "FR55667788",
type = ReportingType.ALERT,
alertType = AlertTypeMapping.TWELVE_MILES_FISHING_ALERT,
Expand All @@ -334,7 +334,7 @@ class GetVesselReportingsUTests {
val infractionReporting =
createCurrentReporting(
id = 33445,
validationDate = ZonedDateTime.parse("2024-03-01T12:00:00Z"),
validationDate = ZonedDateTime.now().minusMonths(10),
internalReferenceNumber = "FR55667788",
type = ReportingType.INFRACTION_SUSPICION,
alertType = null,
Expand All @@ -345,7 +345,7 @@ class GetVesselReportingsUTests {
val infractionReporting2 =
createCurrentReporting(
id = 33456,
validationDate = ZonedDateTime.parse("2024-03-01T12:00:00Z"),
validationDate = ZonedDateTime.now().minusMonths(8),
internalReferenceNumber = "FR55667788",
type = ReportingType.INFRACTION_SUSPICION,
alertType = null,
Expand All @@ -355,7 +355,7 @@ class GetVesselReportingsUTests {
val alertReporting3 =
createCurrentReporting(
id = 44556,
validationDate = ZonedDateTime.parse("2024-04-01T12:00:00Z"),
validationDate = ZonedDateTime.now().minusMonths(7),
internalReferenceNumber = "FR55667788",
type = ReportingType.ALERT,
alertType = AlertTypeMapping.MISSING_FAR_48_HOURS_ALERT,
Expand All @@ -365,7 +365,7 @@ class GetVesselReportingsUTests {
val observation =
createCurrentReporting(
id = 44558,
validationDate = ZonedDateTime.parse("2024-04-01T12:00:00Z"),
validationDate = ZonedDateTime.now().minusMonths(4),
internalReferenceNumber = "FR55667788",
type = ReportingType.OBSERVATION,
alertType = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ class VesselControllerITests {
).willReturn(
VesselReportings(
summary =
ReportingSummary(
ReportingTwelveMonthsSummary(
infractionSuspicionsSummary =
listOf(
ReportingTitleAndNumberOfOccurrences(
Expand Down Expand Up @@ -868,7 +868,7 @@ class VesselControllerITests {
).willReturn(
VesselReportings(
summary =
ReportingSummary(
ReportingTwelveMonthsSummary(
infractionSuspicionsSummary = listOf(),
numberOfInfractionSuspicions = 0,
numberOfObservations = 0,
Expand Down
28 changes: 13 additions & 15 deletions frontend/cypress/e2e/main_window/vessel_sidebar/reporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ context('Vessel sidebar reporting tab', () => {
cy.get('*[data-cy="side-window-reporting-tab"]').click()
cy.get('[data-cy="side-window-sub-menu-NAMO"]').click()
cy.wait(200)
cy.get('*[data-cy="ReportingList-reporting"]').first().contains('FRAIS AVIS MODE')
cy.get('*[data-cy="ReportingTable-reporting"]').first().contains('FRAIS AVIS MODE')

// Archive the newly created reporting
cy.get('table .rs-checkbox-wrapper').eq(1).click({ force: true })
cy.clickButton('Archiver 1 signalement')
cy.clickButton('Archiver')
})

it('An observation reporting should be modified to an Infraction suspicion', () => {
Expand Down Expand Up @@ -91,7 +92,7 @@ context('Vessel sidebar reporting tab', () => {
cy.intercept('PUT', `/bff/v1/reportings/${createdPriorNotification.id}`).as('updateReporting')
cy.get('*[data-cy="reporting-card"]').first().contains('Fin de validité le 08/06/2166')

cy.get('*[data-cy^="edit-reporting-card"]').first().click({ timeout: 10000 })
cy.get('*[data-cy^="edit-reporting-card"]').first().scrollIntoView().click({ timeout: 10000 })
cy.fill('Type de signalement', 'Infraction (suspicion)')
cy.fill('Natinf', '7059')
const nextDate = getUtcDateInMultipleFormats('2200-06-08T13:54')
Expand All @@ -102,7 +103,7 @@ context('Vessel sidebar reporting tab', () => {

cy.get('*[data-cy="reporting-card"]').first().contains('NATINF 7059')
cy.get('*[data-cy="reporting-card"]').first().contains('Fin de validité le 08/06/2200')
cy.get('*[data-cy="delete-reporting-card"]').eq(0).click()
cy.get('*[data-cy="delete-reporting-card"]').eq(0).scrollIntoView().click()
// Then, we confirm the reporting deletion
cy.clickButton('Supprimer')
})
Expand Down Expand Up @@ -130,9 +131,8 @@ context('Vessel sidebar reporting tab', () => {

// Then
cy.get('*[data-cy="reporting-card"]').should('not.exist')
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history-button"]').click()
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history"]').should('exist')
cy.get('*[data-cy="vessel-sidebar-reporting-tab-archive-year"]').eq(0).click()
cy.get('*[data-cy="vessel-sidebar-archived-reporting"]').should('exist')
cy.get('*[data-cy="vessel-sidebar-reporting-archive-year"]').eq(0).click()
cy.get('*[data-cy="reporting-card"]').eq(0).contains('OFB SD 56 / Sortie non autorisée')
cy.get('*[data-cy^="vessel-search-selected-vessel-close-title"]', { timeout: 10000 }).click()
})
Expand All @@ -154,12 +154,11 @@ context('Vessel sidebar reporting tab', () => {

addAndCreateReportingWithinVesselSidebar()
cy.get('[data-cy="archive-reporting-card"]').eq(0).click()
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history-button"]').click()
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history"]').should('exist')
cy.get('*[data-cy="vessel-sidebar-archived-reporting"]').should('exist')

// Then
// Summary
cy.get('[data-cy="vessel-reporting-summary"]').contains('Résumé des derniers signalements (6 dernières années)')
cy.get('[data-cy="vessel-reporting-summary"]').contains('Résumé des derniers signalements (12 derniers mois)')
cy.get('[data-cy="vessel-reporting-summary"]').contains('Signalement "3 milles - Chaluts (NATINF 7059)"')
cy.get('[data-cy="vessel-reporting-summary"]').contains(
"Peche maritime non autorisee dans les eaux maritimes ou salees francaises par un navire de pays tiers a l'union europeenne (NATINF 2608)"
Expand All @@ -181,14 +180,13 @@ context('Vessel sidebar reporting tab', () => {
cy.wait(100)

// When
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history-button"]').click()
cy.get('*[data-cy="vessel-sidebar-reporting-tab-history"]').should('exist')
cy.get('*[data-cy="vessel-sidebar-reporting-tab-archive-year"]').should('have.length', 6)
cy.get('*[data-cy="vessel-sidebar-archived-reporting"]').should('exist')
cy.get('*[data-cy="vessel-sidebar-reporting-archive-year"]').should('have.length', 4)
cy.clickButton('Afficher plus de signalements')

// Then
cy.wait('@getVesselReportings')
cy.get('*[data-cy="vessel-sidebar-reporting-tab-archive-year"]').should('have.length', 7)
cy.get('*[data-cy="vessel-sidebar-reporting-archive-year"]').should('have.length', 5)
})

it('Reporting Should be deleted', () => {
Expand All @@ -209,10 +207,10 @@ context('Vessel sidebar reporting tab', () => {
// When
cy.get('*[data-cy="vessel-menu-reporting"]').contains(1)
cy.get('*[data-cy="reporting-card"]').eq(0).contains('OFB SD 56 / Sortie non autorisée')
cy.get('*[data-cy="delete-reporting-card"]').eq(0).click()
cy.get('*[data-cy="delete-reporting-card"]').eq(0).scrollIntoView().click()
// First, we do not confirm the reporting deletion
cy.clickButton('Annuler', { withinSelector: '.Component-Dialog' })
cy.get('*[data-cy="delete-reporting-card"]').eq(0).click()
cy.get('*[data-cy="delete-reporting-card"]').eq(0).scrollIntoView().click()
// Then, we confirm the reporting deletion
cy.clickButton('Supprimer')

Expand Down
16 changes: 8 additions & 8 deletions frontend/cypress/e2e/side_window/reporting_list/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ context('Side Window > Reporting List > Actions', () => {
cy.getDataCy('side-window-sub-menu-NAMO').click()
cy.fill('Observations', false)

cy.getDataCy('ReportingList-reporting').then($reportingRows => {
cy.getDataCy('ReportingTable-reporting').then($reportingRows => {
const numberOfReportings = $reportingRows.length

// When
Expand All @@ -31,7 +31,7 @@ context('Side Window > Reporting List > Actions', () => {
// Then
assert.deepEqual(archiveInterception.request.body, [createdReportingId])

cy.getDataCy('ReportingList-reporting').should('have.length', numberOfReportings - 1)
cy.getDataCy('ReportingTable-reporting').should('have.length', numberOfReportings - 1)
})
})
})
Expand All @@ -47,7 +47,7 @@ context('Side Window > Reporting List > Actions', () => {
cy.getDataCy('side-window-sub-menu-NAMO').click()
cy.fill('Observations', false)

cy.getDataCy('ReportingList-reporting').then($reportingRows => {
cy.getDataCy('ReportingTable-reporting').then($reportingRows => {
const numberOfReportings = $reportingRows.length

// When
Expand All @@ -63,13 +63,13 @@ context('Side Window > Reporting List > Actions', () => {
// Then
assert.deepEqual(archiveInterception.request.body, [createdReportingId])

cy.getDataCy('ReportingList-reporting').should('have.length', numberOfReportings - 1)
cy.getDataCy('ReportingTable-reporting').should('have.length', numberOfReportings - 1)
})
})
})
})

it('A Reporting Should be edited', () => {
it.only('A Reporting Should be edited', () => {
cy.intercept('PUT', 'bff/v1/reportings/7').as('updateReporting')

// Given
Expand All @@ -95,15 +95,15 @@ context('Side Window > Reporting List > Actions', () => {
})
cy.wait(200)

cy.getDataCy('ReportingList-reporting').should('have.length.greaterThan', 1)
cy.getDataCy('ReportingTable-reporting').should('have.length.greaterThan', 1)
cy.get('tr:contains("COURANT MAIN PROFESSEUR")').contains('DML 56')
cy.get('tr:contains("COURANT MAIN PROFESSEUR")').contains(23581)

/**
* The reporting type must be modified to OBSERVATION
*/

cy.getDataCy('ReportingList-reporting').then($reportingRows => {
cy.getDataCy('ReportingTable-reporting').then($reportingRows => {
const numberOfReportings = $reportingRows.length

cy.clickButton('Editer le signalement', {
Expand All @@ -121,7 +121,7 @@ context('Side Window > Reporting List > Actions', () => {
expect(request.body.authorTrigram).contains('LTH')
expect(response && response.statusCode).equal(200)

cy.getDataCy('ReportingList-reporting').should('have.length', numberOfReportings)
cy.getDataCy('ReportingTable-reporting').should('have.length', numberOfReportings)
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,15 @@ export function VesselLogbook() {
}

const NoFishingActivities = styled.div`
padding: 50px 5px 0px 5px;
padding: 50px 5px 0 5px;
margin: 10px 10px;
height: 70px;
background: ${p => p.theme.color.white};
color: ${p => p.theme.color.slateGray};
text-align: center;
`

const Wrapper = styled.div`
overflow-x: hidden;
max-height: 700px;
`
const Wrapper = styled.div``

const UpdateFishingActivities = styled.div`
background: ${p => p.theme.color.white};
Expand All @@ -126,7 +123,7 @@ const UpdateFishingActivities = styled.div`
width: -moz-available;
width: -webkit-fill-available;
height: 55px;
box-shadow: -10px 5px 7px 0px rgba(81, 81, 81, 0.2);
box-shadow: -10px 5px 7px 0 rgba(81, 81, 81, 0.2);
z-index: 9;
`

Expand Down
Loading
Loading