-
Notifications
You must be signed in to change notification settings - Fork 7
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 – Revoir le mode d'archivage des alertes "FAR 48h" #3806
base: master
Are you sure you want to change the base?
Changes from 4 commits
02b4ff3
29d1d57
f559bc1
f78b859
8188258
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Seafront } from '@constants/seafront' | ||
import { ReportingType } from '@features/Reporting/types' | ||
|
||
import { PendingAlertValueType } from '../../../../../domain/entities/alerts/types' | ||
import { VesselIdentifier } from '../../../../../domain/entities/vessel/types' | ||
|
||
import type { PendingAlertReporting } from '@features/Reporting/types' | ||
|
||
export const fortyHeightHourAlertReporting: PendingAlertReporting = { | ||
creationDate: '2023-10-30T09:10:00Z', | ||
externalReferenceNumber: '', | ||
flagState: 'ES', | ||
id: 12345, | ||
infraction: { | ||
infraction: | ||
'Pêche maritime non autorisée dans les eaux territoriales francaise par capitaine de navire communautaire', | ||
infractionCategory: 'FISHING', | ||
natinfCode: 2610, | ||
regulation: 'ART.L.945-2 §I AL.1, ART.L.945-5 1°,2°,3°,4° C.RUR' | ||
}, | ||
internalReferenceNumber: 'FR04504564', | ||
ircs: '', | ||
isArchived: false, | ||
isDeleted: false, | ||
type: ReportingType.ALERT, | ||
underCharter: null, | ||
validationDate: '2023-10-30T15:08:05.845121Z', | ||
value: { | ||
dml: null, | ||
natinfCode: 2610, | ||
seaFront: Seafront.NAMO, | ||
type: PendingAlertValueType.MISSING_FAR_48_HOURS_ALERT | ||
}, | ||
vesselId: 1234568, | ||
vesselIdentifier: VesselIdentifier.INTERNAL_REFERENCE_NUMBER, | ||
vesselName: 'A VESSEL' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { fortyHeightHourAlertReporting } from '@features/Reporting/useCases/__tests__/__mocks__/dummyReporting' | ||
import { archiveReporting } from '@features/Reporting/useCases/archiveReporting' | ||
import * as deleteReporting from '@features/Reporting/useCases/deleteReporting' | ||
import { describe, it, expect, jest, afterAll } from '@jest/globals' | ||
import { dispatchProcessor } from '@store/__tests__/utils' | ||
|
||
import { PendingAlertValueType } from '../../../../domain/entities/alerts/types' | ||
import { VesselIdentifier } from '../../../../domain/entities/vessel/types' | ||
|
||
jest.mock('../../reportingApi', () => jest.fn()) | ||
jest.mock('../deleteReporting', () => ({ | ||
__esModule: true, | ||
deleteReporting: () => jest.fn() | ||
})) | ||
jest.spyOn(deleteReporting, 'deleteReporting') | ||
|
||
describe('archiveReporting()', () => { | ||
const INITIAL_STATE = { | ||
vessel: { | ||
selectedVesselIdentity: { | ||
externalReferenceNumber: '', | ||
flagState: '', | ||
internalReferenceNumber: '', | ||
vesselId: 1234568, | ||
vesselIdentifier: VesselIdentifier.INTERNAL_REFERENCE_NUMBER, | ||
vesselName: '' | ||
} | ||
} | ||
} | ||
|
||
afterAll(() => { | ||
// Reset module registry to clear the mock | ||
jest.resetModules() | ||
}) | ||
|
||
it('Should delete reporting When alert is MISSING_FAR_48_HOURS_ALERT', async () => { | ||
// When | ||
dispatchProcessor(archiveReporting(fortyHeightHourAlertReporting), INITIAL_STATE) | ||
|
||
// Then | ||
expect(deleteReporting.deleteReporting).toHaveBeenCalled() | ||
}) | ||
|
||
it('Should not delete reporting When the alert is not an MISSING_FAR_48_HOURS_ALERT', async () => { | ||
// Given | ||
const otherAlertReporting = { | ||
...fortyHeightHourAlertReporting, | ||
value: { | ||
...fortyHeightHourAlertReporting.value, | ||
type: PendingAlertValueType.MISSING_FAR_ALERT | ||
} | ||
} | ||
|
||
// When | ||
dispatchProcessor(archiveReporting(otherAlertReporting), INITIAL_STATE) | ||
|
||
// Then | ||
expect(deleteReporting.deleteReporting).toHaveBeenCalledTimes(0) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { jest } from '@jest/globals' | ||
|
||
/** | ||
* To be used to capture all dispatched actions. | ||
* | ||
* we could have more middleware functions being called within the | ||
* use-case middleware, and we should be able to capture all of these events. | ||
*/ | ||
export const dispatchProcessor = (action, initialState) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pouquoi ne pas suivre le nommage + doc officielle ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tu pourrais me détailler ta proposition ? Tu veux dire faire un Note: Ici je ne veux pas descendre au niveau du |
||
const store = { | ||
dispatch: jest.fn(fn => { | ||
if (typeof fn === 'function') { | ||
fn(store.dispatch, store.getState) | ||
} | ||
}), | ||
getState: jest.fn(() => initialState) | ||
} | ||
|
||
action(store.dispatch, store.getState) | ||
|
||
return store | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? (taste)