-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lbac-2210): update referentiel rome validation (#1649)
* feat: update referentiel rome validation * feat: update openapi snapshot * fix: formulaire.controller.test.ts * fix: test * fix: remove comment * fix: normalize string before comparison * fix: test
- Loading branch information
Showing
8 changed files
with
98 additions
and
63 deletions.
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
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 |
---|---|---|
|
@@ -3,35 +3,15 @@ | |
exports[`createJob > should insert a job 1`] = ` | ||
{ | ||
"_id": "670ce30b57a50d6875c141f9", | ||
"address": "address", | ||
"address_detail": "address_detail", | ||
"cfa_delegated_siret": null, | ||
"createdAt": 2021-01-28T15:00:00.000Z, | ||
"distance": 10, | ||
"email": "[email protected]", | ||
"establishment_creation_date": 2024-10-14T09:23:21.588Z, | ||
"establishment_enseigne": "establishment_enseigne", | ||
"establishment_id": "xxxx-xxxx-xxxx-xxxx", | ||
"establishment_raison_sociale": "establishment_raison_sociale", | ||
"establishment_siret": "wosdnnpetvgxonk", | ||
"establishment_size": "establishment_size", | ||
"first_name": "first_name", | ||
"geo_coordinates": "geo_coordinates", | ||
"geopoint": { | ||
"coordinates": [ | ||
41, | ||
10, | ||
], | ||
"type": "Point", | ||
}, | ||
"establishment_siret": "42476141900045", | ||
"idcc": null, | ||
"is_delegated": false, | ||
"last_name": "last_name", | ||
"naf_code": "naf_code", | ||
"naf_label": "naf_label", | ||
"opco": "OPCO multiple", | ||
"origin": "origin", | ||
"phone": "phone", | ||
"opco": null, | ||
"status": "Actif", | ||
"updatedAt": 2021-02-03T17:00:00.000Z, | ||
} | ||
|
@@ -85,8 +65,10 @@ exports[`createJob > should insert a job 2`] = ` | |
"Apprentissage", | ||
], | ||
"managed_by": "670ce1ded6ce30c3c90a0e1d", | ||
"rome_appellation_label": "Agent administratif / Agente administrative", | ||
"rome_code": [ | ||
"M1602", | ||
], | ||
"rome_label": "Opérations administratives", | ||
} | ||
`; |
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { useMongo } from "@tests/utils/mongo.test.utils" | ||
import { saveEntrepriseUserTest } from "@tests/utils/user.test.utils" | ||
import omit from "lodash/omit" | ||
import { ObjectId } from "mongodb" | ||
import { generateJobFixture } from "shared/fixtures/recruiter.fixture" | ||
import { removeAccents } from "shared" | ||
import { RECRUITER_STATUS } from "shared/constants" | ||
import { generateEntrepriseFixture } from "shared/fixtures/entreprise.fixture" | ||
import { generateJobFixture, generateRecruiterFixture } from "shared/fixtures/recruiter.fixture" | ||
import { generateRoleManagementFixture } from "shared/fixtures/roleManagement.fixture" | ||
import { generateReferentielRome } from "shared/fixtures/rome.fixture" | ||
import { generateUserWithAccountFixture } from "shared/fixtures/userWithAccount.fixture" | ||
import { IRecruiter, IReferentielRome, IUserWithAccount } from "shared/models" | ||
import { beforeEach, describe, expect, it } from "vitest" | ||
|
||
|
@@ -20,20 +24,29 @@ describe("createJob", () => { | |
|
||
beforeEach(async () => { | ||
const email = "[email protected]" | ||
const response = await saveEntrepriseUserTest( | ||
{ | ||
_id: new ObjectId("670ce1ded6ce30c3c90a0e1d"), | ||
email, | ||
}, | ||
{}, | ||
{}, | ||
{ jobs: [], email, _id: new ObjectId("670ce30b57a50d6875c141f9"), establishment_creation_date: new Date("2024-10-14T09:23:21.588Z") } | ||
) | ||
user = response.user | ||
recruiter = response.recruiter | ||
|
||
const entreprise = generateEntrepriseFixture() | ||
const role = generateRoleManagementFixture() | ||
user = generateUserWithAccountFixture({ | ||
_id: new ObjectId("670ce1ded6ce30c3c90a0e1d"), | ||
email, | ||
}) | ||
recruiter = generateRecruiterFixture({ | ||
is_delegated: false, | ||
cfa_delegated_siret: null, | ||
status: RECRUITER_STATUS.ACTIF, | ||
establishment_siret: entreprise.siret, | ||
opco: entreprise.opco, | ||
jobs: [], | ||
email, | ||
_id: new ObjectId("670ce30b57a50d6875c141f9"), | ||
establishment_creation_date: new Date("2024-10-14T09:23:21.588Z"), | ||
}) | ||
referentielRome = generateReferentielRome() | ||
await getDbCollection("userswithaccounts").insertOne(user) | ||
await getDbCollection("referentielromes").insertOne(referentielRome) | ||
await getDbCollection("rolemanagements").insertOne(role) | ||
await getDbCollection("entreprises").insertOne(entreprise) | ||
await getDbCollection("recruiters").insertOne(recruiter) | ||
|
||
return async () => { | ||
await getDbCollection("userswithaccounts").deleteMany({}) | ||
|
@@ -48,6 +61,8 @@ describe("createJob", () => { | |
return generateJobFixture({ | ||
managed_by: user._id.toString(), | ||
rome_code: [referentielRome.rome.code_rome], | ||
rome_label: referentielRome.rome.intitule, | ||
rome_appellation_label: referentielRome.appellations[0].libelle, | ||
competences_rome: { | ||
savoir_etre_professionnel: referentielRome.competences.savoir_etre_professionnel?.slice(0, 1), | ||
savoir_faire: referentielRome.competences.savoir_faire?.slice(0, 1), | ||
|
@@ -107,4 +122,20 @@ describe("createJob", () => { | |
] | ||
expect.soft(() => createJob({ user, establishment_id: recruiter.establishment_id, job })).rejects.toThrow("compétences invalides") | ||
}) | ||
it("should raise a bad request when rome_label do not match referentiel rome", async () => { | ||
const job = generateValidJobWritable() | ||
job.rome_label = "test" | ||
expect | ||
.soft(() => createJob({ user, establishment_id: recruiter.establishment_id, job })) | ||
.rejects.toThrow( | ||
`L'intitulé du code ROME ne correspond pas au référentiel : ${removeAccents(referentielRome.rome.intitule.toLowerCase())}, reçu ${removeAccents(job.rome_label.toLowerCase())}` | ||
) | ||
}) | ||
it("should raise a bad request when rome_appellation_label do not match referentiel rome", async () => { | ||
const job = generateValidJobWritable() | ||
job.rome_appellation_label = "test" | ||
expect | ||
.soft(() => createJob({ user, establishment_id: recruiter.establishment_id, job })) | ||
.rejects.toThrow(`L'appellation du code ROME ne correspond pas au référentiel : reçu ${removeAccents(job.rome_appellation_label.toLowerCase())}`) | ||
}) | ||
}) |
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
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