Skip to content

Commit

Permalink
feat: support du champs offer.status sur la création et edition d'off…
Browse files Browse the repository at this point in the history
…re (#1667)
  • Loading branch information
moroine authored Nov 26, 2024
1 parent 2e63530 commit 13bf127
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { generateLbaCompanyFixture } from "shared/fixtures/recruteurLba.fixture"
import { clichyFixture, generateReferentielCommuneFixtures, levalloisFixture, marseilleFixture, parisFixture } from "shared/fixtures/referentiel/commune.fixture"
import { generateReferentielRome } from "shared/fixtures/rome.fixture"
import { generateUserWithAccountFixture } from "shared/fixtures/userWithAccount.fixture"
import { ILbaCompany, IRecruiter, IReferentielRome, JOB_STATUS } from "shared/models"
import { ILbaCompany, IRecruiter, IReferentielRome, JOB_STATUS, JOB_STATUS_ENGLISH } from "shared/models"
import { IJobsPartnersOfferPrivate, INiveauDiplomeEuropeen } from "shared/models/jobsPartners.model"
import { zJobOfferApiWriteV3, zJobSearchApiV3Response, type IJobOfferApiWriteV3, type IJobOfferApiWriteV3Input } from "shared/routes/v3/jobs/jobs.routes.v3.model"
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"
Expand Down Expand Up @@ -1905,6 +1905,18 @@ describe("createJobOffer", () => {
expect(job?.workplace_geopoint).toEqual(clichyFixture.centre)
expect(nock.isDone()).toBeTruthy()
})

it("should support offer.status", async () => {
const data = generateJobOfferApiWriteV3({ ...minimalData, offer: { ...minimalData.offer, status: JOB_STATUS_ENGLISH.ANNULEE } })

const result = await createJobOffer(identity, data)
expect(result).toBeInstanceOf(ObjectId)

const job = await getDbCollection("jobs_partners").findOne({ _id: result })
expect(job?.offer_status).toEqual(JOB_STATUS_ENGLISH.ANNULEE)

expect(nock.isDone()).toBeTruthy()
})
})

describe("updateJobOffer", () => {
Expand Down Expand Up @@ -2042,4 +2054,15 @@ describe("updateJobOffer", () => {
expect(job?.workplace_geopoint).toEqual(clichyFixture.centre)
expect(nock.isDone()).toBeTruthy()
})

it("should support offer.status", async () => {
const data = generateJobOfferApiWriteV3({ ...minimalData, offer: { ...minimalData.offer, status: JOB_STATUS_ENGLISH.ANNULEE } })

await updateJobOffer(_id, identity, data)

const job = await getDbCollection("jobs_partners").findOne({ _id })
expect(job?.offer_status).toEqual(JOB_STATUS_ENGLISH.ANNULEE)

expect(nock.isDone()).toBeTruthy()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ async function upsertJobOffer(data: IJobOfferApiWriteV3, identity: IApiAlternanc
offer_expiration: data.offer.publication.expiration || defaultOfferExpiration,
offer_opening_count: data.offer.opening_count,
offer_origin: data.offer.origin,
offer_status: JOB_STATUS_ENGLISH.ACTIVE,
offer_status: data.offer.status,
offer_multicast: data.offer.multicast,

workplace_siret: data.workplace.siret,
Expand Down
22 changes: 22 additions & 0 deletions shared/helpers/openapi/__snapshots__/generateOpenapi.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9816,6 +9816,17 @@ Limite : 20 appel(s) / 1 seconde(s)
"null",
],
},
"status": {
"default": "Active",
"description": "Status de l'offre (surtout utilisé pour les offres ajouté par API)",
"enum": [
"Active",
"Filled",
"Cancelled",
"Pending",
],
"type": "string",
},
"target_diploma": {
"properties": {
"european": {
Expand Down Expand Up @@ -10886,6 +10897,17 @@ Limite : 20 appel(s) / 1 seconde(s)
"null",
],
},
"status": {
"default": "Active",
"description": "Status de l'offre (surtout utilisé pour les offres ajouté par API)",
"enum": [
"Active",
"Filled",
"Cancelled",
"Pending",
],
"type": "string",
},
"target_diploma": {
"properties": {
"european": {
Expand Down
19 changes: 10 additions & 9 deletions shared/routes/v3/jobs/jobs.routes.v3.model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type IJobOfferApiWriteV3Expected = {
opening_count?: number
origin?: string | null
multicast?: boolean
status?: JOB_STATUS_ENGLISH
}
apply: {
url?: string | null
Expand Down Expand Up @@ -242,16 +243,16 @@ describe("IJobOfferApiWriteV3", () => {
})
})

// describe("offer_status", () => {
// it("should be optional", () => {
// const result = zJobOfferApiWriteV3.safeParse({
// ...data,
// })
describe("offer_status", () => {
it("should be optional", () => {
const result = zJobOfferApiWriteV3.safeParse({
...data,
})

// expect(result.success).toBe(true)
// expect(result.data?.offer.status).toBe(JOB_STATUS_ENGLISH.ACTIVE)
// })
// })
expect(result.success).toBe(true)
expect(result.data?.offer.status).toBe(JOB_STATUS_ENGLISH.ACTIVE)
})
})

describe("offer_creation", () => {
// Fallback is handled in jobOpportinityService
Expand Down
2 changes: 2 additions & 0 deletions shared/routes/v3/jobs/jobs.routes.v3.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { z } from "zod"

import { TRAINING_CONTRACT_TYPE } from "../../../constants"
import { extensions } from "../../../helpers/zodHelpers/zodPrimitives"
import { JOB_STATUS_ENGLISH } from "../../../models"
import {
zDiplomaEuropeanLevel,
ZJobsPartnersOfferApi,
Expand Down Expand Up @@ -179,6 +180,7 @@ export const zJobOfferApiWriteV3 = z.object({
opening_count: ZJobsPartnersOfferPrivate.shape.offer_opening_count.default(1),
origin: ZJobsPartnersOfferPrivate.shape.offer_origin,
multicast: ZJobsPartnersOfferPrivate.shape.offer_multicast,
status: ZJobsPartnersOfferPrivate.shape.offer_status.default(JOB_STATUS_ENGLISH.ACTIVE),
}),
apply: z
.object({
Expand Down

0 comments on commit 13bf127

Please sign in to comment.