-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
262 additions
and
16 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
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,15 @@ | ||
export function getEntityUpdateSetUnset(entity: Record<string, any>) { | ||
const { set, unset } = Object.keys(entity).reduce( | ||
(acc, key) => { | ||
const value = entity[key]; | ||
if (value === undefined) { | ||
acc.unset[key] = 1; | ||
} else { | ||
acc.set[key] = value; | ||
} | ||
return acc; | ||
}, | ||
{ set: {}, unset: {} }, | ||
); | ||
return { $set: set, $unset: unset }; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,214 @@ | ||
import mongoose from "mongoose"; | ||
import { fakerFR as faker } from "@faker-js/faker"; | ||
|
||
import { getAdminTestModuleRef } from "../../../setUpAdminTest"; | ||
import { JeuneModel } from "@admin/core/sejours/jeune/Jeune.model"; | ||
import { JeuneGateway } from "@admin/core/sejours/jeune/Jeune.gateway"; | ||
import { addYears } from "date-fns"; | ||
import { departmentList, regionList } from "snu-lib"; | ||
|
||
export const createJeune = async (jeune?: Partial<JeuneModel>) => { | ||
const adminTestModule = getAdminTestModuleRef(); | ||
const jeuneGateway = adminTestModule.get<JeuneGateway>(JeuneGateway); | ||
|
||
return await jeuneGateway.create({ | ||
prenom: faker.person.firstName(), | ||
nom: faker.person.lastName(), | ||
// frenchNationality: "true", | ||
// birthCountry: faker.location.country(), | ||
// birthCity: faker.location.city(), | ||
// birthCityZip: faker.location.zipCode(), | ||
email: faker.internet | ||
.email({ firstName: faker.person.firstName(), lastName: faker.string.uuid() }) | ||
.toLowerCase(), | ||
telephone: faker.phone.number(), | ||
// phoneZone: "FRANCE", | ||
genre: faker.person.gender(), | ||
dateNaissance: faker.date.past({ years: 3, refDate: addYears(new Date(), -15) }), | ||
sessionId: new mongoose.Types.ObjectId().toString(), | ||
sessionNom: "Juillet 2023", | ||
// acceptCGU: "true", | ||
// phase: "CONTINUE", | ||
statut: "REFUSED", | ||
statutPhase1: "AFFECTED", | ||
// statutPhase2: "IN_PROGRESS", | ||
// statutPhase3: "VALIDATED", | ||
// statusPhase2UpdatedAt: faker.date.past(), | ||
// statusPhase2ValidatedAt: faker.date.past(), | ||
// statusPhase3UpdatedAt: faker.date.past(), | ||
// statusPhase3ValidatedAt: faker.date.past(), | ||
// lastStatusAt: faker.date.past(), | ||
// withdrawnReason: "", | ||
// withdrawnMessage: "", | ||
// inscriptionStep: "PROFIL", | ||
// cohesion2020Step: "JDC", | ||
// historic: [], | ||
// password: faker.internet.password(), | ||
// cniFiles: [], | ||
cohesionStayPresence: "true", | ||
presenceJDM: "true", | ||
departSejourAt: faker.date.past().toISOString(), | ||
departSejourMotif: "blabla", | ||
departSejourMotifComment: "blabla details", | ||
// cohesionStayMedicalFileReceived: "false", | ||
centreId: "", | ||
// cohesionCenterName: "", | ||
// cohesionCenterZip: "", | ||
// cohesionCenterCity: "", | ||
// autoAffectationPhase1ExpiresAt: faker.date.past(), | ||
// phase2ApplicationStatus: [], | ||
// phase3StructureName: "", | ||
// phase3MissionDomain: "", | ||
// phase3MissionDescription: "", | ||
// phase3MissionStartAt: faker.date.past(), | ||
// phase3MissionEndAt: faker.date.past(), | ||
// phase3TutorFirstName: "", | ||
// phase3TutorLastName: "", | ||
// phase3TutorEmail: "", | ||
// phase3TutorPhone: "", | ||
// phase3TutorNote: "", | ||
// phase3Token: "3", | ||
// address: "", | ||
// complementAddress: "", | ||
// zip: faker.location.zipCode(), | ||
// city: faker.location.city(), | ||
// cityCode: faker.location.zipCode(), | ||
departement: faker.helpers.arrayElement(departmentList), | ||
region: faker.helpers.arrayElement(regionList), | ||
// country: "France", | ||
localisation: { | ||
lat: Number(faker.location.latitude()), | ||
lon: Number(faker.location.longitude()), | ||
}, | ||
// hostLastName: faker.person.lastName(), | ||
// hostFirstName: faker.person.firstName(), | ||
// hostRelationship: "Parent", | ||
// foreignCountry: faker.location.country(), | ||
// foreignCity: faker.location.city(), | ||
// foreignZip: faker.location.zipCode(), | ||
// foreignAddress: "Une super adresse", | ||
// populationDensity: "DENSE", | ||
qpv: "false", | ||
// situation: "Etudiant", | ||
// grade: "2ndeGT", | ||
// schoolCertification: "false", | ||
// schooled: "true", | ||
// schoolName: faker.location.city(), | ||
// schoolType: "Lycée", | ||
// schoolAddress: faker.location.street(), | ||
// schoolComplementAdresse: "", | ||
// schoolZip: faker.location.zipCode(), | ||
// schoolCity: faker.location.city(), | ||
departementScolarite: faker.helpers.arrayElement(departmentList), | ||
regionScolarite: faker.helpers.arrayElement(regionList), | ||
// schoolLocation: { | ||
// lat: Number(faker.location.latitude()), | ||
// lon: Number(faker.location.longitude()), | ||
// }, | ||
// schoolId: String(faker.number.int()), | ||
// academy: "Strasbourg", | ||
// parent1Status: "", | ||
parent1Prenom: faker.person.firstName(), | ||
parent1Nom: faker.person.lastName(), | ||
parent1Email: faker.internet.email(), | ||
parent1Telephone: faker.phone.number(), | ||
// parent1OwnAddress: "true", | ||
// parent1Address: faker.location.streetAddress(), | ||
// parent1ComplementAddress: "", | ||
// parent1Zip: faker.location.zipCode(), | ||
// parent1City: faker.location.city(), | ||
// parent1Department: faker.helpers.arrayElement(departmentList), | ||
// parent1Region: faker.helpers.arrayElement(regionList), | ||
// parent1Location: { | ||
// lat: Number(faker.location.latitude()), | ||
// lon: Number(faker.location.longitude()), | ||
// }, | ||
// parent1FromFranceConnect: "true", | ||
// parent2Status: "", | ||
parent2Prenom: faker.person.firstName(), | ||
parent2Nom: faker.person.lastName(), | ||
parent2Email: faker.internet.email(), | ||
parent2Telephone: faker.phone.number(), | ||
// parent2OwnAddress: "true", | ||
// parent2Address: faker.location.streetAddress(), | ||
// parent2ComplementAddress: "", | ||
// parent2Zip: faker.location.zipCode(), | ||
// parent2City: faker.location.city(), | ||
// parent2Department: faker.helpers.arrayElement(departmentList), | ||
// parent2Region: faker.helpers.arrayElement(regionList), | ||
// parent2Location: { | ||
// lat: Number(faker.location.latitude()), | ||
// lon: Number(faker.location.longitude()), | ||
// }, | ||
// parent2FromFranceConnect: "false", | ||
// handicap: "true", | ||
// ppsBeneficiary: "false", | ||
// paiBeneficiary: "false", | ||
// medicosocialStructure: "true", | ||
// medicosocialStructureName: faker.location.country(), | ||
// medicosocialStructureAddress: faker.location.streetAddress(), | ||
// medicosocialStructureComplementAddress: "", | ||
// medicosocialStructureZip: faker.location.zipCode(), | ||
// medicosocialStructureCity: faker.location.city(), | ||
// medicosocialStructureDepartment: faker.helpers.arrayElement(departmentList), | ||
// medicosocialStructureRegion: faker.helpers.arrayElement(regionList), | ||
// medicosocialStructureLocation: { | ||
// lat: Number(faker.location.latitude()), | ||
// lon: Number(faker.location.longitude()), | ||
// }, | ||
// engagedStructure: "Maison", | ||
// specificAmenagment: "false", | ||
// specificAmenagmentType: "Aucun", | ||
// highSkilledActivity: "true", | ||
// highSkilledActivityType: "Sport", | ||
// highSkilledActivityProofFiles: [], | ||
// parentConsentment: "true", | ||
// parentConsentmentFiles: [], | ||
// parentConsentmentFilesCompliant: "false", | ||
// parentConsentmentFilesCompliantInfo: "", | ||
// consentment: "false", | ||
// imageRight: "false", | ||
// imageRightFiles: [], | ||
// autoTestPCR: "true", | ||
// autoTestPCRFiles: [], | ||
// rulesYoung: "true", | ||
// rulesParent1: "true", | ||
// rulesParent2: "true", | ||
// rulesFiles: [], | ||
// jdc: "false", | ||
// motivations: "SNU", | ||
// domains: [""], | ||
// professionnalProject: "UNIFORM", | ||
// professionnalProjectPrecision: "", | ||
// period: "DURING_SCHOOL", | ||
// periodRanking: [""], | ||
// mobilityNearSchool: "false", | ||
// mobilityNearHome: "false", | ||
// mobilityNearRelative: "true", | ||
// mobilityNearRelativeName: "", | ||
// mobilityNearRelativeAddress: "", | ||
// mobilityNearRelativeZip: faker.location.zipCode(), | ||
// mobilityTransport: [faker.vehicle.vehicle()], | ||
// mobilityTransportOther: faker.lorem.sentences(), | ||
// missionFormat: "CONTINUOUS", | ||
// engaged: "true", | ||
// engagedDescription: faker.lorem.sentences(), | ||
// desiredLocation: faker.lorem.sentences(), | ||
// defenseInterest: faker.lorem.sentences(), | ||
// defenseTypeInterest: faker.lorem.sentences(), | ||
// defenseDomainInterest: faker.lorem.sentences(), | ||
// defenseMotivationInterest: faker.lorem.sentences(), | ||
// securityInterest: faker.lorem.sentences(), | ||
// securityDomainInterest: faker.lorem.sentences(), | ||
// solidarityInterest: faker.lorem.sentences(), | ||
// healthInterest: faker.lorem.sentences(), | ||
// educationInterest: faker.lorem.sentences(), | ||
// cultureInterest: faker.lorem.sentences(), | ||
// sportInterest: faker.lorem.sentences(), | ||
// environmentInterest: faker.lorem.sentences(), | ||
// citizenshipInterest: faker.lorem.sentences(), | ||
// originalCohortId: new mongoose.Types.ObjectId().toString(), | ||
youngPhase1Agreement: "true", | ||
...jeune, | ||
}); | ||
}; |