1- import { hashPassword , ProposedSectionEntity , UserEntity } from "@libs/users-backend" ;
1+ import {
2+ hashPassword ,
3+ SectionTemplatesEntity ,
4+ UserEntity ,
5+ CurriculumEntity ,
6+ SectionsEntity ,
7+ SectionItemsEntity ,
8+ } from "@libs/users-backend" ;
29import type { EntityManager } from "@mikro-orm/core" ;
310import { Seeder } from "@mikro-orm/seeder" ;
11+ import personnalInformationsJsonSchema from "./models/personal-informations.schema.json" with { type : "json" } ;
12+ import formationsJsonSchema from "./models/formations.schema.json" with { type : "json" } ;
13+ import langueJsonSchema from "./models/langues.schema.json" with { type : "json" } ;
14+ import centresInteretsJsonSchema from "./models/centres-interets.schema.json" with { type : "json" } ;
15+ import competencesJsonSchema from "./models/competences.schema.json" with { type : "json" } ;
16+ import experiencesJsonSchema from "./models/experiences.schema.json" with { type : "json" } ;
17+ import profilJsonSchema from "./models/profil.schema.json" with { type : "json" } ;
18+ import referencesJsonSchema from "./models/references.schema.json" with { type : "json" } ;
419
520export class DatabaseSeeder extends Seeder {
621 async run ( em : EntityManager ) {
@@ -15,22 +30,134 @@ export class DatabaseSeeder extends Seeder {
1530 password : hashedPassword ,
1631 } ) ;
1732
18- em . create ( ProposedSectionEntity , {
19- id : "e2e-proposed-section-1" ,
20- title : "Informations personnelles" ,
33+ // Curriculum for e2e tests
34+ em . create ( CurriculumEntity , {
35+ id : "e2e-curriculum" ,
36+ userId : "e2e-login-user" ,
37+ title : "Mon CV" ,
38+ createdAt : new Date ( ) ,
39+ updatedAt : new Date ( ) ,
40+ } ) ;
41+
42+ const template1 = em . create ( SectionTemplatesEntity , {
43+ id : "e2e-section-template-1" ,
44+ label : "Informations personnelles" ,
45+ jsonSchema : personnalInformationsJsonSchema ,
2146 position : 1 ,
2247 } ) ;
2348
24- em . create ( ProposedSectionEntity , {
25- id : "e2e-proposed-section-2" ,
26- title : "Expérience professionnelle" ,
49+ const template2 = em . create ( SectionTemplatesEntity , {
50+ id : "e2e-section-template-2" ,
51+ label : "Formations" ,
52+ jsonSchema : formationsJsonSchema ,
2753 position : 2 ,
2854 } ) ;
2955
30- em . create ( ProposedSectionEntity , {
31- id : "e2e-proposed-section-3" ,
32- title : "Formation et diplômes" ,
56+ em . create ( SectionTemplatesEntity , {
57+ id : "e2e-section-template-3" ,
58+ label : "Expériences professionnelles" ,
59+ jsonSchema : experiencesJsonSchema ,
60+ position : 3 ,
61+ } ) ;
62+
63+ em . create ( SectionTemplatesEntity , {
64+ id : "e2e-section-template-4" ,
65+ label : "Compétences" ,
66+ jsonSchema : competencesJsonSchema ,
67+ position : 4 ,
68+ } ) ;
69+
70+ em . create ( SectionTemplatesEntity , {
71+ id : "e2e-section-template-5" ,
72+ label : "Centres d'intérêts" ,
73+ jsonSchema : centresInteretsJsonSchema ,
74+ position : 5 ,
75+ } ) ;
76+
77+ em . create ( SectionTemplatesEntity , {
78+ id : "e2e-section-template-6" ,
79+ label : "Profil" ,
80+ jsonSchema : profilJsonSchema ,
81+ position : 6 ,
82+ } ) ;
83+
84+ em . create ( SectionTemplatesEntity , {
85+ id : "e2e-section-template-7" ,
86+ label : "Références" ,
87+ jsonSchema : referencesJsonSchema ,
88+ position : 7 ,
89+ } ) ;
90+
91+ em . create ( SectionTemplatesEntity , {
92+ id : "e2e-section-template-3" ,
93+ label : "Langues" ,
94+ jsonSchema : langueJsonSchema ,
3395 position : 3 ,
3496 } ) ;
97+
98+ const curriculum = em . create ( CurriculumEntity , {
99+ id : "e2e-curriculum" ,
100+ userId : "e2e-login-user" ,
101+ title : "Mon CV" ,
102+ createdAt : new Date ( ) ,
103+ updatedAt : new Date ( ) ,
104+ } ) ;
105+
106+ const section1 = em . create ( SectionsEntity , {
107+ id : "e2e-section-1" ,
108+ curriculum,
109+ template : template1 ,
110+ title : "Informations personnelles" ,
111+ position : 1 ,
112+ } ) ;
113+
114+ const section2 = em . create ( SectionsEntity , {
115+ id : "e2e-section-2" ,
116+ curriculum,
117+ template : template2 ,
118+ title : "Formations" ,
119+ position : 2 ,
120+ } ) ;
121+
122+ em . create ( SectionItemsEntity , {
123+ id : "e2e-section-item-1" ,
124+ section : section1 ,
125+ position : 1 ,
126+ jsonData : {
127+ firstName : "Amaury" ,
128+ lastName : "Deflorenne" ,
129+ email : "test@gmail.com" ,
130+ phone : "0601020304" ,
131+ address : "123 rue de la paix, 75000 Paris" ,
132+ } ,
133+ } ) ;
134+
135+ em . create ( SectionItemsEntity , {
136+ id : "e2e-section-item-2" ,
137+ section : section2 ,
138+ position : 1 ,
139+ jsonData : {
140+ school : "Université de Lyon" ,
141+ degree : "Master Informatique" ,
142+ field : "Informatique" ,
143+ startDate : "2021-09-01" ,
144+ endDate : "2023-06-30" ,
145+ description : "Description de ma formation en informatique à l'Université de Lyon." ,
146+ } ,
147+ } ) ;
148+
149+ em . create ( SectionItemsEntity , {
150+ id : "e2e-section-item-3" ,
151+ section : section2 ,
152+ position : 2 ,
153+ jsonData : {
154+ school : "Université de Paris" ,
155+ degree : "Licence Informatique" ,
156+ field : "Informatique" ,
157+ startDate : "2018-09-01" ,
158+ endDate : "2021-06-30" ,
159+ description : "Description de ma formation en informatique à l'Université de Paris." ,
160+ } ,
161+ } ) ;
35162 }
36163}
0 commit comments