Skip to content

Commit

Permalink
Fix envActions stub
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Mar 25, 2024
1 parent 5ec9f06 commit dbe4acc
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = {
}
},
{
files: ['src/domain/types/*.ts', 'src/domain/**/mission.types.ts', 'src/domain/shared_slices/**/*.ts', 'src/**/slice.ts'],
files: ['src/domain/types/*.ts', 'src/domain/**/types.ts', 'src/domain/shared_slices/**/*.ts', 'src/**/slice.ts'],
plugins: ['no-null'],
rules: {
'no-param-reassign': 'off'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,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 @@ -100,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 @@ -172,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
1 change: 1 addition & 0 deletions frontend/cypress/e2e/side_window/mission_form/utils.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -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,10 +1,8 @@
import { EnvMissionAction } from '@features/Mission/envMissionAction.types'
import { Mission } from '@features/Mission/mission.types'
import { MissionAction } from '@features/Mission/missionAction.types'
import dayjs from 'dayjs'
import styled from 'styled-components'

import type { MissionActionFormValues, MissionActionForTimeline } from '../types'
import type { MissionActionFormValues } from '../types'
import type { ReactNode } from 'react'

export function formatDateLabel(dateLabel: string) {
Expand Down Expand Up @@ -68,20 +66,6 @@ export function getMissionActionFormInitialValues(type: MissionAction.MissionAct
}
}

export function getMissionActionDate(
missionAction: MissionActionForTimeline | EnvMissionAction.MissionActionForTimeline
) {
if (missionAction.source === Mission.MissionSource.MONITORFISH) {
return (missionAction as MissionActionFormValues).actionDatetimeUtc
}

if (missionAction.source === Mission.MissionSource.MONITORENV) {
return (missionAction as EnvMissionAction.MissionAction).actionStartDateTimeUtc
}

throw new Error(`Unknown source: ${missionAction.source}`)
}

const Placeholder = styled.span`
color: ${p => p.theme.color.slateGray};
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function getTitleFromMissionMainFormValues(
export function getUpdatedMissionFromMissionMainFormValues(
missionId: Mission.Mission['id'],
mainFormValues: MissionMainFormValues
): Mission.Mission {
): Mission.SavedMission {
const missionData = getMissionDataFromMissionFormValues(mainFormValues)

return {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/features/Mission/mission.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export namespace Mission {
// ---------------------------------------------------------------------------
// Types

export type MissionData = Except<Mission, 'id'>
export type MissionData = Except<Mission, 'id' | 'envActions'>

export type SavedMission = Except<Mission, 'envActions'>

export type MissionPointFeatureProperties = {
color: string
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/Mission/monitorenvMissionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const monitorenvMissionApi = monitorenvApi.injectEndpoints({
transformErrorResponse: response => new FrontendApiError(GET_MISSION_ERROR_MESSAGE, response)
}),

updateMission: builder.mutation<Mission.Mission, Mission.Mission>({
updateMission: builder.mutation<Mission.Mission, Mission.SavedMission>({
query: mission => ({
body: mission,
method: 'POST',
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/hooks/useTable/__tests__/useTable.test.TOFIX.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ describe('hooks/useTable()', () => {

it('should return the expected augmented data from simple queries with untransformed columns', () => {
const rawData: CollectionItem[] = [
{ id: '1', title: 'First MissionAction' },
{ id: '2', title: 'Second MissionAction' },
{ id: '12', title: 'Twelfth MissionAction' },
{ id: '123', title: 'Hundred and twenty-third MissionAction' }
{ id: '1', title: 'First Item' },
{ id: '2', title: 'Second Item' },
{ id: '12', title: 'Twelfth Item' },
{ id: '123', title: 'Hundred and twenty-third Item' }
]
const tableOptions: TableOptions<any> = {
columns: [
Expand All @@ -49,7 +49,7 @@ describe('hooks/useTable()', () => {
},
$sortable: {},
id: '12',
title: 'Twelfth MissionAction'
title: 'Twelfth Item'
},
{
$isChecked: false,
Expand All @@ -61,7 +61,7 @@ describe('hooks/useTable()', () => {
},
$sortable: {},
id: '123',
title: 'Hundred and twenty-third MissionAction'
title: 'Hundred and twenty-third Item'
}
])

Expand All @@ -78,7 +78,7 @@ describe('hooks/useTable()', () => {
},
$sortable: {},
id: '123',
title: 'Hundred and twenty-third MissionAction'
title: 'Hundred and twenty-third Item'
}
])

Expand All @@ -95,7 +95,7 @@ describe('hooks/useTable()', () => {
},
$sortable: {},
id: '12',
title: 'Twelfth MissionAction'
title: 'Twelfth Item'
},
{
$isChecked: false,
Expand All @@ -107,7 +107,7 @@ describe('hooks/useTable()', () => {
},
$sortable: {},
id: '123',
title: 'Hundred and twenty-third MissionAction'
title: 'Hundred and twenty-third Item'
}
])
})
Expand Down

0 comments on commit dbe4acc

Please sign in to comment.