-
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.
style(api): added missing folders test scripts and prisma/seed
- Loading branch information
Showing
23 changed files
with
405 additions
and
401 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
"prisma:generate:migration": "prisma migrate dev --create-only", | ||
"cron": "npx [email protected] infra/cron.ts", | ||
"cron-dev": "npx [email protected] 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" | ||
|
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
7 changes: 5 additions & 2 deletions
7
packages/reva-api/prisma/seed/referentials/table-vulnerability-indicators.ts
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,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"; |
30 changes: 15 additions & 15 deletions
30
packages/reva-api/test/fixtures/payment-requests.fixture.ts
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,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", | ||
}; |
32 changes: 16 additions & 16 deletions
32
packages/reva-api/test/helpers/attach-organism-to-all-ccn-helper.ts
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,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, | ||
}, | ||
}); | ||
} | ||
} |
32 changes: 16 additions & 16 deletions
32
packages/reva-api/test/helpers/attach-organism-to-all-degrees-helper.ts
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,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 || "", | ||
}, | ||
}); | ||
} | ||
} |
28 changes: 14 additions & 14 deletions
28
packages/reva-api/test/helpers/entities/create-account-helper.ts
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,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<Account>) => | ||
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<Account>) => | ||
prismaClient.account.create({ | ||
data: { | ||
email: faker.internet.email(), | ||
firstname: faker.person.firstName(), | ||
lastname: faker.person.lastName(), | ||
keycloakId: faker.string.uuid(), | ||
...accountArgs, | ||
}, | ||
}); |
66 changes: 33 additions & 33 deletions
66
packages/reva-api/test/helpers/entities/create-candidacy-drop-out-helper.ts
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,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<CandidacyDropOut>, | ||
) => { | ||
//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<CandidacyDropOut>, | ||
) => { | ||
//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, | ||
}, | ||
}); | ||
}; |
70 changes: 35 additions & 35 deletions
70
packages/reva-api/test/helpers/entities/create-candidate-helper.ts
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,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<Candidate>, | ||
): Promise<Candidate> => { | ||
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<Candidate>, | ||
): Promise<Candidate> => { | ||
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, | ||
}, | ||
}); | ||
}; |
26 changes: 13 additions & 13 deletions
26
packages/reva-api/test/helpers/entities/create-certification-authority-structure-helper.ts
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,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<CertificationAuthorityStructure>, | ||
) => | ||
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<CertificationAuthorityStructure>, | ||
) => | ||
prismaClient.certificationAuthorityStructure.create({ | ||
data: { | ||
label: faker.lorem.sentence(), | ||
...args, | ||
}, | ||
}); |
28 changes: 14 additions & 14 deletions
28
packages/reva-api/test/helpers/entities/create-convention-collective-helper.ts
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,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<ConventionCollective>, | ||
) => | ||
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<ConventionCollective>, | ||
) => | ||
prismaClient.conventionCollective.create({ | ||
data: { | ||
code: faker.string.numeric(5), | ||
label: faker.company.name(), | ||
...ccnArgs, | ||
}, | ||
}); |
Oops, something went wrong.