-
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(lba-2262): évolution réponse à candidat (#1725)
* feat: déport logique router dans composant * fix: gestion du cas * feat: partie back wip * feat: partie front wip * feat: version cancel visuel seulement * feat: style bouton cancel * feat: aération texte * feat: téléphone optionnel * feat: modèle email * feat: cancel intention * feat: canceling ok * feat: save et cancel ok * feat: suppression immédiate intention lors de l'envoi immédiat * feat: avanti * fix: application du texte correct * feat: looks good * feat: enregistrement refusal_reasons * fix: tests * feat: job ok * feat: snap updated * fix: route auth schema * feat: rename route 1 * feat: rename route 2 * feat: jobOrCompany * feat: passage en mode pipeline * feat: stream ok * feat: factorisation et email_logs * feat: premier test ok * feat: tests controllers ok * feat: mock envoi d'email * feat: skip until mail mock is cracked * feat: tests * feat: skipping * feat: diminution de la permissivité * fix: style CTA * feat: textarea plus haute * feat: affichage conditionnel du phone * fix: détection correcte type de message * correction typo réponse négative recruteur * maj motifs refus candidature * fix: snapshot * fix: test --------- Co-authored-by: guilletmarion <[email protected]> Co-authored-by: Kevin Barnoin <[email protected]>
- Loading branch information
1 parent
3842ddb
commit 73f3296
Showing
28 changed files
with
873 additions
and
86 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
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,16 +1,20 @@ | ||
import { ObjectId } from "mongodb" | ||
import { IApplicationApiPublic, JOB_STATUS } from "shared" | ||
import { NIVEAUX_POUR_LBA, RECRUITER_STATUS } from "shared/constants" | ||
import { ApplicationIntention } from "shared/constants/application" | ||
import { LBA_ITEM_TYPE } from "shared/constants/lbaitem" | ||
import { applicationTestFile, wrongApplicationTestFile } from "shared/fixtures/application.fixture" | ||
import { applicationTestFile, generateApplicantFixture, generateApplicationFixture, wrongApplicationTestFile } from "shared/fixtures/application.fixture" | ||
import { generateRecruiterFixture } from "shared/fixtures/recruiter.fixture" | ||
import { generateLbaCompanyFixture } from "shared/fixtures/recruteurLba.fixture" | ||
import { parisFixture } from "shared/fixtures/referentiel/commune.fixture" | ||
import { generateReferentielRome } from "shared/fixtures/rome.fixture" | ||
import { generateUserWithAccountFixture } from "shared/fixtures/userWithAccount.fixture" | ||
import { describe, expect, it, vi } from "vitest" | ||
|
||
import { s3Write } from "@/common/utils/awsUtils" | ||
import { getDbCollection } from "@/common/utils/mongodbUtils" | ||
import { buildUserForToken } from "@/services/application.service" | ||
import { generateApplicationReplyToken } from "@/services/appLinks.service" | ||
import { useMongo } from "@tests/utils/mongo.test.utils" | ||
import { useServer } from "@tests/utils/server.test.utils" | ||
|
||
|
@@ -63,12 +67,19 @@ const recruteur = generateLbaCompanyFixture({ | |
last_update_at: new Date("2024-07-04T23:24:58.995Z"), | ||
}) | ||
|
||
const recruiterEmailFixture = "[email protected]" | ||
|
||
const user = generateUserWithAccountFixture({ | ||
_id: new ObjectId("670ce1ded6ce30c3c90a0e1d"), | ||
email: recruiterEmailFixture, | ||
}) | ||
|
||
const recruiter = generateRecruiterFixture({ | ||
establishment_siret: "11000001500013", | ||
establishment_raison_sociale: "ASSEMBLEE NATIONALE", | ||
geopoint: parisFixture.centre, | ||
status: RECRUITER_STATUS.ACTIF, | ||
email: "[email protected]", | ||
email: recruiterEmailFixture, | ||
jobs: [ | ||
{ | ||
rome_code: ["M1602"], | ||
|
@@ -78,6 +89,15 @@ const recruiter = generateRecruiterFixture({ | |
job_creation_date: new Date("2021-01-01"), | ||
job_expiration_date: new Date("2050-01-01"), | ||
}, | ||
{ | ||
_id: new ObjectId("64a43d28eeeb7c3b210faf59"), | ||
rome_code: ["M1602"], | ||
rome_label: "Opérations administratives", | ||
job_status: JOB_STATUS.ACTIVE, | ||
job_level_label: NIVEAUX_POUR_LBA.INDIFFERENT, | ||
job_creation_date: new Date("2021-01-01"), | ||
job_expiration_date: new Date("2050-01-01"), | ||
}, | ||
], | ||
address_detail: { | ||
code_insee_localite: parisFixture.code, | ||
|
@@ -94,10 +114,24 @@ const referentielRome = generateReferentielRome({ | |
}, | ||
}) | ||
|
||
const applicantFixture = generateApplicantFixture({}) | ||
|
||
const applicationFixture = generateApplicationFixture({ | ||
_id: new ObjectId("6081289803569600282e0001"), | ||
job_id: "64a43d28eeeb7c3b210faf59", | ||
job_origin: LBA_ITEM_TYPE.OFFRES_EMPLOI_LBA, | ||
applicant_id: applicantFixture._id, | ||
}) | ||
|
||
const userToken = buildUserForToken(applicationFixture, user) | ||
const intentionToken = generateApplicationReplyToken(userToken, applicationFixture._id.toString(), ApplicationIntention.ENTRETIEN) | ||
|
||
const mockData = async () => { | ||
await getDbCollection("recruteurslba").insertOne(recruteur) | ||
await getDbCollection("recruiters").insertOne(recruiter) | ||
await getDbCollection("referentielromes").insertOne(referentielRome) | ||
await getDbCollection("applicants").insertOne(applicantFixture) | ||
await getDbCollection("applications").insertOne(applicationFixture) | ||
} | ||
|
||
useMongo(mockData) | ||
|
@@ -152,6 +186,7 @@ describe("POST /v2/application", () => { | |
applicant_phone: body.applicant_phone, | ||
company_email: recruteur.email, | ||
company_feedback: null, | ||
company_feedback_reasons: null, | ||
company_name: "ASSEMBLEE NATIONALE", | ||
company_phone: null, | ||
company_recruitment_intention: null, | ||
|
@@ -212,6 +247,7 @@ describe("POST /v2/application", () => { | |
company_address: "Paris", | ||
company_email: "[email protected]", | ||
company_feedback: null, | ||
company_feedback_reasons: null, | ||
company_naf: "", | ||
company_name: "ASSEMBLEE NATIONALE", | ||
company_phone: "0300000000", | ||
|
@@ -254,4 +290,89 @@ describe("POST /v2/application", () => { | |
expect.soft(response.statusCode).toEqual(400) | ||
expect.soft(response.json()).toEqual({ statusCode: 400, error: "Bad Request", message: "File type is not supported" }) | ||
}) | ||
|
||
it("save scheduled intention when link in email is followed", async () => { | ||
const response = await httpClient().inject({ | ||
method: "GET", | ||
path: `/api/application/intention/schedule/6081289803569600282e0001?intention=${ApplicationIntention.ENTRETIEN}`, | ||
headers: { authorization: `Bearer ${intentionToken}` }, | ||
}) | ||
|
||
expect.soft(response.statusCode).toEqual(200) | ||
expect | ||
.soft(response.json()) | ||
.toEqual({ applicant_first_name: "a", applicant_last_name: "a", recruiter_email: "[email protected]", recruiter_phone: "0300000000" }) | ||
const intentionInDb = await getDbCollection("recruiter_intention_mails").findOne({ applicationId: new ObjectId("6081289803569600282e0001") }) | ||
expect.soft(intentionInDb).not.toEqual(null) | ||
}) | ||
|
||
it("Remove scheduled intention when cancel button", async () => { | ||
await httpClient().inject({ | ||
method: "GET", | ||
path: `/api/application/intention/schedule/6081289803569600282e0001?intention=${ApplicationIntention.ENTRETIEN}`, | ||
headers: { authorization: `Bearer ${intentionToken}` }, | ||
}) | ||
|
||
const response = await httpClient().inject({ | ||
method: "POST", | ||
path: "/api/application/intention/cancel/6081289803569600282e0001", | ||
headers: { authorization: `Bearer ${intentionToken}` }, | ||
}) | ||
|
||
expect.soft(response.statusCode).toEqual(200) | ||
expect.soft(response.json()).toEqual({ result: "ok", message: "intention canceled" }) | ||
const intentionInDb = await getDbCollection("recruiter_intention_mails").findOne({ applicationId: new ObjectId("6081289803569600282e0001") }) | ||
expect.soft(intentionInDb).toEqual(null) | ||
}) | ||
|
||
it("Remove scheduled intention when cancel button", async () => { | ||
await httpClient().inject({ | ||
method: "GET", | ||
path: `/api/application/intention/schedule/6081289803569600282e0001?intention=${ApplicationIntention.ENTRETIEN}`, | ||
headers: { authorization: `Bearer ${intentionToken}` }, | ||
}) | ||
|
||
const response = await httpClient().inject({ | ||
method: "POST", | ||
path: "/api/application/intention/cancel/6081289803569600282e0001", | ||
headers: { authorization: `Bearer ${intentionToken}` }, | ||
}) | ||
|
||
expect.soft(response.statusCode).toEqual(200) | ||
expect.soft(response.json()).toEqual({ result: "ok", message: "intention canceled" }) | ||
const intentionInDb = await getDbCollection("recruiter_intention_mails").findOne({ applicationId: new ObjectId("6081289803569600282e0001") }) | ||
expect.soft(intentionInDb).toEqual(null) | ||
}) | ||
|
||
it.skip("Remove scheduled intention when Envoyer le message button", async () => { | ||
await httpClient().inject({ | ||
method: "GET", | ||
path: `/api/application/intention/schedule/6081289803569600282e0001?intention=${ApplicationIntention.ENTRETIEN}`, | ||
headers: { authorization: `Bearer ${intentionToken}` }, | ||
}) | ||
|
||
const response = await httpClient().inject({ | ||
method: "POST", | ||
path: "/api/application/intentionComment/6081289803569600282e0001", | ||
body: { | ||
company_feedback: "Bonjour", | ||
company_recruitment_intention: ApplicationIntention.ENTRETIEN, | ||
email: "[email protected]", | ||
phone: "", | ||
refusal_reasons: [], | ||
}, | ||
headers: { authorization: `Bearer ${intentionToken}` }, | ||
}) | ||
|
||
expect.soft(response.statusCode).toEqual(200) | ||
expect.soft(response.json()).toEqual({ result: "ok", message: "comment registered" }) | ||
const intentionInDb = await getDbCollection("recruiter_intention_mails").findOne({ applicationId: new ObjectId("6081289803569600282e0001") }) | ||
expect.soft(intentionInDb).toEqual(null) | ||
const application = await getDbCollection("applications").findOne({ _id: new ObjectId("6081289803569600282e0001") }) | ||
expect.soft(application!).toMatchObject({ | ||
company_feedback_reasons: [], | ||
company_feedback: "Bonjour", | ||
company_recruitment_intention: ApplicationIntention.ENTRETIEN, | ||
}) | ||
}) | ||
}) |
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,5 @@ | ||
import { processScheduledRecruiterIntentions } from "@/services/application.service" | ||
|
||
export const processRecruiterIntentions = async () => { | ||
await processScheduledRecruiterIntentions() | ||
} |
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
Oops, something went wrong.