Skip to content

Commit

Permalink
Merge branch 'main' into feat-update-sentry-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
kevbarns committed Jan 16, 2025
2 parents db04159 + 9b0a963 commit 5be4a57
Show file tree
Hide file tree
Showing 70 changed files with 2,245 additions and 3,741 deletions.
8 changes: 5 additions & 3 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fileignoreconfig:
checksum: 8cdd1da6c1155f26b417a27e26311d4f00b7d8bd6c21f1f86c1c7cb3f0599e6a
- filename: server/.env.test
checksum: e03b5dac5c70accc532a744505fb928c9b2da6b233f360fe95ad127dbc0a5d6d
- filename: server/src/common/apis/apiReferentielCatalogue.fixture.ts
checksum: 845d2420a673b7fcb76c834ac58509ff5634c9910d8ed0f8304554835d6fd224
- filename: server/src/common/utils/awsUtils.ts
checksum: d7d550a8852127bd6838bd7c3f4aee9bba06731d932cff880ff2c1033578fdbd
- filename: server/src/config.ts
Expand All @@ -22,7 +24,7 @@ fileignoreconfig:
- filename: server/src/db/migrations/202405230000000-migrate-fix-missing-date-blacklist.ts
checksum: 0c1b814245a58b8ca788fbfab9899206edbddaae795d56963f86c5aa83ea555f
- filename: server/src/http/controllers/__snapshots__/etablissementRecruteur.controller.test.ts.snap
checksum: e8a35e591adb1447d1b6e796b063f435ac389e9ffe619c68185f348beae71215
checksum: 7bf9d206d0ed729df96134d4238d2cecc5b87ce2f8273bc32d95a7609a23afab
- filename: server/src/http/controllers/application.controller.test.ts
checksum: 00cac67c8e138098126ae98702e2bdc3e1092e1bbf188d9a437197e9ca94e16a
- filename: server/src/http/controllers/appointments/appointments.controller.ts
Expand All @@ -34,9 +36,9 @@ fileignoreconfig:
- filename: server/src/http/controllers/user.controller.test.ts
checksum: e01d1b9c54d1e6d0c98fd7984f32c3a93f3e9bde92887bdab320cb7af91fdd92
- filename: server/src/http/controllers/v2/applications.controller.v2.test.ts
checksum: 9147c705b5bdfe6eff6b1b75c467249ee1af783d57ff16d78722e48e60831c68
checksum: af3286368a305384cae3151698d863167d9f2b9e206d7063625c22595289ea3b
- filename: server/src/http/controllers/v2/appointment.controller.v2.test.ts
checksum: 72502c3acc46f9b6903b69095518c3d865cf437f311ed14585da04d8440b4ac0
checksum: bbbf100d65bae0d840c715f4b1d893986df7423f470f3ee300545959105f6ca4
- filename: server/src/http/controllers/v2/jobs.controller.v2.test.ts
checksum: a99bfdcb5a8f4c66e9d055b44160adbc7ec2bcaf87209ff76fa9a9f674b9ca86
- filename: server/src/http/controllers/v2/jobs.controller.v2.ts
Expand Down
181 changes: 181 additions & 0 deletions server/src/common/apis/apiReferentielCatalogue.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
export const apiReferentielCatalogueFixture = {
siret: "52151363000017",
_meta: {
anomalies: [
{ key: "500", type: "erreur", details: "[SireneApi] Request failed with status code 500", job: "collect", sources: ["sirene"], date_collecte: "2023-10-02T04:12:20.357Z" },
{ key: "ECONNRESET", type: "erreur", details: "[SireneApi] read ECONNRESET", job: "collect", sources: ["sirene"], date_collecte: "2023-06-05T04:11:07.419Z" },
{
key: "ENOTFOUND",
type: "erreur",
details: "[SireneApi] getaddrinfo ENOTFOUND api.insee.fr",
job: "collect",
sources: ["sirene"],
date_collecte: "2023-05-04T04:11:39.640Z",
},
{
key: "ETIMEDOUT",
type: "erreur",
details: "[SireneApi] connect ETIMEDOUT 143.196.255.207:443",
job: "collect",
sources: ["sirene"],
date_collecte: "2022-10-17T12:16:47.914Z",
},
],
date_import: "2021-12-17T18:17:55.829Z",
date_dernier_import: "2025-01-16T05:03:08.761Z",
date_collecte: "2025-01-16T05:07:58.002Z",
uai_probable: "0561986E",
nouveau: false,
},
certifications: [
{
type: "rncp",
code: "RNCP28573",
label: "Brevet Professionnel de la Jeunesse, de l'Éducation Populaire et du Sport - spécialité Éducateur Sportif - 8 mentions( cf liste dans base légale)",
sources: ["catalogue"],
date_collecte: "2025-01-09T04:44:35.642Z",
},
{
type: "rncp",
code: "RNCP35901",
label: "Brevet professionnel de la jeunesse, de l’éducation populaire et du sport spécialité « éducateur sportif » mention parachutisme",
sources: ["catalogue"],
date_collecte: "2025-01-15T04:38:56.255Z",
},
{
type: "rncp",
code: "RNCP36248",
label: "spécialité « éducateur sportif » mention «Activités aquatiques et de la natation »",
sources: ["catalogue"],
date_collecte: "2025-01-16T04:39:34.561Z",
},
{
type: "rncp",
code: "RNCP36249",
label: "BP-brevet professionnel de la jeunesse, de l'éducation populaire et du sport spécialité éducateur sportif mention rugby à XV",
sources: ["catalogue"],
date_collecte: "2025-01-16T04:39:34.543Z",
},
{
type: "rncp",
code: "RNCP36957",
label: "Brevet professionnel de la jeunesse, de l’éducation populaire et du sport spécialité « éducateur sportif » mention « aviron et disciplines associées »",
sources: ["catalogue"],
date_collecte: "2025-01-10T04:38:54.864Z",
},
{
type: "rncp",
code: "RNCP36958",
label: "brevet professionnel de la jeunesse, de l’éducation populaire et du sport spécialité « éducateur sportif » mention « tennis de table »",
sources: ["catalogue"],
date_collecte: "2025-01-14T04:38:59.932Z",
},
{
type: "rncp",
code: "RNCP37106",
label: "Brevet professionnel de la jeunesse, de l'éducation populaire et du sportspécialité « éducateur sportif » mention « activités de la forme »",
sources: ["catalogue"],
date_collecte: "2025-01-16T04:45:42.947Z",
},
{
type: "rncp",
code: "RNCP37191",
label: "Brevet professionnel de la jeunesse, de l’éducation populaire et du sport spécialité « éducateur sportif » mention « activités physiques pour tous »",
sources: ["catalogue"],
date_collecte: "2025-01-16T04:45:46.290Z",
},
{
type: "rncp",
code: "RNCP37387",
label: "Brevet professionnel de la jeunesse, de l’éducation populaire et du sport spécialité « éducateur sportif » mention « lutte et disciplines associées »",
sources: ["catalogue"],
date_collecte: "2025-01-16T04:39:34.316Z",
},
{
type: "rncp",
code: "RNCP37477",
label:
"Brevet professionnel de la jeunesse, de l’éducation populaire et du sport spécialité « éducateur sportif » mention « ski nautique-wakeboard, disciplines associées et tous supports de glisse tractés »",
sources: ["catalogue"],
date_collecte: "2025-01-11T04:38:59.645Z",
},
{
type: "rncp",
code: "RNCP39926",
label: "Spécialité Animateur mention Animation socio-éducative ou culturelle",
sources: ["catalogue"],
date_collecte: "2025-01-16T04:30:06.597Z",
},
],
contacts: [
{ email: "[email protected]", confirmé: false, sources: ["catalogue"], date_collecte: "2025-01-16T04:30:06.597Z" },
{ email: "[email protected]", confirmé: false, sources: ["acce"], date_collecte: "2025-01-15T05:47:52.786Z" },
],
diplomes: [
{ type: "cfd", code: "44633506", niveau: "446", label: "BP JEPS", sources: ["catalogue"], date_collecte: "2025-01-16T04:45:46.290Z" },
{ type: "cfd", code: "44633518", niveau: "446", label: "BP JEPS", sources: ["catalogue"], date_collecte: "2025-01-16T04:39:34.561Z" },
{ type: "cfd", code: "44633522", niveau: "446", label: "BP JEPS", sources: ["catalogue"], date_collecte: "2025-01-16T04:39:34.542Z" },
{ type: "cfd", code: "44633523", niveau: "446", label: "BP JEPS", sources: ["catalogue"], date_collecte: "2025-01-16T04:30:06.597Z" },
{ type: "cfd", code: "44633524", niveau: "446", label: "BP JEPS", sources: ["catalogue"], date_collecte: "2025-01-16T04:39:34.316Z" },
{ type: "cfd", code: "44633527", niveau: "446", label: "BP JEPS", sources: ["catalogue"], date_collecte: "2025-01-16T04:45:42.947Z" },
],
lieux_de_formation: [
{
code: "-2.5899487_47.7327681",
adresse: {
label: "-2.5899487_47.7327681",
code_postal: "56250",
code_insee: "56053",
localite: "Elven",
geojson: { type: "Feature", geometry: { type: "Point", coordinates: [-2.589803, 47.732663] }, properties: { score: 0.9999998980024534, source: "geo-adresse-api" } },
departement: { code: "56", nom: "Morbihan" },
region: { code: "53", nom: "Bretagne" },
academie: { code: "14", nom: "Rennes" },
},
uai: "0561986E",
uai_fiable: false,
sources: ["catalogue"],
date_collecte: "2025-01-16T04:45:46.290Z",
siret: "52151363000017",
},
{
code: "-2.752094_48.185211",
adresse: {
label: "-2.752094_48.185211",
code_postal: "22600",
code_insee: "22136",
localite: "Loudéac",
geojson: { type: "Feature", geometry: { type: "Point", coordinates: [-2.75207, 48.185268] }, properties: { score: 0.9999999826867761, source: "geo-adresse-api" } },
departement: { code: "22", nom: "Côtes-d'Armor" },
region: { code: "53", nom: "Bretagne" },
academie: { code: "14", nom: "Rennes" },
},
uai_fiable: false,
sources: ["catalogue"],
date_collecte: "2025-01-16T04:45:46.276Z",
},
],
referentiels: ["catalogue-etablissements", "datagouv"],
relations: [],
reseaux: [],
uai_potentiels: [{ uai: "0561986E", sources: ["deca", "tableau-de-bord", "catalogue-etablissements", "ideo2"], date_collecte: "2025-01-16T05:08:33.449Z" }],
etat_administratif: "actif",
forme_juridique: { code: "5710", label: "SAS, société par actions simplifiée" },
raison_sociale: "INSTITUT BRETON DU SPORT ET DE L'ANIMATION",
siege_social: true,
enseigne: "IBSA FORMATION",
adresse: {
academie: { code: "14", nom: "Rennes" },
code_insee: "56053",
code_postal: "56250",
departement: { code: "56", nom: "Morbihan" },
geojson: { geometry: { coordinates: [-2.585947, 47.749302], type: "Point" }, properties: { score: 0.6743845454545453, source: "geo-adresse-api" }, type: "Feature" },
label: "PONT BILIO 56250 ELVEN",
localite: "Elven",
region: { code: "53", nom: "Bretagne" },
},
nature: "responsable_formateur",
numero_declaration_activite: "53560851656",
qualiopi: true,
uai: "0561986E",
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ exports[`POST /etablissement/creation > Création d'entreprise > Vérifie que le
}
`;

exports[`POST /etablissement/creation > Création de CFA > Vérifie qu un email ne peut pas créer 2 comptes CFA 1`] = `
{
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"origin": "lba",
"phone": "0612345678",
}
`;

exports[`POST /etablissement/creation > Création de CFA > Vérifie que le CFA est créé 1`] = `
{
"email": "[email protected]",
Expand Down
14 changes: 10 additions & 4 deletions server/src/http/controllers/application.controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { omit } from "lodash-es"
import { ObjectId } from "mongodb"
import { generateLbaCompanyFixture } from "shared/fixtures/recruteurLba.fixture"
import { beforeEach, describe, expect, it, vi } from "vitest"
Expand Down Expand Up @@ -86,20 +87,25 @@ describe("POST /v1/application", () => {
const applications = await getDbCollection("applications").find({}).toArray()
const applicant = await getDbCollection("applicants").findOne({ _id: applications[0]?.applicant_id })

expect(omit(applicant, ["createdAt", "last_connection", "updatedAt"])).toEqual({
_id: applicant?._id,
email: body.applicant_email,
firstname: body.applicant_first_name,
lastname: body.applicant_last_name,
phone: body.applicant_phone,
})

expect(applications).toEqual([
{
_id: expect.any(ObjectId),
applicant_id: applicant?._id,
applicant_attachment_name: body.applicant_file_name,
applicant_email: body.applicant_email,
applicant_first_name: body.applicant_first_name,
applicant_last_name: body.applicant_last_name,
applicant_message_to_company: "",
applicant_phone: body.applicant_phone,
caller: body.caller,
company_address: "126 RUE DE L UNIVERSITE, 75007 Paris",
company_email: recruteur.email,
company_feedback: null,
company_feedback_reasons: null,
company_naf: "Administration publique générale",
company_name: "ASSEMBLEE NATIONALE",
company_phone: null,
Expand Down
61 changes: 37 additions & 24 deletions server/src/http/controllers/application.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { notFound } from "@hapi/boom"
import { ObjectId } from "mongodb"
import { oldItemTypeToNewItemType } from "shared/constants/lbaitem"
import { zRoutes } from "shared/index"

import { getDbCollection } from "../../common/utils/mongodbUtils"
import { getApplicantFromDB } from "../../services/applicant.service"
import { getCompanyEmailFromToken, sendApplication, sendMailToApplicant } from "../../services/application.service"
import { getApplicationDataForIntentionAndScheduleMessage, getCompanyEmailFromToken, sendApplication, sendRecruiterIntention } from "../../services/application.service"
import { Server } from "../server"

const rateLimitConfig = {
Expand Down Expand Up @@ -59,36 +57,37 @@ export default function (server: Server) {
},
async (req, res) => {
const { id } = req.params
const { company_recruitment_intention, company_feedback, email, phone } = req.body
const { company_recruitment_intention, company_feedback, email, phone, refusal_reasons } = req.body

const application = await getDbCollection("applications").findOneAndUpdate(
{ _id: new ObjectId(id) },
{ $set: { company_recruitment_intention, company_feedback, company_feedback_date: new Date() } }
)

if (!application) {
throw notFound()
}

const applicant = await getApplicantFromDB({ _id: application.applicant_id })

if (!applicant) {
throw notFound(`unexpected: applicant not found for application ${application._id}`)
}

await sendMailToApplicant({
application,
applicant,
email,
phone,
await sendRecruiterIntention({
application_id: new ObjectId(id),
company_recruitment_intention,
company_feedback,
email,
phone,
refusal_reasons,
})

return res.status(200).send({ result: "ok", message: "comment registered" })
}
)

server.post(
"/application/intention/cancel/:id",
{
schema: zRoutes.post["/application/intention/cancel/:id"],
onRequest: server.auth(zRoutes.post["/application/intention/cancel/:id"]),
config: rateLimitConfig,
},
async (req, res) => {
const { id } = req.params

await getDbCollection("recruiter_intention_mails").deleteOne({ applicationId: new ObjectId(id) })

return res.status(200).send({ result: "ok", message: "intention canceled" })
}
)

server.post(
"/application/intention/:id",
{
Expand Down Expand Up @@ -121,4 +120,18 @@ export default function (server: Server) {
return res.status(200).send({ company_email })
}
)

server.get(
"/application/intention/schedule/:id",
{
schema: zRoutes.get["/application/intention/schedule/:id"],
onRequest: server.auth(zRoutes.get["/application/intention/schedule/:id"]),
},
async (req, res) => {
const { id } = req.params
const { intention } = req.query
const data = await getApplicationDataForIntentionAndScheduleMessage(id, intention)
return res.status(200).send({ ...data })
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { zRoutes } from "shared/routes"
import { beforeEach, describe, expect, it } from "vitest"

import { apiEntrepriseEtablissementFixture } from "@/common/apis/apiEntreprise/apiEntreprise.client.fixture"
import { apiReferentielCatalogueFixture } from "@/common/apis/apiReferentielCatalogue.fixture"
import { getDbCollection } from "@/common/utils/mongodbUtils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
Expand All @@ -21,8 +22,12 @@ describe("POST /etablissement/creation", () => {
.persist()
.get(new RegExp("/sirene/etablissements/diffusibles/", "g"))
.reply(200, apiEntrepriseEtablissementFixture.dinum)

const mockCfa = nock("https://referentiel.apprentissage.beta.gouv.fr").persist().get(new RegExp("/api/v1/organismes/[0-9]+", "g")).reply(200, apiReferentielCatalogueFixture)

return async () => {
mockEntreprise.persist(false)
mockCfa.persist(false)
await getDbCollection("recruiters").deleteMany()
await getDbCollection("rolemanagements").deleteMany()
await getDbCollection("entreprises").deleteMany()
Expand Down
4 changes: 2 additions & 2 deletions server/src/http/controllers/formations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export default (server: Server) => {
)

server.get(
"/v1/formations/min",
"/v1/_private/formations/min",
{
schema: zRoutes.get["/v1/formations/min"],
schema: zRoutes.get["/v1/_private/formations/min"],
config,
},
async (req, res) => {
Expand Down
Loading

0 comments on commit 5be4a57

Please sign in to comment.