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] Affichage des actions Env dans la timeline du formulaire de mission #3033

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 12 additions & 0 deletions frontend/cypress/e2e/side_window/mission_form/action_list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,16 @@ context('Side Window > Mission Form > Action List', () => {
'est automatiquement calculée selon le point ou la zone de la dernière action rapportée par l’unité.'
)
})

it('Should show Env actions on the actions timeline', () => {
editSideWindowMissionListMissionWithId(34, SeaFrontGroup.MEMN)

cy.get('[data-cy="mission-form-action-list"]').children().eq(0).contains('28 Nov à 13:59')
cy.get('[data-cy="mission-form-action-list"]').children().eq(0).contains('Surveillance')
cy.get('[data-cy="mission-form-action-list"]').children().eq(1).contains('Action CACEM')

cy.get('[data-cy="mission-form-action-list"]').children().eq(2).contains('17 Nov à 13:59')
cy.get('[data-cy="mission-form-action-list"]').children().eq(2).contains('Contrôle')
cy.get('[data-cy="mission-form-action-list"]').children().eq(3).contains('Action CACEM')
})
})
Comment on lines 241 to 256
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1-1]

The TODO comment at the beginning of the file suggests finding a way to reset data after each test to make them independent and easily re-runnable. This is a good practice for ensuring test reliability and avoiding inter-test dependencies.

Would you like assistance in implementing a solution for resetting data after each test, perhaps through Cypress commands or fixtures?

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Mission } from '@features/Mission/mission.types'

import { fillSideWindowMissionFormBase, openSideWindowNewMission } from './utils'
import { Mission } from '../../../../src/domain/entities/mission/types'
import { getUtcDateInMultipleFormats } from '../../utils/getUtcDateInMultipleFormats'

context('Side Window > Mission Form > Air Control', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Mission } from '@features/Mission/mission.types'

import { fillSideWindowMissionFormBase, openSideWindowNewMission } from './utils'
import { Mission } from '../../../../src/domain/entities/mission/types'

context('Side Window > Mission Form > Air Surveillance', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Mission } from '@features/Mission/mission.types'

import { fillSideWindowMissionFormBase, openSideWindowNewMission } from './utils'
import { Mission } from '../../../../src/domain/entities/mission/types'
import { getUtcDateInMultipleFormats } from '../../utils/getUtcDateInMultipleFormats'

context('Side Window > Mission Form > Land Control', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Mission } from '@features/Mission/mission.types'

import { fillSideWindowMissionFormBase, openSideWindowNewMission } from './utils'
import { Mission } from '../../../../src/domain/entities/mission/types'
import { SeaFrontGroup } from '../../../../src/domain/entities/seaFront/constants'
import { SideWindowMenuLabel } from '../../../../src/domain/entities/sideWindow/constants'
import { FAKE_MISSION_WITH_EXTERNAL_ACTIONS, FAKE_MISSION_WITHOUT_EXTERNAL_ACTIONS } from '../../constants'
Expand Down Expand Up @@ -41,6 +42,7 @@ context('Side Window > Mission Form > Main Form', () => {
}).as('createMission')
cy.intercept('GET', '/api/v1/missions/1', {
body: {
envActions: [],
id: 1
},
statusCode: 201
Expand Down Expand Up @@ -99,6 +101,7 @@ context('Side Window > Mission Form > Main Form', () => {
openSideWindowNewMission()
cy.intercept('GET', '/api/v1/missions/1', {
body: {
envActions: [],
id: 1
},
statusCode: 201
Expand Down Expand Up @@ -171,6 +174,7 @@ context('Side Window > Mission Form > Main Form', () => {
openSideWindowNewMission()
cy.intercept('GET', '/api/v1/missions/1', {
body: {
envActions: [],
id: 1
},
statusCode: 201
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Mission } from '@features/Mission/mission.types'

import { fillSideWindowMissionFormBase, openSideWindowNewMission } from './utils'
import { Mission } from '../../../../src/domain/entities/mission/types'

context('Side Window > Mission Form > Observation', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Mission } from '@features/Mission/mission.types'

import { fillSideWindowMissionFormBase, openSideWindowNewMission } from './utils'
import { Mission } from '../../../../src/domain/entities/mission/types'
import { getUtcDateInMultipleFormats } from '../../utils/getUtcDateInMultipleFormats'

context('Side Window > Mission Form > Sea Control', () => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/cypress/e2e/side_window/mission_form/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SideWindowMenuLabel } from '../../../../src/domain/entities/sideWindow/
import { customDayjs } from '../../utils/customDayjs'
import { getUtcDateInMultipleFormats } from '../../utils/getUtcDateInMultipleFormats'

import type { Mission } from '../../../../src/domain/entities/mission/types'
import type { Mission } from '@features/Mission/mission.types'

export const openSideWindowNewMission = () => {
cy.viewport(1920, 1080)
Expand Down Expand Up @@ -64,6 +64,7 @@ export const fillSideWindowMissionFormBase = (
}).as('createMission')
cy.intercept('GET', '/api/v1/missions/1', {
body: {
envActions: [],
id: 1,
isClosed: isReturningClosed
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/missionAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { monitorfishApi, monitorfishApiKy } from './api'
import { ApiError } from '../libs/ApiError'
import { FrontendApiError } from '../libs/FrontendApiError'

import type { MissionAction } from '../domain/types/missionAction'
import type { MissionAction } from '@features/Mission/missionAction.types'

const GET_MISSION_ACTIONS_ERROR_MESSAGE = "Nous n'avons pas pu récupérer les actions de la mission"

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/context/MissionEventContext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'

import type { Mission } from '../domain/entities/mission/types'
import type { Mission } from '@features/Mission/mission.types'

export const MissionEventContext = React.createContext<Mission.Mission | undefined>(undefined)
2 changes: 1 addition & 1 deletion frontend/src/domain/entities/alerts/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SeaFront } from '../seaFront/constants'

import type { MissionAction } from '../../types/missionAction'
import type { VesselIdentifier, VesselIdentity } from '../vessel/types'
import type { MissionAction } from '@features/Mission/missionAction.types'
import type { Except } from 'type-fest'

export enum PendingAlertValueType {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/domain/entities/controls.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { MissionAction } from '@features/Mission/missionAction.types'
import { customDayjs } from '@mtes-mct/monitor-ui'

import { MissionAction } from '../types/missionAction'

import type { MissionActionFormValues } from '@features/Mission/components/MissionForm/types'

import InfractionType = MissionAction.InfractionType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Mission } from '@features/Mission/mission.types'
import { expect } from '@jest/globals'
import { customDayjs } from '@mtes-mct/monitor-ui'

import { Mission } from '../types'
import { getMissionStatus } from '../utils'

// TODO Test all mission statuses.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Mission } from '@features/Mission/mission.types'
import { expect } from '@jest/globals'
import { getUtcizedDayjs } from '@mtes-mct/monitor-ui'

import { SEA_FRONT_GROUP_SEA_FRONTS, SeaFront } from '../../../seaFront/constants'
import { Mission } from '../../types'
import { seaFrontFilterFunction } from '../seaFrontFilterFunction'

import MissionSource = Mission.MissionSource
Expand All @@ -12,6 +12,7 @@ describe('domain/entities/mission/filters/seaFrontFilterFunction.ts()', () => {
it('should return true when the facade is included in the mission facade', () => {
const mission = {
controlUnits: [],
envActions: [],
facade: SeaFront.MED,
id: 123,
isClosed: false,
Expand All @@ -30,6 +31,7 @@ describe('domain/entities/mission/filters/seaFrontFilterFunction.ts()', () => {
it('should return false when the facade is not included in the mission facade', () => {
const mission = {
controlUnits: [],
envActions: [],
facade: SeaFront.SA,
id: 123,
isClosed: false,
Expand All @@ -48,6 +50,7 @@ describe('domain/entities/mission/filters/seaFrontFilterFunction.ts()', () => {
it('should return true when the facade is not filtered', () => {
const mission = {
controlUnits: [],
envActions: [],
facade: SeaFront.SA,
id: 123,
isClosed: false,
Expand All @@ -66,6 +69,7 @@ describe('domain/entities/mission/filters/seaFrontFilterFunction.ts()', () => {
it('should return true when a group of facade is filtered', () => {
const mission = {
controlUnits: [],
envActions: [],
facade: SeaFront.GUADELOUPE,
id: 123,
isClosed: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Mission } from '../types'
import { Mission } from '@features/Mission/mission.types'

export function administrationFilterFunction(mission: Mission.Mission, filter: string[]) {
if (filter.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Mission } from '@features/Mission/mission.types'

import { SeaFront } from '../../seaFront/constants'
import { Mission } from '../types'

export function seaFrontFilterFunction(mission: Mission.Mission, filter: SeaFront[]) {
if (filter.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Mission } from '../types'
import { Mission } from '@features/Mission/mission.types'

export function unitFilterFunction(mission: Mission.Mission, filter: string[]) {
if (filter.length === 0) {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/domain/entities/mission/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { getMissionActionInfractionsFromMissionActionFormValues } from '@features/Mission/components/MissionForm/ActionList/utils'
import { Mission } from '@features/Mission/mission.types'
import { MissionAction } from '@features/Mission/missionAction.types'
import { isLandControl } from '@features/Mission/useCases/getLastControlCircleGeometry'
import { OPENLAYERS_PROJECTION, WSG84_PROJECTION } from '@mtes-mct/monitor-ui'
import { random } from 'lodash'
Expand All @@ -9,17 +11,15 @@ import { circular } from 'ol/geom/Polygon'
import { transform } from 'ol/proj'

import { LAND_CONTROL_ZONE_RADIUS, SEA_CONTROL_ZONE_RADIUS } from './constants'
import { Mission } from './types'
import { getMissionStatus } from './utils'
import { getMissionColor } from '../../../features/Mission/layers/MissionLayer/styles'
import { booleanToInt, getDate, getDateTime } from '../../../utils'
import { MissionAction } from '../../types/missionAction'
import { getNumberOfInfractions, getNumberOfInfractionsWithRecord } from '../controls'
import { MonitorFishLayer } from '../layers/types'
import { OpenLayersGeometryType } from '../map/constants'

import type { MissionWithActions } from './types'
import type { MissionActionFormValues, MissionMainFormValues } from '@features/Mission/components/MissionForm/types'
import type { MissionWithActions } from '@features/Mission/mission.types'
import type { MultiPolygon } from 'ol/geom'

import MissionStatus = Mission.MissionStatus
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/domain/entities/mission/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Mission } from '@features/Mission/mission.types'
import { customDayjs } from '@mtes-mct/monitor-ui'

import { Mission } from './types'

export const getMissionStatus = ({
endDateTimeUtc,
isClosed,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/entities/vessel/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO This should be moved to `entities/vessel/types.ts`
// TODO This should be moved to `entities/vessel/mission.types.ts`

louptheron marked this conversation as resolved.
Show resolved Hide resolved
import type { RiskFactor } from './riskFactor/types'
import type { ReportingType } from '../../types/reporting'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/shared_slices/Control.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSlice } from '@reduxjs/toolkit'

import type { MissionAction } from '../types/missionAction'
import type { MissionAction } from '@features/Mission/missionAction.types'
import type { PayloadAction } from '@reduxjs/toolkit'

export type ControlState = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/ActivityReport/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Vessel } from '../../domain/entities/vessel/types'
import type { LegacyControlUnit } from '../../domain/types/legacyControlUnit'
import type { MissionAction } from '../../domain/types/missionAction'
import type { MissionAction } from '../Mission/missionAction.types'

export type ActivityReports = {
activityReports: ActivityReport[]
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/ActivityReport/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { range, sortBy } from 'lodash'

import { JDP, UNTARGETED_SPECIES_CODE } from './constants'
import { MissionAction } from '../../domain/types/missionAction'
import { MissionAction } from '../Mission/missionAction.types'

import type { ActivityReportWithId } from './types'
import type { DownloadAsCsvMap } from '@utils/downloadAsCsv'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatDataForSelectPicker } from '@features/Backoffice/utils'
import { OptionValue } from '@features/SideWindow/MissionList/FilterBar'
import { OptionValue } from '@features/Mission/components/MissionList/FilterBar'
import { useBackofficeAppDispatch } from '@hooks/useBackofficeAppDispatch'
import { useBackofficeAppSelector } from '@hooks/useBackofficeAppSelector'
import { MultiSelect, SingleTag } from '@mtes-mct/monitor-ui'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MissionAction } from 'domain/types/missionAction'
import { MissionAction } from '@features/Mission/missionAction.types'
import { memo } from 'react'
import styled from 'styled-components'
import { FrontendErrorBoundary } from 'ui/FrontendErrorBoundary'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */

import { HIDDEN_ERROR } from '@features/Mission/components/MissionForm/constants'
import { MissionAction } from '@features/Mission/missionAction.types'
import { customDayjs } from '@mtes-mct/monitor-ui'
import { mainStore } from '@store/index'
import { MissionAction } from 'domain/types/missionAction'
import { array, boolean, number, object, string } from 'yup'

// -----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MissionAction } from '@features/Mission/missionAction.types'
import { FormikCheckbox, FormikMultiRadio, FormikTextarea } from '@mtes-mct/monitor-ui'
import { MissionAction } from 'domain/types/missionAction'
import styled from 'styled-components'

import { FieldsetGroup } from '../../shared/FieldsetGroup'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import styled from 'styled-components'
import { FieldsetGroupSpinner } from '../../shared/FieldsetGroup'

import type { MissionActionFormValues } from '../../types'
import type { MissionAction } from '@features/Mission/missionAction.types'
import type { Option } from '@mtes-mct/monitor-ui'
import type { MissionAction } from 'domain/types/missionAction'

type FleetSegmentsFieldProps = Readonly<{
label: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HIDDEN_ERROR } from '@features/Mission/components/MissionForm/constants'
import { MissionAction } from '@features/Mission/missionAction.types'
import { addOrEditControlCoordinates } from '@features/Mission/useCases/addOrEditControlCoordinates'
import { useListenForDrawedGeometry } from '@hooks/useListenForDrawing'
import { useMainAppDispatch } from '@hooks/useMainAppDispatch'
Expand All @@ -8,7 +9,6 @@ import { isCypress } from '@utils/isCypress'
import { convertToGeoJSONGeometryObject } from 'domain/entities/layers'
import { InteractionListener, OpenLayersGeometryType } from 'domain/entities/map/constants'
import { fitToExtent } from 'domain/shared_slices/Map'
import { MissionAction } from 'domain/types/missionAction'
import { getCoordinatesExtent } from 'domain/use_cases/map/getCoordinatesExtent'
import { useField, useFormikContext } from 'formik'
import Feature from 'ol/Feature'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MissionAction } from '@features/Mission/missionAction.types'
import { Accent, Icon, IconButton, Legend, Tag, TagGroup, THEME } from '@mtes-mct/monitor-ui'
import { MissionAction } from 'domain/types/missionAction'
import ReactMarkdown from 'react-markdown'
import styled from 'styled-components'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { InfractionCategory } from './types'
import { InfractionFormLiveSchema } from '../../schemas'
import { INFRACTION_TYPES_AS_OPTIONS } from '../constants'

import type { MissionAction } from 'domain/types/missionAction'
import type { MissionAction } from '@features/Mission/missionAction.types'

type InfractionFormProps = Readonly<{
initialValues: MissionAction.Infraction & { group?: string | undefined }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FieldsetGroup, FieldsetGroupSpinner } from '../../../shared/FieldsetGro
import { FieldsetGroupSeparator } from '../../../shared/FieldsetGroupSeparator'

import type { MissionActionFormValues } from '../../../types'
import type { MissionAction } from 'domain/types/missionAction'
import type { MissionAction } from '@features/Mission/missionAction.types'

type FormikMultiInfractionPickerProps = Readonly<{
addButtonLabel: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { FieldsetGroup, FieldsetGroupSpinner } from '../../shared/FieldsetGroup'
import { FieldsetGroupSeparator } from '../../shared/FieldsetGroupSeparator'

import type { MissionActionFormValues } from '../../types'
import type { MissionAction } from '@features/Mission/missionAction.types'
import type { Option } from '@mtes-mct/monitor-ui'
import type { Gear } from 'domain/types/Gear'
import type { MissionAction } from 'domain/types/missionAction'
import type { DeepPartial } from 'types'

export function GearsField() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MissionAction } from '@features/Mission/missionAction.types'
import { FormikMultiRadio, FormikTextarea } from '@mtes-mct/monitor-ui'
import { MissionAction } from 'domain/types/missionAction'

import { FieldsetGroup } from '../../shared/FieldsetGroup'
import { FieldsetGroupSeparator } from '../../shared/FieldsetGroupSeparator'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MissionAction } from '@features/Mission/missionAction.types'
import { getOptionsFromLabelledEnum } from '@utils/getOptionsFromLabelledEnum'
import { MissionAction } from 'domain/types/missionAction'

export const FLIGHT_GOALS_AS_OPTIONS = getOptionsFromLabelledEnum(MissionAction.FLIGHT_GOAL_LABEL)
export const INFRACTION_TYPES_AS_OPTIONS = getOptionsFromLabelledEnum(MissionAction.INFRACTION_TYPE_LABEL)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MissionAction } from '@features/Mission/missionAction.types'
import { getLocalizedDayjs } from '@mtes-mct/monitor-ui'
import { MissionAction } from 'domain/types/missionAction'

import type { FleetSegment } from '@features/FleetSegment/types'
import type { Option } from '@mtes-mct/monitor-ui'
Expand Down
Loading
Loading