Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

feat(simplification): supprime les types cod,dec,wfr,wmm,wmr #1461

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,9 @@ describe("statut d'une démarche", () => {
[Travaux.DemandeComplements, 'fai', Demarches.EnInstruction],
[Travaux.ReceptionComplements, 'fai', Demarches.EnInstruction],
[Travaux.SaisineAutoriteEnvironmentale, 'fai', Demarches.EnInstruction],
[Travaux.MemoireReponseExploitant, 'fai', Demarches.EnInstruction],
[Travaux.AvisReception, 'fai', Demarches.EnInstruction],
[Travaux.AvisDesServicesEtCommissionsConsultatives, 'fai', Demarches.EnInstruction],
[Travaux.AvisAutoriteEnvironmentale, 'fai', Demarches.EnInstruction],
[Travaux.MemoireReponseExploitant, 'fai', Demarches.EnInstruction],
[Travaux.AvisRapportDirecteurREAL, 'fai', Demarches.EnInstruction],
[Travaux.TransPrescriptionsDemandeur, 'fai', Demarches.EnInstruction],
[Travaux.AvisPrescriptionsDemandeur, 'fai', Demarches.EnInstruction],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ const titreDemarcheTravauxStatutIdFind = (titreDemarcheEtapes: Pick<ITitreEtape,
[Travaux.AvisRapportDirecteurREAL]: DemarchesStatutsIds.EnInstruction,
[Travaux.TransPrescriptionsDemandeur]: DemarchesStatutsIds.EnInstruction,
[Travaux.EnquetePublique]: DemarchesStatutsIds.EnInstruction,
[Travaux.MemoireReponseExploitant]: DemarchesStatutsIds.EnInstruction,
[Travaux.AvisPrescriptionsDemandeur]: DemarchesStatutsIds.EnInstruction,
[Travaux.ArretePrescriptionComplementaire]: DemarchesStatutsIds.EnInstruction,
[Travaux.ArretePrefectDonneActe1]: DemarchesStatutsIds.EnInstruction,
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const TitreEtapesTravauxTypes = {
SaisineAutoriteEnvironmentale: 'wse',
AvisAutoriteEnvironmentale: 'wae',
ArretePrefectoralSursis: 'wps',
MemoireReponseExploitant: 'wmm',
EnquetePublique: 'epu',
AvisRapportDirecteurREAL: 'apd',
TransPrescriptionsDemandeur: 'wtp',
Expand Down
12 changes: 12 additions & 0 deletions packages/common/src/heritage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { test, expect, describe } from 'vitest'
import { EtapeHeritageProps, isHeritageProps } from './heritage'

describe('isHeritageProps', () => {
test('la string "camino" n\'est pas une heritageProp', () => {
expect(isHeritageProps('camino')).toBe(false)
})

test.each<EtapeHeritageProps>(['titulaires', 'amodiataires', 'dateDebut', 'dateFin', 'duree', 'substances', 'perimetre'])('%s est une heritageProp', prop => {
expect(isHeritageProps(prop)).toBe(true)
})
})
4 changes: 2 additions & 2 deletions packages/common/src/permissions/etape-form.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ test('perimetreStepIsComplete', () => {
test('etapeDocumentsStepIsVisible', () => {
expect(etapeDocumentsStepIsVisible({ typeId: 'asl' }, 'oct', 'axm')).toBe(true)
expect(etapeDocumentsStepIsVisible({ typeId: 'mdp' }, 'oct', 'axm')).toBe(true)
expect(etapeDocumentsStepIsVisible({ typeId: 'cod' }, 'oct', 'axm')).toBe(false)
expect(etapeDocumentsStepIsVisible({ typeId: 'pqr' }, 'oct', 'axm')).toBe(false)
})

const axmDocumentsComplete = [
Expand Down Expand Up @@ -431,7 +431,7 @@ test('etapeDocumentsStepIsComplete', () => {
test('entrepriseDocumentsStepIsVisible', () => {
expect(entrepriseDocumentsStepIsVisible({ typeId: 'asl' }, 'oct', 'axm')).toBe(false)
expect(entrepriseDocumentsStepIsVisible({ typeId: 'mfr' }, 'oct', 'axm')).toBe(true)
expect(entrepriseDocumentsStepIsVisible({ typeId: 'cod' }, 'oct', 'axm')).toBe(false)
expect(entrepriseDocumentsStepIsVisible({ typeId: 'pqr' }, 'oct', 'axm')).toBe(false)
})
test('entrepriseDocumentsStepIsComplete', () => {
expect(
Expand Down
59 changes: 2 additions & 57 deletions packages/common/src/static/etapesTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Definition } from '../definition'
import { EtapeBrouillon } from '../etape'

// prettier-ignore
const IDS = ['abd', 'aca','aco','and','anf','def','dex','dim', 'dpu', 'dux','ihi', 'mfr','mod','mom','rca','rcb','rcd','rcm','rco','rcs','rie','rif','rim','rpu','sco','acg','apd','ape','apo','app','apu','asl','cac','cim','cod','css','dae','dec','des','ede','edm','epu','esb','mca','mcb','mcd', 'mci','mcm','mco','mcp','mcr','mcs','mdp','mec','men','meo','mie','mif','mim','mna','mnb','mnc','mnd','mni','mno','mns','mnv','ncl','npp','pfc','pfd','ppu','pqr','rcg','rde','rpe','sas','sca','scg','spe','spo','spp','vfc','vfd','wab','wae','wao','war','wau','wco','wda','wdc','wdd','wde','wdm','wfa','wfd','wfo','wfr','wmm','wmr','wmt', 'wpa','wpb','wpc','wpo','wpp','wps','wrc','wre','wrt','wse','wtp', 'asc', 'adc'] as const
const IDS = ['abd', 'aca','aco','and','anf','def','dex','dim', 'dpu', 'dux','ihi', 'mfr','mod','mom','rca','rcb','rcd','rcm','rco','rcs','rie','rif','rim','rpu','sco','acg','apd','ape','apo','app','apu','asl','cac','cim','css','dae','des','ede','edm','epu','esb','mca','mcb','mcd', 'mci','mcm','mco','mcp','mcr','mcs','mdp','mec','men','meo','mie','mif','mim','mna','mnb','mnc','mnd','mni','mno','mns','mnv','ncl','npp','pfc','pfd','ppu','pqr','rcg','rde','rpe','sas','sca','scg','spe','spo','spp','vfc','vfd','wab','wae','wao','war','wau','wco','wda','wdc','wdd','wde','wdm','wfa','wfd','wfo','wmt', 'wpa','wpb','wpc','wpo','wpp','wps','wrc','wre','wrt','wse','wtp', 'asc', 'adc'] as const

// prettier-ignore
const FONDAMENTALES_IDS = ['abd', 'aca','aco','and','anf','def','dex','dim', 'dpu','dux','ihi', 'mfr','mod','mom','rca','rcb','rcd','rcm','rco','rcs','rie','rif','rim','rpu','sco'] as const satisfies Readonly<EtapeTypeIdFondamentaleArray>

// prettier-ignore
const NON_FONDAMENTALES_IDS = ['acg','apd','ape','apo','app','apu','asl','cac','cim','cod','css','dae','dec','des','ede','edm','epu','esb','mca','mcb','mcd','mci', 'mcm','mco','mcp','mcr', 'mcs','mdp','mec','men','meo','mie','mif','mim','mna','mnb','mnc','mnd','mni','mno','mns','mnv','ncl','npp','pfc','pfd','ppu','pqr','rcg','rde','rpe','sas','sca','scg','spe','spo','spp','vfc','vfd','wab','wae','wao','war','wau','wco','wda','wdc','wdd','wde','wdm','wfa','wfd','wfo','wfr','wmm','wmr','wmt','wpa','wpb','wpc','wpo','wpp','wps','wrc','wre','wrt','wse','wtp', 'asc', 'adc'] as const satisfies Readonly<EtapeTypeIdNonFondamentale[]>
const NON_FONDAMENTALES_IDS = ['acg','apd','ape','apo','app','apu','asl','cac','cim','css','dae','des','ede','edm','epu','esb','mca','mcb','mcd','mci', 'mcm','mco','mcp','mcr', 'mcs','mdp','mec','men','meo','mie','mif','mim','mna','mnb','mnc','mnd','mni','mno','mns','mnv','ncl','npp','pfc','pfd','ppu','pqr','rcg','rde','rpe','sas','sca','scg','spe','spo','spp','vfc','vfd','wab','wae','wao','war','wau','wco','wda','wdc','wdd','wde','wdm','wfa','wfd','wfo','wmt','wpa','wpb','wpc','wpo','wpp','wps','wrc','wre','wrt','wse','wtp', 'asc', 'adc'] as const satisfies Readonly<EtapeTypeIdNonFondamentale[]>

// Ceci est un test :)
;[...FONDAMENTALES_IDS, ...NON_FONDAMENTALES_IDS] as const satisfies typeof IDS
Expand All @@ -30,10 +30,8 @@ export const ETAPES_TYPES = {
decisionDuProprietaireDuSol: 'asl',
consultationDesAdministrationsCentrales: 'cac',
concertationInterministerielle: 'cim',
saisineDuConseilDepartementalDeLenvironnementEtDesRisquesSanitairesEtTechnologiques_Coderst_: 'cod',
classementSansSuite: 'css',
decisionDeLaMissionAutoriteEnvironnementale_ExamenAuCasParCasDuProjet_: 'dae',
declaration: 'dec',
decisionDeLOfficeNationalDesForets: 'def',
desistementDuDemandeur: 'des',
decisionDeLadministration: 'dex',
Expand Down Expand Up @@ -113,9 +111,6 @@ export const ETAPES_TYPES = {
demandeDautorisationDouvertureDeTravauxMiniers_AOTM_: 'wfa',
declarationDarretDefinitifDeTravaux_DADT_: 'wfd',
declarationDouvertureDeTravauxMiniers_DOTM_: 'wfo',
demandeDautorisationDouvertureDeTravauxMiniers_DAOTM_: 'wfr',
memoireEnReponseDeLexploitant_ParRapportALavisDeLAE_: 'wmm',
memoireEnReponseDeLexploitant: 'wmr',
memoireDeFinDeTravaux: 'wmt',
publicationDeDecisionAuRecueilDesActesAdministratifs_wpa: 'wpa',
porterAConnaissance: 'wpb',
Expand Down Expand Up @@ -277,16 +272,6 @@ export const EtapesTypes = {
public_lecture: false,
entreprises_lecture: true,
},
dec: {
id: 'dec',
nom: 'déclaration',
description: '',
fondamentale: false,
unique: true,
date_fin: null,
public_lecture: true,
entreprises_lecture: true,
},
cac: {
id: 'cac',
nom: 'consultation des administrations centrales',
Expand Down Expand Up @@ -348,16 +333,6 @@ export const EtapesTypes = {
public_lecture: false,
entreprises_lecture: false,
},
cod: {
id: 'cod',
nom: "saisine du conseil départemental de l'environnement et des risques sanitaires et technologiques (Coderst)",
description: '',
fondamentale: false,
unique: false,
date_fin: null,
public_lecture: true,
entreprises_lecture: true,
},
wda: {
id: 'wda',
nom: 'Donné acte de la déclaration (DOTM)',
Expand Down Expand Up @@ -1065,16 +1040,6 @@ export const EtapesTypes = {
public_lecture: true,
entreprises_lecture: true,
},
wfr: {
id: 'wfr',
nom: "Demande d'autorisation d'ouverture de travaux miniers (DAOTM)",
description: '',
fondamentale: false,
unique: false,
date_fin: null,
public_lecture: false,
entreprises_lecture: false,
},
wco: {
id: 'wco',
nom: 'Réception de compléments',
Expand All @@ -1085,16 +1050,6 @@ export const EtapesTypes = {
public_lecture: false,
entreprises_lecture: false,
},
wmr: {
id: 'wmr',
nom: "mémoire en réponse de l'exploitant",
description: "mémoire en réponse de l'exploitant à l'avis d'autorité environnementale.",
fondamentale: false,
unique: false,
date_fin: null,
public_lecture: false,
entreprises_lecture: false,
},
wfa: {
id: 'wfa',
nom: "Demande d'autorisation d'ouverture de travaux miniers (AOTM)",
Expand Down Expand Up @@ -1205,16 +1160,6 @@ export const EtapesTypes = {
public_lecture: false,
entreprises_lecture: false,
},
wmm: {
id: 'wmm',
nom: "memoire en réponse de l'exploitant (par rapport à l'avis de l'AE)",
description: '',
fondamentale: false,
unique: false,
date_fin: null,
public_lecture: false,
entreprises_lecture: false,
},
wtp: {
id: 'wtp',
nom: 'Transmission du projet de prescriptions au demandeur',
Expand Down
5 changes: 0 additions & 5 deletions packages/common/src/static/etapesTypesEtapesStatuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ export const EtapesTypesEtapesStatuts = {

consultationDesAdministrationsCentrales: { FAIT: { etapeTypeId: 'cac', etapeStatutId: 'fai' } },
concertationInterministerielle: { FAIT: { etapeTypeId: 'cim', etapeStatutId: 'fai' } },
saisineDuConseilDepartementalDeLenvironnementEtDesRisquesSanitairesEtTechnologiques_Coderst_: { FAIT: { etapeTypeId: 'cod', etapeStatutId: 'fai' } },

classementSansSuite: { FAIT: { etapeTypeId: 'css', etapeStatutId: 'fai' } },
decisionDeLaMissionAutoriteEnvironnementale_ExamenAuCasParCasDuProjet_: {
EXEMPTE: { etapeTypeId: 'dae', etapeStatutId: 'exe' },
REQUIS: { etapeTypeId: 'dae', etapeStatutId: 'req' },
},
declaration: { FAIT: { etapeTypeId: 'dec', etapeStatutId: 'fai' } },
decisionDeLOfficeNationalDesForets: {
ACCEPTE: { etapeTypeId: 'def', etapeStatutId: 'acc' },
REJETE: { etapeTypeId: 'def', etapeStatutId: 'rej' },
Expand Down Expand Up @@ -223,9 +221,6 @@ export const EtapesTypesEtapesStatuts = {
demandeDautorisationDouvertureDeTravauxMiniers_AOTM_: { FAIT: { etapeTypeId: 'wfa', etapeStatutId: 'fai' } },
declarationDarretDefinitifDeTravaux_DADT_: { FAIT: { etapeTypeId: 'wfd', etapeStatutId: 'fai' } },
declarationDouvertureDeTravauxMiniers_DOTM_: { FAIT: { etapeTypeId: 'wfo', etapeStatutId: 'fai' } },
demandeDautorisationDouvertureDeTravauxMiniers_DAOTM_: { DEPOSE: { etapeTypeId: 'wfr', etapeStatutId: 'dep' } },
memoireEnReponseDeLexploitant_ParRapportALavisDeLAE_: { FAIT: { etapeTypeId: 'wmm', etapeStatutId: 'fai' } },
memoireEnReponseDeLexploitant: { DEPOSE: { etapeTypeId: 'wmr', etapeStatutId: 'dep' } },
memoireDeFinDeTravaux: { FAIT: { etapeTypeId: 'wmt', etapeStatutId: 'fai' } },
publicationDeDecisionAuRecueilDesActesAdministratifs_wpa: { FAIT: { etapeTypeId: 'wpa', etapeStatutId: 'fai' } },
porterAConnaissance: { FAIT: { etapeTypeId: 'wpb', etapeStatutId: 'fai' } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test('getDocuments erreurs', () => {
})

test('getDocuments pas de surcharge mais pas de documents', () => {
expect(getDocuments('apm', 'amo', 'cod')).toMatchInlineSnapshot('[]')
expect(getDocuments('apm', 'amo', 'pqr')).toMatchInlineSnapshot('[]')
})

test('getDocuments pas de surcharge', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,17 +297,6 @@ const EtapesTypesDocumentsTypes = {
{ documentTypeId: DOCUMENTS_TYPES_IDS.dossier, optionnel: true },
],
[ETAPES_TYPES.declarationDouvertureDeTravauxMiniers_DOTM_]: [{ documentTypeId: DOCUMENTS_TYPES_IDS.declaration, optionnel: true }],
[ETAPES_TYPES.demandeDautorisationDouvertureDeTravauxMiniers_DAOTM_]: [
{ documentTypeId: DOCUMENTS_TYPES_IDS.accuseDeReceptionDUneDemande, optionnel: true },
{ documentTypeId: DOCUMENTS_TYPES_IDS.documentsCartographiques, optionnel: true },
{ documentTypeId: DOCUMENTS_TYPES_IDS.dossierDeDemande, optionnel: true },
{ documentTypeId: DOCUMENTS_TYPES_IDS.dossier, optionnel: true },
{ documentTypeId: DOCUMENTS_TYPES_IDS.ficheDePresentation, optionnel: true },
{ documentTypeId: DOCUMENTS_TYPES_IDS.identificationDeMateriel, optionnel: true },
{ documentTypeId: DOCUMENTS_TYPES_IDS.noticeDIncidence, optionnel: true },
],
[ETAPES_TYPES.memoireEnReponseDeLexploitant_ParRapportALavisDeLAE_]: [{ documentTypeId: DOCUMENTS_TYPES_IDS.dossier, optionnel: true }],
[ETAPES_TYPES.memoireEnReponseDeLexploitant]: [{ documentTypeId: DOCUMENTS_TYPES_IDS.dossier, optionnel: true }],
[ETAPES_TYPES.memoireDeFinDeTravaux]: [{ documentTypeId: DOCUMENTS_TYPES_IDS.programmeDesTravaux, optionnel: true }],
[ETAPES_TYPES.publicationDeDecisionAuRecueilDesActesAdministratifs_wpa]: [{ documentTypeId: DOCUMENTS_TYPES_IDS.arretePrefectoral, optionnel: true }],
[ETAPES_TYPES.porterAConnaissance]: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const travaux = {
ETAPES_TYPES.saisineDeLautoriteEnvironnementale,
ETAPES_TYPES.avisDeLautoriteEnvironnementale,
ETAPES_TYPES.avisDesServicesEtCommissionsConsultatives,
ETAPES_TYPES.memoireEnReponseDeLexploitant_ParRapportALavisDeLAE_,
ETAPES_TYPES.enquetePublique,
ETAPES_TYPES.rapportEtAvisDeLaDREAL,
ETAPES_TYPES.transmissionDuProjetDePrescriptionsAuDemandeur,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ const TDESections = {
},
],
[ETAPES_TYPES.demande]: caracteristiquesARM,
[ETAPES_TYPES.modificationDeLaDemande_DecisionDeLaMissionAutoriteEnvironnementale_ExamenAuCasParCasDuProjet_]: caracteristiquesARM,
[ETAPES_TYPES.modificationDeLaDemande]: caracteristiquesARM,
[ETAPES_TYPES.completudeDeLaDemande]: [
{
Expand Down
47 changes: 47 additions & 0 deletions packages/common/src/titres.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,51 @@ describe('getMostRecentValuePropFromEtapeFondamentaleValide', () => {
])
).toStrictEqual(dpu.fondamentale.titulaireIds)
})

test("retourne null s'il n'y a aucune étape fondamentale", () => {
expect(getMostRecentValuePropFromEtapeFondamentaleValide('titulaireIds', [])).toBe(null)
})

test('ignore une étape si sa propriété est null', () => {
const dpu: TitrePropTitreEtapeFindDemarcheEtape = {
etape_type_id: 'dpu',
fondamentale: {
date_debut: null,
date_fin: toCaminoDate('2032-08-18'),
duree: null,
substances: [],
titulaireIds: [entrepriseIdValidator.parse('fr-791652399')],
amodiataireIds: null,
perimetre: null,
},
etape_statut_id: 'acc',
is_brouillon: ETAPE_IS_NOT_BROUILLON,
ordre: 2,
}

const dex: TitrePropTitreEtapeFindDemarcheEtape = {
etape_type_id: 'dex',
fondamentale: {
date_debut: null,
date_fin: null,
duree: 240,
substances: [],
titulaireIds: [entrepriseIdValidator.parse('fr-310380811')],
amodiataireIds: null,
perimetre: null,
},
etape_statut_id: 'acc',
is_brouillon: ETAPE_IS_NOT_BROUILLON,
ordre: 1,
}

expect(
getMostRecentValuePropFromEtapeFondamentaleValide('duree', [
{
etapes: [dpu, dex],
ordre: 1,
},
])
).toStrictEqual(240)
})
})
8 changes: 4 additions & 4 deletions packages/common/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export default defineConfig({
thresholds: {
// the endgame is to put thresholds at 100 and never touch it again :)
autoUpdate: true,
branches: 91.57,
functions: 83.46,
lines: 96.73,
statements: 96.73,
branches: 91.81,
functions: 83.85,
lines: 96.81,
statements: 96.81,
perFile: false,
},
},
Expand Down
Loading