Skip to content

Commit

Permalink
[Avaries VMS] Correction de bugs mineurs (#2497)
Browse files Browse the repository at this point in the history
## Linked issues

- Resolve #2401
- Resove #2402

### Backoffice - segments de flottes

- Resolve #2486
- Resolve #2487

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
louptheron committed Sep 15, 2023
2 parents b729ed5 + e84a944 commit 112b506
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { expect } from '@jest/globals'

import { BeaconMalfunctionVesselStatus, EndOfBeaconMalfunctionReason } from '../constants'
import { getMalfunctionStartDateText } from '../index'

describe('domain/entities/beaconMalfunction/index.getMalfunctionStartDateText()', () => {
it('should return the right status', () => {
const beaconMalfunction = {
beaconNumber: 'NOT_FOUND',
endOfBeaconMalfunctionReason: EndOfBeaconMalfunctionReason.BEACON_DEACTIVATED_OR_UNEQUIPPED,
externalReferenceNumber: '08FR65465',
flagState: 'FR',
id: 5,
internalReferenceNumber: 'FR263465414',
ircs: 'IR123',
malfunctionEndDateTime: null,
malfunctionStartDateTime: '2023-08-21T11:17:22.997231Z',
notificationRequested: null,
riskFactor: null,
stage: 'ARCHIVED',
vesselId: 12,
vesselIdentifier: 'EXTERNAL_REFERENCE_NUMBER',
vesselName: 'LE b@TO 2',
vesselStatus: BeaconMalfunctionVesselStatus.ON_SALE,
vesselStatusLastModificationDateTime: '2023-08-28T11:17:22.997231Z'
}

const result = getMalfunctionStartDateText(beaconMalfunction)

expect(result).toEqual('Balise désactivée')
})
})
10 changes: 8 additions & 2 deletions frontend/src/domain/entities/beaconMalfunction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@ const getMalfunctionStartDateText = (beaconMalfunction: BeaconMalfunction) => {
) {
switch (beaconMalfunction.endOfBeaconMalfunctionReason) {
case END_OF_MALFUNCTION_REASON_RECORD.RESUMED_TRANSMISSION.value:
return `Reprise des émissions ${getReducedTimeAgo(beaconMalfunction.malfunctionEndDateTime)}`
return `Reprise des émissions ${
(beaconMalfunction.malfunctionEndDateTime && getReducedTimeAgo(beaconMalfunction.malfunctionEndDateTime)) ||
''
}`.trim()
case END_OF_MALFUNCTION_REASON_RECORD.BEACON_DEACTIVATED_OR_UNEQUIPPED.value:
return `Balise désactivée ${getReducedTimeAgo(beaconMalfunction.malfunctionEndDateTime)}`
return `Balise désactivée ${
(beaconMalfunction.malfunctionEndDateTime && getReducedTimeAgo(beaconMalfunction.malfunctionEndDateTime)) ||
''
}`.trim()
default:
throw Error('Should not happen')
}
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/domain/entities/beaconMalfunction/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export type BeaconMalfunction = {
ircs: string
malfunctionEndDateTime: string | null
malfunctionStartDateTime: string
notificationRequested: string
priority: boolean
notificationRequested: string | null
stage: string
vesselIdentifier: string
vesselName: string
Expand All @@ -39,9 +38,8 @@ export type BeaconMalfunctionComment = {
}

export type BeaconMalfunctionAction = {
beaconMalfunctionId: Integer<number>
beaconMalfunctionId: number
dateTime: string
id: number
nextValue: BeaconMalfunctionsStage | BeaconMalfunctionVesselStatus
previousValue: BeaconMalfunctionsStage | BeaconMalfunctionVesselStatus
propertyName: BeaconMalfunctionPropertyName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function FleetSegmentsTable({ faoAreas, fleetSegments, setFleetSegments,
<Table
affixHorizontalScrollbar
data={fleetSegments}
height={height < 900 ? height - 120 : 830}
height={height < 900 ? height - 120 : 800}
locale={{
emptyMessage: 'Aucun résultat',
loading: 'Chargement...'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/Backoffice/tableCells.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ModifiableCellWrapper = styled.div`
}
`

const impactRange = _.range(1, 4, 0.1).map(num => {
const impactRange = _.range(1, 4.1, 0.1).map(num => {
const rounded = Number(num.toFixed(1))
return { label: rounded, value: rounded }
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { expect } from '@jest/globals'
import { render } from '@testing-library/react'

import {
BeaconMalfunctionPropertyName,
BeaconMalfunctionsStage,
EndOfBeaconMalfunctionReason
} from '../../../../domain/entities/beaconMalfunction/constants'
import { getActionText } from '../beaconMalfunctions'

describe('features/SideWindow/BeaconMalfunctionBoard/beaconMalfunctions.tsx/getActionText()', () => {
it('should not show the end of malfunction reason when the stage value is not an end column', () => {
const reason = EndOfBeaconMalfunctionReason.BEACON_DEACTIVATED_OR_UNEQUIPPED
const action = {
beaconMalfunctionId: 9149,
dateTime: '2022-12-05T07:53:07.39248Z',
nextValue: BeaconMalfunctionsStage.FOLLOWING,
previousValue: BeaconMalfunctionsStage.AT_QUAY,
propertyName: BeaconMalfunctionPropertyName.STAGE
}

const result = getActionText(action, reason)

const { container } = render(result)
expect(container.textContent).toContain('Le ticket a été déplacé')
expect(container.textContent).not.toContain('Il a été clôturé pour cause')
})

it('should show the end of malfunction reason when the stage value is an end column', () => {
const reason = EndOfBeaconMalfunctionReason.BEACON_DEACTIVATED_OR_UNEQUIPPED
const action = {
beaconMalfunctionId: 9149,
dateTime: '2022-12-05T07:53:07.39248Z',
nextValue: BeaconMalfunctionsStage.ARCHIVED,
previousValue: BeaconMalfunctionsStage.AT_QUAY,
propertyName: BeaconMalfunctionPropertyName.STAGE
}

const result = getActionText(action, reason)

const { container } = render(result)
expect(container.textContent).toContain('Le ticket a été déplacé')
expect(container.textContent).toContain('Il a été clôturé pour cause')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ export function getActionText(
)
}
case BeaconMalfunctionPropertyName.STAGE: {
const isEndColumn =
action.nextValue === STAGE_RECORD.END_OF_MALFUNCTION.code || action.nextValue === STAGE_RECORD.ARCHIVED.code
const previousValue = STAGE_RECORD[action.previousValue].title
const nextValue = STAGE_RECORD[action.nextValue].title
const additionalText = endOfBeaconMalfunctionReason
? END_OF_MALFUNCTION_REASON_RECORD[endOfBeaconMalfunctionReason].label
? isEndColumn && END_OF_MALFUNCTION_REASON_RECORD[endOfBeaconMalfunctionReason].label
: ''

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react'
import styled from 'styled-components'

import { getFirstVesselStatus } from '../../../../domain/entities/beaconMalfunction'
import { getFirstVesselStatus, getMalfunctionStartDateText } from '../../../../domain/entities/beaconMalfunction'
import {
BeaconMalfunctionPropertyName,
BeaconMalfunctionVesselStatus,
Expand Down Expand Up @@ -82,10 +82,7 @@ export function BeaconMalfunctionCard({
</Title>
<Body>
<LastPositionInfo>Dernière position {lastPositionPlace}</LastPositionInfo>
<Resume>
Reprise des émissions le{' '}
{getDateTime(beaconMalfunctionWithDetails.beaconMalfunction.malfunctionEndDateTime, true)}
</Resume>
<Resume>{getMalfunctionStartDateText(beaconMalfunctionWithDetails.beaconMalfunction)}</Resume>
<Length>Durée : {lengthInDays}</Length>
<DetectedActivity>Activité détectée</DetectedActivity>
{beaconMalfunctionWithDetails.actions.find(
Expand Down

0 comments on commit 112b506

Please sign in to comment.