diff --git a/packages/reva-api/package.json b/packages/reva-api/package.json index a8aaab9bd..1a4586824 100644 --- a/packages/reva-api/package.json +++ b/packages/reva-api/package.json @@ -21,7 +21,7 @@ "prisma:generate:migration": "prisma migrate dev --create-only", "cron": "npx tsx@4.7.0 infra/cron.ts", "cron-dev": "npx tsx@4.7.0 infra/cron.ts | npx pino-pretty", - "lint": "eslint --color modules infra" + "lint": "eslint --color modules infra test scripts prisma/seed" }, "prisma": { "seed": "npx tsx prisma/seed/seed.ts" diff --git a/packages/reva-api/prisma/seed/referentials/seed-formacodes.ts b/packages/reva-api/prisma/seed/referentials/seed-formacodes.ts index 3078c1eb5..fdf5c1297 100644 --- a/packages/reva-api/prisma/seed/referentials/seed-formacodes.ts +++ b/packages/reva-api/prisma/seed/referentials/seed-formacodes.ts @@ -228,7 +228,7 @@ function readCsvRows({ }); } -export async function seedFormacode() { +async function seedFormacode() { const prisma = new PrismaClient(); await prisma.$transaction( diff --git a/packages/reva-api/prisma/seed/referentials/table-basic-skills.ts b/packages/reva-api/prisma/seed/referentials/table-basic-skills.ts index 172405b83..64e65d3db 100644 --- a/packages/reva-api/prisma/seed/referentials/table-basic-skills.ts +++ b/packages/reva-api/prisma/seed/referentials/table-basic-skills.ts @@ -8,7 +8,8 @@ export async function insertBasicSkillsIfNone(prisma: PrismaClient) { data: [ { label: "Usage et communication numérique" }, { - label: "Utilisation des règles de base de calcul et du raisonnement mathématique", + label: + "Utilisation des règles de base de calcul et du raisonnement mathématique", }, { label: "Communication en français" }, ], diff --git a/packages/reva-api/prisma/seed/referentials/table-vulnerability-indicators.ts b/packages/reva-api/prisma/seed/referentials/table-vulnerability-indicators.ts index c8a068cec..e615cc793 100644 --- a/packages/reva-api/prisma/seed/referentials/table-vulnerability-indicators.ts +++ b/packages/reva-api/prisma/seed/referentials/table-vulnerability-indicators.ts @@ -1,7 +1,10 @@ import { PrismaClient } from "@prisma/client"; -export async function insertVulnerabilityIndicatorsIfNone(prisma: PrismaClient) { - const vulnerabilityIndicatorsCount = await prisma.vulnerabilityIndicator.count(); +export async function insertVulnerabilityIndicatorsIfNone( + prisma: PrismaClient, +) { + const vulnerabilityIndicatorsCount = + await prisma.vulnerabilityIndicator.count(); if (vulnerabilityIndicatorsCount === 0) { await prisma.vulnerabilityIndicator.createMany({ diff --git a/packages/reva-api/test/fixtures/index.ts b/packages/reva-api/test/fixtures/index.ts index 3b711124a..6b4f8c7f2 100644 --- a/packages/reva-api/test/fixtures/index.ts +++ b/packages/reva-api/test/fixtures/index.ts @@ -1,6 +1,6 @@ -export * from "./basic-skills.fixtures"; -export * from "./candidacies.fixture"; -export * from "./feasibilities.fixture"; -export * from "./funding-requests.fixture"; -export * from "./payment-requests.fixture"; -export * from "./trainings.fixture"; +export * from "./basic-skills.fixtures"; +export * from "./candidacies.fixture"; +export * from "./feasibilities.fixture"; +export * from "./funding-requests.fixture"; +export * from "./payment-requests.fixture"; +export * from "./trainings.fixture"; diff --git a/packages/reva-api/test/fixtures/payment-requests.fixture.ts b/packages/reva-api/test/fixtures/payment-requests.fixture.ts index cd895dda6..41f75a763 100644 --- a/packages/reva-api/test/fixtures/payment-requests.fixture.ts +++ b/packages/reva-api/test/fixtures/payment-requests.fixture.ts @@ -1,15 +1,15 @@ -export const PAYMENT_REQUEST = { - individualEffectiveHourCount: 0, - individualEffectiveCost: 0, - collectiveEffectiveHourCount: 0, - collectiveEffectiveCost: 0, - mandatoryTrainingsEffectiveHourCount: 0, - mandatoryTrainingsEffectiveCost: 0, - basicSkillsEffectiveHourCount: 0, - basicSkillsEffectiveCost: 0, - certificateSkillsEffectiveHourCount: 0, - certificateSkillsEffectiveCost: 0, - otherTrainingEffectiveHourCount: 0, - otherTrainingEffectiveCost: 0, - invoiceNumber: "Invoice-001", -}; +export const PAYMENT_REQUEST = { + individualEffectiveHourCount: 0, + individualEffectiveCost: 0, + collectiveEffectiveHourCount: 0, + collectiveEffectiveCost: 0, + mandatoryTrainingsEffectiveHourCount: 0, + mandatoryTrainingsEffectiveCost: 0, + basicSkillsEffectiveHourCount: 0, + basicSkillsEffectiveCost: 0, + certificateSkillsEffectiveHourCount: 0, + certificateSkillsEffectiveCost: 0, + otherTrainingEffectiveHourCount: 0, + otherTrainingEffectiveCost: 0, + invoiceNumber: "Invoice-001", +}; diff --git a/packages/reva-api/test/helpers/attach-organism-to-all-ccn-helper.ts b/packages/reva-api/test/helpers/attach-organism-to-all-ccn-helper.ts index 85fdb3fd0..8a5a50a87 100644 --- a/packages/reva-api/test/helpers/attach-organism-to-all-ccn-helper.ts +++ b/packages/reva-api/test/helpers/attach-organism-to-all-ccn-helper.ts @@ -1,16 +1,16 @@ -import { Organism } from "@prisma/client"; -import { prismaClient } from "../../prisma/client"; - -export async function attachOrganismToAllConventionCollectiveHelper( - organism: Organism | null, -) { - const ccn = await prismaClient.conventionCollective.findMany(); - for (const c of ccn) { - await prismaClient.organismOnConventionCollective.create({ - data: { - organismId: organism?.id || "", - ccnId: c.id, - }, - }); - } -} +import { Organism } from "@prisma/client"; +import { prismaClient } from "../../prisma/client"; + +export async function attachOrganismToAllConventionCollectiveHelper( + organism: Organism | null, +) { + const ccn = await prismaClient.conventionCollective.findMany(); + for (const c of ccn) { + await prismaClient.organismOnConventionCollective.create({ + data: { + organismId: organism?.id || "", + ccnId: c.id, + }, + }); + } +} diff --git a/packages/reva-api/test/helpers/attach-organism-to-all-degrees-helper.ts b/packages/reva-api/test/helpers/attach-organism-to-all-degrees-helper.ts index b8d8dbbcf..a56393951 100644 --- a/packages/reva-api/test/helpers/attach-organism-to-all-degrees-helper.ts +++ b/packages/reva-api/test/helpers/attach-organism-to-all-degrees-helper.ts @@ -1,16 +1,16 @@ -import { Organism } from "@prisma/client"; -import { prismaClient } from "../../prisma/client"; - -export async function attachOrganismToAllDegreesHelper( - organism: Organism | null, -) { - const degrees = await prismaClient.degree.findMany(); - for (const degree of degrees) { - await prismaClient.organismOnDegree.create({ - data: { - degreeId: degree?.id || "", - organismId: organism?.id || "", - }, - }); - } -} +import { Organism } from "@prisma/client"; +import { prismaClient } from "../../prisma/client"; + +export async function attachOrganismToAllDegreesHelper( + organism: Organism | null, +) { + const degrees = await prismaClient.degree.findMany(); + for (const degree of degrees) { + await prismaClient.organismOnDegree.create({ + data: { + degreeId: degree?.id || "", + organismId: organism?.id || "", + }, + }); + } +} diff --git a/packages/reva-api/test/helpers/entities/create-account-helper.ts b/packages/reva-api/test/helpers/entities/create-account-helper.ts index 737b2f7ce..31ac7467a 100644 --- a/packages/reva-api/test/helpers/entities/create-account-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-account-helper.ts @@ -1,14 +1,14 @@ -import { faker } from "@faker-js/faker"; -import { Account } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; - -export const createAccountHelper = async (accountArgs?: Partial) => - prismaClient.account.create({ - data: { - email: faker.internet.email(), - firstname: faker.person.firstName(), - lastname: faker.person.lastName(), - keycloakId: faker.string.uuid(), - ...accountArgs, - }, - }); +import { faker } from "@faker-js/faker"; +import { Account } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; + +export const createAccountHelper = async (accountArgs?: Partial) => + prismaClient.account.create({ + data: { + email: faker.internet.email(), + firstname: faker.person.firstName(), + lastname: faker.person.lastName(), + keycloakId: faker.string.uuid(), + ...accountArgs, + }, + }); diff --git a/packages/reva-api/test/helpers/entities/create-candidacy-drop-out-helper.ts b/packages/reva-api/test/helpers/entities/create-candidacy-drop-out-helper.ts index 854ddab1f..112373b07 100644 --- a/packages/reva-api/test/helpers/entities/create-candidacy-drop-out-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-candidacy-drop-out-helper.ts @@ -1,33 +1,33 @@ -import { CandidacyDropOut } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; -import { createCandidacyHelper } from "./create-candidacy-helper"; -import { createDropOutReasonHelper } from "./create-drop-out-reason-helper"; - -export const createCandidacyDropOutHelper = async ( - args?: Partial, -) => { - //either take the candidacy whose id is passed in args or create a new one - const candidacy = args?.candidacyId - ? await prismaClient.candidacy.findUnique({ - where: { id: args.candidacyId }, - }) - : await createCandidacyHelper(); - - if (!candidacy) { - throw new Error("candidacy not found"); - } - const dropOutReason = await createDropOutReasonHelper(); - - return prismaClient.candidacyDropOut.create({ - data: { - status: candidacy?.status, - candidacyId: candidacy.id, - dropOutReasonId: dropOutReason.id, - ...args, - }, - include: { - candidacy: true, - dropOutReason: true, - }, - }); -}; +import { CandidacyDropOut } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; +import { createCandidacyHelper } from "./create-candidacy-helper"; +import { createDropOutReasonHelper } from "./create-drop-out-reason-helper"; + +export const createCandidacyDropOutHelper = async ( + args?: Partial, +) => { + //either take the candidacy whose id is passed in args or create a new one + const candidacy = args?.candidacyId + ? await prismaClient.candidacy.findUnique({ + where: { id: args.candidacyId }, + }) + : await createCandidacyHelper(); + + if (!candidacy) { + throw new Error("candidacy not found"); + } + const dropOutReason = await createDropOutReasonHelper(); + + return prismaClient.candidacyDropOut.create({ + data: { + status: candidacy?.status, + candidacyId: candidacy.id, + dropOutReasonId: dropOutReason.id, + ...args, + }, + include: { + candidacy: true, + dropOutReason: true, + }, + }); +}; diff --git a/packages/reva-api/test/helpers/entities/create-candidate-helper.ts b/packages/reva-api/test/helpers/entities/create-candidate-helper.ts index fa8dad113..02d4bc236 100644 --- a/packages/reva-api/test/helpers/entities/create-candidate-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-candidate-helper.ts @@ -1,35 +1,35 @@ -import { faker } from "@faker-js/faker"; -import { Candidate, Gender } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; - -export const createCandidateHelper = async ( - candidateArgs?: Partial, -): Promise => { - const parisDepartment = await prismaClient.department.findFirst({ - where: { code: "75" }, - }); - - return prismaClient.candidate.create({ - data: { - firstname: faker.person.firstName(), - lastname: faker.person.lastName(), - email: faker.internet.email(), - gender: Gender.man, - keycloakId: faker.string.uuid(), - firstname2: faker.person.middleName(), - firstname3: faker.person.middleName(), - phone: faker.phone.number(), - birthdate: faker.date.past(), - birthCity: faker.location.city(), - nationality: faker.lorem.word(), - highestDegreeLabel: faker.lorem.word(), - street: faker.location.streetAddress(), - city: faker.location.city(), - zip: faker.string.numeric(5), - addressComplement: faker.lorem.word(), - givenName: faker.person.fullName(), - departmentId: parisDepartment?.id ?? "", - ...candidateArgs, - }, - }); -}; +import { faker } from "@faker-js/faker"; +import { Candidate, Gender } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; + +export const createCandidateHelper = async ( + candidateArgs?: Partial, +): Promise => { + const parisDepartment = await prismaClient.department.findFirst({ + where: { code: "75" }, + }); + + return prismaClient.candidate.create({ + data: { + firstname: faker.person.firstName(), + lastname: faker.person.lastName(), + email: faker.internet.email(), + gender: Gender.man, + keycloakId: faker.string.uuid(), + firstname2: faker.person.middleName(), + firstname3: faker.person.middleName(), + phone: faker.phone.number(), + birthdate: faker.date.past(), + birthCity: faker.location.city(), + nationality: faker.lorem.word(), + highestDegreeLabel: faker.lorem.word(), + street: faker.location.streetAddress(), + city: faker.location.city(), + zip: faker.string.numeric(5), + addressComplement: faker.lorem.word(), + givenName: faker.person.fullName(), + departmentId: parisDepartment?.id ?? "", + ...candidateArgs, + }, + }); +}; diff --git a/packages/reva-api/test/helpers/entities/create-certification-authority-structure-helper.ts b/packages/reva-api/test/helpers/entities/create-certification-authority-structure-helper.ts index 4b7543d03..af134433e 100644 --- a/packages/reva-api/test/helpers/entities/create-certification-authority-structure-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-certification-authority-structure-helper.ts @@ -1,13 +1,13 @@ -import { faker } from "@faker-js/faker/."; -import { CertificationAuthorityStructure } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; - -export const createCertificationAuthorityStructureHelper = async ( - args?: Partial, -) => - prismaClient.certificationAuthorityStructure.create({ - data: { - label: faker.lorem.sentence(), - ...args, - }, - }); +import { faker } from "@faker-js/faker/."; +import { CertificationAuthorityStructure } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; + +export const createCertificationAuthorityStructureHelper = async ( + args?: Partial, +) => + prismaClient.certificationAuthorityStructure.create({ + data: { + label: faker.lorem.sentence(), + ...args, + }, + }); diff --git a/packages/reva-api/test/helpers/entities/create-convention-collective-helper.ts b/packages/reva-api/test/helpers/entities/create-convention-collective-helper.ts index b0696773a..b84ed1f74 100644 --- a/packages/reva-api/test/helpers/entities/create-convention-collective-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-convention-collective-helper.ts @@ -1,14 +1,14 @@ -import { faker } from "@faker-js/faker/."; -import { prismaClient } from "../../../prisma/client"; -import { ConventionCollective } from "@prisma/client"; - -export const createCCNHelper = async ( - ccnArgs?: Partial, -) => - prismaClient.conventionCollective.create({ - data: { - code: faker.string.numeric(5), - label: faker.company.name(), - ...ccnArgs, - }, - }); +import { faker } from "@faker-js/faker/."; +import { prismaClient } from "../../../prisma/client"; +import { ConventionCollective } from "@prisma/client"; + +export const createCCNHelper = async ( + ccnArgs?: Partial, +) => + prismaClient.conventionCollective.create({ + data: { + code: faker.string.numeric(5), + label: faker.company.name(), + ...ccnArgs, + }, + }); diff --git a/packages/reva-api/test/helpers/entities/create-drop-out-reason-helper.ts b/packages/reva-api/test/helpers/entities/create-drop-out-reason-helper.ts index b05f4da2b..8dd109297 100644 --- a/packages/reva-api/test/helpers/entities/create-drop-out-reason-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-drop-out-reason-helper.ts @@ -1,13 +1,13 @@ -import { faker } from "@faker-js/faker/."; -import { DropOutReason } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; - -export const createDropOutReasonHelper = async ( - args?: Partial, -) => - prismaClient.dropOutReason.create({ - data: { - label: faker.lorem.sentence(), - ...args, - }, - }); +import { faker } from "@faker-js/faker/."; +import { DropOutReason } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; + +export const createDropOutReasonHelper = async ( + args?: Partial, +) => + prismaClient.dropOutReason.create({ + data: { + label: faker.lorem.sentence(), + ...args, + }, + }); diff --git a/packages/reva-api/test/helpers/entities/create-feasibility-dematerialized-helper.ts b/packages/reva-api/test/helpers/entities/create-feasibility-dematerialized-helper.ts index db8b13c3e..195019f45 100644 --- a/packages/reva-api/test/helpers/entities/create-feasibility-dematerialized-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-feasibility-dematerialized-helper.ts @@ -1,29 +1,29 @@ -import { Feasibility, FeasibilityFormat } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; -import { createCandidacyHelper } from "./create-candidacy-helper"; - -export const createFeasibilityDematerializedHelper = async ( - feasibilityArgs?: Partial, -) => { - const candidacy = await createCandidacyHelper(); - - return prismaClient.feasibility.create({ - data: { - candidacyId: feasibilityArgs?.candidacyId ?? candidacy.id, - feasibilityFormat: FeasibilityFormat.DEMATERIALIZED, - dematerializedFeasibilityFile: { - create: {}, - }, - ...feasibilityArgs, - }, - include: { - dematerializedFeasibilityFile: true, - candidacy: { - include: { - organism: { include: { accounts: true } }, - candidate: true, - }, - }, - }, - }); -}; +import { Feasibility, FeasibilityFormat } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; +import { createCandidacyHelper } from "./create-candidacy-helper"; + +export const createFeasibilityDematerializedHelper = async ( + feasibilityArgs?: Partial, +) => { + const candidacy = await createCandidacyHelper(); + + return prismaClient.feasibility.create({ + data: { + candidacyId: feasibilityArgs?.candidacyId ?? candidacy.id, + feasibilityFormat: FeasibilityFormat.DEMATERIALIZED, + dematerializedFeasibilityFile: { + create: {}, + }, + ...feasibilityArgs, + }, + include: { + dematerializedFeasibilityFile: true, + candidacy: { + include: { + organism: { include: { accounts: true } }, + candidate: true, + }, + }, + }, + }); +}; diff --git a/packages/reva-api/test/helpers/entities/create-feasibility-uploaded-pdf-helper.ts b/packages/reva-api/test/helpers/entities/create-feasibility-uploaded-pdf-helper.ts index ff2900b4e..8621c75bf 100644 --- a/packages/reva-api/test/helpers/entities/create-feasibility-uploaded-pdf-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-feasibility-uploaded-pdf-helper.ts @@ -1,34 +1,34 @@ -import { Feasibility } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; -import { createCandidacyHelper } from "./create-candidacy-helper"; -import { createFileHelper } from "./create-file-helper"; - -export const createFeasibilityUploadedPdfHelper = async ( - feasibilityArgs?: Partial, -) => { - const candidacy = await createCandidacyHelper(); - const file = await createFileHelper(); - - return prismaClient.feasibility.create({ - data: { - candidacyId: feasibilityArgs?.candidacyId ?? candidacy.id, - feasibilityUploadedPdf: { - create: { - feasibilityFileId: file.id, - }, - }, - ...feasibilityArgs, - }, - include: { - feasibilityUploadedPdf: true, - candidacy: { - include: { - organism: { include: { accounts: true } }, - candidate: true, - department: true, - certification: true, - }, - }, - }, - }); -}; +import { Feasibility } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; +import { createCandidacyHelper } from "./create-candidacy-helper"; +import { createFileHelper } from "./create-file-helper"; + +export const createFeasibilityUploadedPdfHelper = async ( + feasibilityArgs?: Partial, +) => { + const candidacy = await createCandidacyHelper(); + const file = await createFileHelper(); + + return prismaClient.feasibility.create({ + data: { + candidacyId: feasibilityArgs?.candidacyId ?? candidacy.id, + feasibilityUploadedPdf: { + create: { + feasibilityFileId: file.id, + }, + }, + ...feasibilityArgs, + }, + include: { + feasibilityUploadedPdf: true, + candidacy: { + include: { + organism: { include: { accounts: true } }, + candidate: true, + department: true, + certification: true, + }, + }, + }, + }); +}; diff --git a/packages/reva-api/test/helpers/entities/create-file-helper.ts b/packages/reva-api/test/helpers/entities/create-file-helper.ts index 2a26f645f..e2e6f78c7 100644 --- a/packages/reva-api/test/helpers/entities/create-file-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-file-helper.ts @@ -1,13 +1,13 @@ -import { faker } from "@faker-js/faker/."; -import { prismaClient } from "../../../prisma/client"; - -export const createFileHelper = async (fileArgs?: Partial) => - prismaClient.file.create({ - data: { - id: faker.string.uuid(), - name: faker.lorem.word(), - mimeType: "application/pdf", - path: faker.lorem.word(), - ...fileArgs, - }, - }); +import { faker } from "@faker-js/faker/."; +import { prismaClient } from "../../../prisma/client"; + +export const createFileHelper = async (fileArgs?: Partial) => + prismaClient.file.create({ + data: { + id: faker.string.uuid(), + name: faker.lorem.word(), + mimeType: "application/pdf", + path: faker.lorem.word(), + ...fileArgs, + }, + }); diff --git a/packages/reva-api/test/helpers/entities/create-funding-request-batch-helper.ts b/packages/reva-api/test/helpers/entities/create-funding-request-batch-helper.ts index 6bf9446bb..1ff19fd01 100644 --- a/packages/reva-api/test/helpers/entities/create-funding-request-batch-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-funding-request-batch-helper.ts @@ -1,22 +1,22 @@ -import { faker } from "@faker-js/faker/."; -import { FundingRequestBatchUnifvae } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; -import { createFundingRequestHelper } from "./create-funding-request-helper"; -export const createFundingRequestBatchHelper = async ( - args?: Partial, -) => { - const fundingRequest = await createFundingRequestHelper(); - - return prismaClient.fundingRequestBatchUnifvae.create({ - data: { - fundingRequestId: fundingRequest.id, - content: { - field1: faker.number.int(), - field2: faker.lorem.words(), - field3: faker.lorem.words(), - field4: faker.number.float(), - }, - ...(args as any), - }, - }); -}; +import { faker } from "@faker-js/faker/."; +import { FundingRequestBatchUnifvae } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; +import { createFundingRequestHelper } from "./create-funding-request-helper"; +export const createFundingRequestBatchHelper = async ( + args?: Partial, +) => { + const fundingRequest = await createFundingRequestHelper(); + + return prismaClient.fundingRequestBatchUnifvae.create({ + data: { + fundingRequestId: fundingRequest.id, + content: { + field1: faker.number.int(), + field2: faker.lorem.words(), + field3: faker.lorem.words(), + field4: faker.number.float(), + }, + ...(args as any), + }, + }); +}; diff --git a/packages/reva-api/test/helpers/entities/create-funding-request-helper.ts b/packages/reva-api/test/helpers/entities/create-funding-request-helper.ts index 331e8461e..dfc3f1e72 100644 --- a/packages/reva-api/test/helpers/entities/create-funding-request-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-funding-request-helper.ts @@ -1,21 +1,21 @@ -import { faker } from "@faker-js/faker"; -import { FundingRequestUnifvae } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; -import { FUNDING_REQUEST_FULL_CERT_OK_HOURS } from "../../../test/fixtures"; -import { createCandidacyHelper } from "./create-candidacy-helper"; - -export const createFundingRequestHelper = async ( - args?: Partial, -) => { - const candidacy = await createCandidacyHelper(); - - return prismaClient.fundingRequestUnifvae.create({ - data: { - ...FUNDING_REQUEST_FULL_CERT_OK_HOURS, - certificateSkills: faker.word.noun(), - otherTraining: faker.word.noun(), - candidacyId: candidacy.id, - ...args, - }, - }); -}; +import { faker } from "@faker-js/faker"; +import { FundingRequestUnifvae } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; +import { FUNDING_REQUEST_FULL_CERT_OK_HOURS } from "../../../test/fixtures"; +import { createCandidacyHelper } from "./create-candidacy-helper"; + +export const createFundingRequestHelper = async ( + args?: Partial, +) => { + const candidacy = await createCandidacyHelper(); + + return prismaClient.fundingRequestUnifvae.create({ + data: { + ...FUNDING_REQUEST_FULL_CERT_OK_HOURS, + certificateSkills: faker.word.noun(), + otherTraining: faker.word.noun(), + candidacyId: candidacy.id, + ...args, + }, + }); +}; diff --git a/packages/reva-api/test/helpers/entities/create-jury-helper.ts b/packages/reva-api/test/helpers/entities/create-jury-helper.ts index 62d46364f..82a5316a3 100644 --- a/packages/reva-api/test/helpers/entities/create-jury-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-jury-helper.ts @@ -1,37 +1,37 @@ -import { Jury } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; -import { createCandidacyHelper } from "./create-candidacy-helper"; -import { createCertificationAuthorityHelper } from "./create-certification-authority-helper"; - -export const createJuryHelper = async (args?: Partial) => { - //either take the candidacy whose id is passed in args or create a new one - const candidacy = args?.candidacyId - ? await prismaClient.candidacy.findUnique({ - where: { id: args.candidacyId }, - }) - : await createCandidacyHelper(); - - if (!candidacy) { - throw new Error("candidacy not found"); - } - - const certificationAuthority = await createCertificationAuthorityHelper(); - - return prismaClient.jury.create({ - data: { - isActive: args?.isActive ?? true, - candidacyId: candidacy.id, - certificationAuthorityId: certificationAuthority.id, - dateOfSession: new Date(), - ...args, - }, - include: { - candidacy: { - include: { - candidate: true, - certification: true, - }, - }, - }, - }); -}; +import { Jury } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; +import { createCandidacyHelper } from "./create-candidacy-helper"; +import { createCertificationAuthorityHelper } from "./create-certification-authority-helper"; + +export const createJuryHelper = async (args?: Partial) => { + //either take the candidacy whose id is passed in args or create a new one + const candidacy = args?.candidacyId + ? await prismaClient.candidacy.findUnique({ + where: { id: args.candidacyId }, + }) + : await createCandidacyHelper(); + + if (!candidacy) { + throw new Error("candidacy not found"); + } + + const certificationAuthority = await createCertificationAuthorityHelper(); + + return prismaClient.jury.create({ + data: { + isActive: args?.isActive ?? true, + candidacyId: candidacy.id, + certificationAuthorityId: certificationAuthority.id, + dateOfSession: new Date(), + ...args, + }, + include: { + candidacy: { + include: { + candidate: true, + certification: true, + }, + }, + }, + }); +}; diff --git a/packages/reva-api/test/helpers/entities/create-maison-mere-aap-helper.ts b/packages/reva-api/test/helpers/entities/create-maison-mere-aap-helper.ts index a6a1ec994..34a102c93 100644 --- a/packages/reva-api/test/helpers/entities/create-maison-mere-aap-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-maison-mere-aap-helper.ts @@ -1,29 +1,29 @@ -import { faker } from "@faker-js/faker/."; -import { LegalStatus, MaisonMereAAP } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; -import { createAccountHelper } from "./create-account-helper"; - -export const createMaisonMereAapHelper = async ( - mmArgs?: Partial, -) => { - const account = await createAccountHelper(); - - return prismaClient.maisonMereAAP.create({ - data: { - isActive: true, - statutValidationInformationsJuridiquesMaisonMereAAP: "A_JOUR", - raisonSociale: faker.company.name(), - siret: faker.string.nanoid(14), - statutJuridique: LegalStatus.ASSOCIATION_LOI_1901, - typologie: "expertFiliere", - dateExpirationCertificationQualiopi: faker.date.future(), - gestionnaireAccountId: account.id, - cguVersion: 1, - cguAcceptedAt: faker.date.past(), - ...mmArgs, - }, - include: { - gestionnaire: true, - }, - }); -}; +import { faker } from "@faker-js/faker/."; +import { LegalStatus, MaisonMereAAP } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; +import { createAccountHelper } from "./create-account-helper"; + +export const createMaisonMereAapHelper = async ( + mmArgs?: Partial, +) => { + const account = await createAccountHelper(); + + return prismaClient.maisonMereAAP.create({ + data: { + isActive: true, + statutValidationInformationsJuridiquesMaisonMereAAP: "A_JOUR", + raisonSociale: faker.company.name(), + siret: faker.string.nanoid(14), + statutJuridique: LegalStatus.ASSOCIATION_LOI_1901, + typologie: "expertFiliere", + dateExpirationCertificationQualiopi: faker.date.future(), + gestionnaireAccountId: account.id, + cguVersion: 1, + cguAcceptedAt: faker.date.past(), + ...mmArgs, + }, + include: { + gestionnaire: true, + }, + }); +}; diff --git a/packages/reva-api/test/helpers/entities/create-organism-on-convention-collective-helper.ts b/packages/reva-api/test/helpers/entities/create-organism-on-convention-collective-helper.ts index 41089afdd..28a2fe55b 100644 --- a/packages/reva-api/test/helpers/entities/create-organism-on-convention-collective-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-organism-on-convention-collective-helper.ts @@ -1,23 +1,23 @@ -import { OrganismOnConventionCollective } from "@prisma/client"; -import { prismaClient } from "../../../prisma/client"; -import { createCCNHelper } from "./create-convention-collective-helper"; -import { createOrganismHelper } from "./create-organism-helper"; - -export const createOrganismOnConventionCollectiveHelper = async ( - oOCCArgs?: Partial, -) => { - const organism = await createOrganismHelper(); - const ccn = await createCCNHelper(); - - return prismaClient.organismOnConventionCollective.create({ - data: { - organismId: organism.id, - ccnId: ccn.id, - ...oOCCArgs, - }, - include: { - organism: true, - ccn: true, - }, - }); -}; +import { OrganismOnConventionCollective } from "@prisma/client"; +import { prismaClient } from "../../../prisma/client"; +import { createCCNHelper } from "./create-convention-collective-helper"; +import { createOrganismHelper } from "./create-organism-helper"; + +export const createOrganismOnConventionCollectiveHelper = async ( + oOCCArgs?: Partial, +) => { + const organism = await createOrganismHelper(); + const ccn = await createCCNHelper(); + + return prismaClient.organismOnConventionCollective.create({ + data: { + organismId: organism.id, + ccnId: ccn.id, + ...oOCCArgs, + }, + include: { + organism: true, + ccn: true, + }, + }); +}; diff --git a/packages/reva-api/test/helpers/entities/create-reorientation-reason-helper.ts b/packages/reva-api/test/helpers/entities/create-reorientation-reason-helper.ts index 0619148d7..c4a351615 100644 --- a/packages/reva-api/test/helpers/entities/create-reorientation-reason-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-reorientation-reason-helper.ts @@ -1,13 +1,13 @@ -import { faker } from "@faker-js/faker/locale/fr"; -import { prismaClient } from "../../../prisma/client"; -import { ReorientationReason } from "@prisma/client"; - -export const createReorientationReasonHelper = async ( - reorientationReasonArgs?: Partial, -) => - prismaClient.reorientationReason.create({ - data: { - label: faker.lorem.sentence(), - ...reorientationReasonArgs, - }, - }); +import { faker } from "@faker-js/faker/locale/fr"; +import { prismaClient } from "../../../prisma/client"; +import { ReorientationReason } from "@prisma/client"; + +export const createReorientationReasonHelper = async ( + reorientationReasonArgs?: Partial, +) => + prismaClient.reorientationReason.create({ + data: { + label: faker.lorem.sentence(), + ...reorientationReasonArgs, + }, + });