-
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
Open
louptheron
wants to merge
5
commits into
master
Choose a base branch
from
loup/refactor_48_alert_far_archive
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
02b4ff3
Add deletion of alert in place of archive
louptheron 29d1d57
Refactor test
louptheron f559bc1
Add migration
louptheron f78b859
Delete backend/src/main/resources/db/migration/internal/V0.281__Delet…
louptheron 8188258
Apply review refactor
louptheron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
frontend/src/features/Reporting/useCases/__tests__/__mocks__/dummyReporting.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} |
60 changes: 60 additions & 0 deletions
60
frontend/src/features/Reporting/useCases/__tests__/archiveReporting.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { | ||
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 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Pouquoi ne pas suivre le nommage + doc officielle ?
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.
Tu pourrais me détailler ta proposition ? Tu veux dire faire un
createSlice
test ?Note: Ici je ne veux pas descendre au niveau du
fetch
, pour ne pas avoir à gérer RTK.