Repository: 1024pix/pix
Pull request #11853: [TECH] Seeds : ajouter un cas de certification sco simple (PIX-17209).
Author: login: Jeyffrey
Labels: name: Tech Review OK
name: :rocket: Ready to Merge
name: Func Review OK
description: PO validated functionally the PR
name: team-certif
Created: 2025-03-26T12:00:31Z | Merged: 2025-03-27T13:49:12Z

## 🌸 Problème

Côté certif, on a besoin de seeds pratiques et dignes de confiance.

## 🌳 Proposition

Ajouter un premier cas concret de certif :

> Un utilisateur Sco certifiable peut directement lancer sa certification sur PixApp

## 🐝 Remarques

Une fois que c'est validé, penser à indiquer ces seeds dans la doc partagée.

## 🤧 Pour tester

- Aller sur **PixApp** en RA ou en local (les devs, je vous encourage à le faire en local pour faciliter la vérif des données en DB)
- Se connecter avec `certifiable-sco-user@example.net`
- Entrer en certif avec ces données :
  - **Numéro de session** :  `7400`
     **Prénom** :  `Sco`
     **Nom de naissance** :  `Certifiable`
     **Date de naissance** : `01/01/2000`

  - **Code d'accès** : `AZERTY`

- Pour se connecter à **PixOrga**/**PixCertif** : `simple-sco-organization-member@example.net` 


Diff:
diff --git a/api/db/seeds/data/team-certification/cases/simple-sco-managing-students-certification.js b/api/db/seeds/data/team-certification/cases/simple-sco-managing-students-certification.js
new file mode 100644
index 00000000000..b1bf58271eb
--- /dev/null
+++ b/api/db/seeds/data/team-certification/cases/simple-sco-managing-students-certification.js
@@ -0,0 +1,166 @@
+import { Candidate } from '../../../../../src/certification/enrolment/domain/models/Candidate.js';
+import { Subscription } from '../../../../../src/certification/enrolment/domain/models/Subscription.js';
+import { usecases as enrolmentUseCases } from '../../../../../src/certification/enrolment/domain/usecases/index.js';
+import { OrganizationForAdmin } from '../../../../../src/organizational-entities/domain/models/OrganizationForAdmin.js';
+import { usecases as organizationalEntitiesUsecases } from '../../../../../src/organizational-entities/domain/usecases/index.js';
+import * as organizationCreationValidator from '../../../../../src/organizational-entities/domain/validators/organization-creation-validator.js';
+import {
+  CertificationCenter,
+  types as certificationCenterTypes,
+} from '../../../../../src/shared/domain/models/CertificationCenter.js';
+import { Membership } from '../../../../../src/shared/domain/models/index.js';
+import { normalize } from '../../../../../src/shared/infrastructure/utils/string-utils.js';
+import { usecases as teamUsecases } from '../../../../../src/team/domain/usecases/index.js';
+import * as tooling from '../../common/tooling/index.js';
+import { acceptPixOrgaTermsOfService } from '../../common/tooling/legal-documents.js';
+import {
+  SIMPLE_SCO_CERTIFICATION_CENTER_ID,
+  SIMPLE_SCO_CERTIFICATION_USER_ID,
+  SIMPLE_SCO_ORGANIZATION_MEMBER_ID,
+  SIMPLE_SCO_SESSION,
+} from '../constants.js';
+
+/**
+ * --- CERTIFICATION CASE ---
+ *
+ * The goal here is to reproduce the most simple certification case:
+ *   - I'm a SCO user with a certifiable account
+ *   - I'm able to start a certification course
+ *   - The organization is Sco and managing students
+ */
+export default async function simpleScoManagingStudentsCertificationCase({ databaseBuilder }) {
+  /**
+   * 1. Create the certification session
+   */
+  const externalId = 'SCO_CERTIFICATION_ORGANIZATION';
+
+  const organizationMember = databaseBuilder.factory.buildUser.withRawPassword({
+    id: SIMPLE_SCO_ORGANIZATION_MEMBER_ID,
+    firstName: 'Sco',
+    lastName: 'Organization Member',
+    email: 'simple-sco-organization-member@example.net',
+    cgu: true,
+    lang: 'fr',
+    lastTermsOfServiceValidatedAt: new Date(),
+    pixCertifTermsOfServiceAccepted: true,
+  });
+
+  acceptPixOrgaTermsOfService(databaseBuilder, organizationMember.id);
+
+  await databaseBuilder.commit();
+
+  // Organization
+  const organization = new OrganizationForAdmin({
+    name: 'Certification Sco Organization #1',
+    type: 'SCO',
+    isManagingStudents: true,
+    externalId,
+  });
+
+  const newOrga = await organizationalEntitiesUsecases.createOrganization({
+    organization,
+    organizationCreationValidator,
+  });
+
+  const organizationMembership = await teamUsecases.createMembership({
+    organizationRole: Membership.roles.ADMIN,
+    userId: organizationMember.id,
+    organizationId: newOrga.id,
+  });
+
+  // Certification center
+  const certificationCenter = new CertificationCenter({
+    id: SIMPLE_SCO_CERTIFICATION_CENTER_ID,
+    name: 'Sco Certification Center #1',
+    type: certificationCenterTypes.SCO,
+    externalId,
+    createdAt: new Date('2022-01-30'),
+    habilitations: [],
+    isV3Pilot: true,
+  });
+
+  const certificationCenterForAdmin = await organizationalEntitiesUsecases.createCertificationCenter({
+    certificationCenter,
+    complementaryCertificationIds: [],
+  });
+
+  await teamUsecases.createCertificationCenterMembershipForScoOrganizationAdminMember({
+    membership: organizationMembership,
+  });
+
+  /**
+   * 2. Create the certifiable user
+   */
+  const scoUser = databaseBuilder.factory.buildUser.withRawPassword({
+    id: SIMPLE_SCO_CERTIFICATION_USER_ID,
+    firstName: 'Sco',
+    lastName: 'Certifiable',
+    email: 'certifiable-sco-user@example.net',
+    cgu: true,
+    lang: 'fr',
+    lastTermsOfServiceValidatedAt: new Date(),
+    pixCertifTermsOfServiceAccepted: true,
+  });
+
+  await tooling.profile.createCertifiableProfile({
+    databaseBuilder,
+    userId: scoUser.id,
+  });
+
+  const organizationLearner = databaseBuilder.factory.buildOrganizationLearner({
+    userId: scoUser.id,
+    organizationId: newOrga.id,
+    firstName: scoUser.firstName,
+    lastName: scoUser.lastName,
+    email: scoUser.email,
+    sex: scoUser.sex,
+    birthdate: '2000-01-01',
+    isCertifiable: true,
+    certifiableAt: new Date('2022-01-30'),
+  });
+
+  await databaseBuilder.commit();
+
+  // Transform this user into certification candidate
+  const candidate = new Candidate({
+    authorizedToStart: true,
+    organizationLearnerId: organizationLearner.id,
+    firstName: organizationLearner.firstName,
+    lastName: organizationLearner.lastName,
+    sex: organizationLearner.sex,
+    birthdate: organizationLearner.birthdate,
+    birthCountry: 'France',
+    birthINSEECode: '75115',
+    email: organizationLearner.email,
+    isLinked: true,
+    hasSeenCertificationInstructions: false,
+    accessibilityAdjustmentNeeded: false,
+    subscriptions: [Subscription.buildCore({ certificationCandidateId: null })],
+  });
+
+  /**
+   * 4. Initialize session
+   */
+  const session = await enrolmentUseCases.createSession({
+    userId: organizationMember.id,
+    session: {
+      certificationCenterId: certificationCenterForAdmin.id,
+      address: 'Rennes',
+      room: '28D',
+      examiner: 'Johnny Douw',
+      date: '2025-01-30',
+      time: '14:30',
+      description: 'Description de la simple session Sco',
+    },
+  });
+  await databaseBuilder.knex('sessions').where('id', session.id).update({
+    id: SIMPLE_SCO_SESSION,
+    accessCode: 'AZERTY',
+  });
+
+  await enrolmentUseCases.addCandidateToSession({
+    sessionId: SIMPLE_SCO_SESSION,
+    candidate,
+    normalizeStringFnc: normalize,
+  });
+}
diff --git a/api/db/seeds/data/team-certification/constants.js b/api/db/seeds/data/team-certification/constants.js
index c4802683e48..d5c23ae9313 100644
--- a/api/db/seeds/data/team-certification/constants.js
+++ b/api/db/seeds/data/team-certification/constants.js
@@ -9,8 +9,6 @@ const TEAM_CERTIFICATION_OFFSET_ID = 7000;
 // IDS
 /// USERS
 const TEAM_CERTIFICATION_OFFSET_ID_USERS = TEAM_CERTIFICATION_OFFSET_ID + 100;
-const SCO_CERTIFICATION_MANAGING_STUDENTS_ORGANIZATION_USER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS;
-const SCO_CERTIFICATION_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS + 1;
 const PRO_ADMIN_CERTIFICATION_CENTER_USER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS + 2;
 const PRO_ORGANIZATION_USER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS + 3;
 const V3_CERTIFICATION_CENTER_USER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS + 4;
@@ -20,24 +18,24 @@ const SCO_CERTIFICATION_NOT_MANAGING_STUDENTS_ORGANIZATION_USER_ID = TEAM_CERTIF
 const SCO_CERTIFICATION_NOT_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS + 8;
 const SCO_CERTIFICATION_MANAGING_AGRI_STUDENTS_CERTIFICATION_CENTER_USER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS + 9;
 const SCO_CERTIFICATION_MANAGING_AGRI_STUDENTS_ORGANIZATION_USER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS + 10;
+const SIMPLE_SCO_CERTIFICATION_USER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS + 11;
+const SIMPLE_SCO_ORGANIZATION_MEMBER_ID = TEAM_CERTIFICATION_OFFSET_ID_USERS + 12;
 
 /// ORGAS
 const TEAM_CERTIFICATION_OFFSET_ID_ORGAS = TEAM_CERTIFICATION_OFFSET_ID + 200;
-const SCO_MANAGING_STUDENTS_ORGANIZATION_ID = TEAM_CERTIFICATION_OFFSET_ID_ORGAS;
 const PRO_ORGANIZATION_ID = TEAM_CERTIFICATION_OFFSET_ID_ORGAS + 1;
 const SCO_NOT_MANAGING_STUDENTS_ORGANIZATION_ID = TEAM_CERTIFICATION_OFFSET_ID_ORGAS + 2;
 const SCO_MANAGING_AGRI_STUDENTS_ORGANIZATION_ID = TEAM_CERTIFICATION_OFFSET_ID_ORGAS + 3;
 
 /// CERTIFICATION CENTERS
 const TEAM_CERTIFICATION_OFFSET_ID_CENTERS = TEAM_CERTIFICATION_OFFSET_ID + 300;
-const SCO_CERTIFICATION_CENTER_ID = TEAM_CERTIFICATION_OFFSET_ID_CENTERS + 1;
 const PRO_CERTIFICATION_CENTER_ID = TEAM_CERTIFICATION_OFFSET_ID_CENTERS + 2;
 const SUP_CERTIFICATION_CENTER_ID = TEAM_CERTIFICATION_OFFSET_ID_CENTERS + 4;
 const SCO_NOT_MANAGING_CERTIFICATION_CENTER_ID = TEAM_CERTIFICATION_OFFSET_ID_CENTERS + 5;
 const SCO_CERTIFICATION_AGRI_CENTER_ID = TEAM_CERTIFICATION_OFFSET_ID_CENTERS + 6;
+const SIMPLE_SCO_CERTIFICATION_CENTER_ID = TEAM_CERTIFICATION_OFFSET_ID_CENTERS + 7;
 
 /// EXTERNAL IDS
-const CERTIFICATION_SCO_MANAGING_STUDENTS_EXTERNAL_ID = 'CERTIFICATION_SCO_MANAGING_STUDENTS_EXTERNAL_ID';
 const CERTIFICATION_SCO_MANAGING_AGRI_STUDENTS_EXTERNAL_ID = 'CERTIFICATION_SCO_MANAGING_AGRI_STUDENTS_EXTERNAL_ID';
 const CERTIFICATION_SCO_NOT_MANAGING_STUDENTS_EXTERNAL_ID = 'CERTIFICATION_SCO_NOT_MANAGING_STUDENTS_EXTERNAL_ID';
 const PRO_EXTERNAL_ID = 'PRO_EXTERNAL_ID';
@@ -45,7 +43,7 @@ const SUP_EXTERNAL_ID = 'SUP_EXTERNAL_ID';
 
 // SESSION IDS
 const TEAM_CERTIFICATION_OFFSET_ID_SESSIONS = TEAM_CERTIFICATION_OFFSET_ID + 400;
-const SCO_PUBLISHED_SESSION = TEAM_CERTIFICATION_OFFSET_ID_SESSIONS + 1;
+const SIMPLE_SCO_SESSION = TEAM_CERTIFICATION_OFFSET_ID_SESSIONS;
 
 const complementaryCertificationIds = [
   CLEA_COMPLEMENTARY_CERTIFICATION_ID,
@@ -56,7 +54,6 @@ const complementaryCertificationIds = [
 export {
   CERTIFIABLE_SUCCESS_USER_ID,
   CERTIFICATION_SCO_MANAGING_AGRI_STUDENTS_EXTERNAL_ID,
-  CERTIFICATION_SCO_MANAGING_STUDENTS_EXTERNAL_ID,
   CERTIFICATION_SCO_NOT_MANAGING_STUDENTS_EXTERNAL_ID,
   complementaryCertificationIds,
   PRO_ADMIN_CERTIFICATION_CENTER_USER_ID,
@@ -66,18 +63,17 @@ export {
   PRO_ORGANIZATION_ID,
   PRO_ORGANIZATION_USER_ID,
   SCO_CERTIFICATION_AGRI_CENTER_ID,
-  SCO_CERTIFICATION_CENTER_ID,
   SCO_CERTIFICATION_MANAGING_AGRI_STUDENTS_CERTIFICATION_CENTER_USER_ID,
   SCO_CERTIFICATION_MANAGING_AGRI_STUDENTS_ORGANIZATION_USER_ID,
-  SCO_CERTIFICATION_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID,
-  SCO_CERTIFICATION_MANAGING_STUDENTS_ORGANIZATION_USER_ID,
   SCO_CERTIFICATION_NOT_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID,
   SCO_CERTIFICATION_NOT_MANAGING_STUDENTS_ORGANIZATION_USER_ID,
   SCO_MANAGING_AGRI_STUDENTS_ORGANIZATION_ID,
-  SCO_MANAGING_STUDENTS_ORGANIZATION_ID,
   SCO_NOT_MANAGING_CERTIFICATION_CENTER_ID,
   SCO_NOT_MANAGING_STUDENTS_ORGANIZATION_ID,
-  SCO_PUBLISHED_SESSION,
+  SIMPLE_SCO_CERTIFICATION_CENTER_ID,
+  SIMPLE_SCO_CERTIFICATION_USER_ID,
+  SIMPLE_SCO_ORGANIZATION_MEMBER_ID,
+  SIMPLE_SCO_SESSION,
   SUP_CERTIFICATION_CENTER_ID,
   SUP_EXTERNAL_ID,
   TEAM_CERTIFICATION_OFFSET_ID_CENTERS,
diff --git a/api/db/seeds/data/team-certification/create-sco-organization-managing-student-with-siecle.js b/api/db/seeds/data/team-certification/create-sco-organization-managing-student-with-siecle.js
deleted file mode 100644
index ad0003689fb..00000000000
--- a/api/db/seeds/data/team-certification/create-sco-organization-managing-student-with-siecle.js
+++ /dev/null
@@ -1,114 +0,0 @@
-import { CertificationCenter } from '../../../../src/shared/domain/models/index.js';
-import { COLLEGE_TAG } from '../common/constants.js';
-import * as tooling from '../common/tooling/index.js';
-import { acceptPixOrgaTermsOfService } from '../common/tooling/legal-documents.js';
-import {
-  CERTIFICATION_SCO_MANAGING_STUDENTS_EXTERNAL_ID,
-  SCO_CERTIFICATION_CENTER_ID,
-  SCO_CERTIFICATION_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID,
-  SCO_CERTIFICATION_MANAGING_STUDENTS_ORGANIZATION_USER_ID,
-  SCO_MANAGING_STUDENTS_ORGANIZATION_ID,
-  SCO_PUBLISHED_SESSION,
-} from './constants.js';
-
-export async function scoOrganizationManaginStudentsWithSiecle({ databaseBuilder }) {
-  await _createScoOrganization({ databaseBuilder });
-  await _createScoCertificationCenter({ databaseBuilder });
-  await _createPublishedScoSession({ databaseBuilder });
-}
-
-async function _createScoOrganization({ databaseBuilder }) {
-  databaseBuilder.factory.buildUser.withRawPassword({
-    id: SCO_CERTIFICATION_MANAGING_STUDENTS_ORGANIZATION_USER_ID,
-    firstName: 'Orga User SCO managing Student',
-    lastName: 'Certification',
-    email: 'orga-sco-managing-students@example.net',
-    cgu: true,
-    lang: 'fr',
-    lastTermsOfServiceValidatedAt: new Date(),
-    mustValidateTermsOfService: false,
-    pixCertifTermsOfServiceAccepted: false,
-    hasSeenAssessmentInstructions: false,
-  });
-
-  acceptPixOrgaTermsOfService(databaseBuilder, SCO_CERTIFICATION_MANAGING_STUDENTS_ORGANIZATION_USER_ID);
-
-  await tooling.organization.createOrganization({
-    databaseBuilder,
-    organizationId: SCO_MANAGING_STUDENTS_ORGANIZATION_ID,
-    type: 'SCO',
-    name: 'Orga SCO Managing team Certification',
-    isManagingStudents: true,
-    externalId: CERTIFICATION_SCO_MANAGING_STUDENTS_EXTERNAL_ID,
-    adminIds: [SCO_CERTIFICATION_MANAGING_STUDENTS_ORGANIZATION_USER_ID],
-    configOrganization: {
-      learnerCount: 8,
-    },
-    tagIds: [COLLEGE_TAG.id],
-  });
-}
-
-async function _createScoCertificationCenter({ databaseBuilder }) {
-  databaseBuilder.factory.buildUser.withRawPassword({
-    id: SCO_CERTIFICATION_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID,
-    firstName: 'Certif User SCO managing student',
-    lastName: 'Certification',
-    email: 'certif-sco-v3@example.net',
-    cgu: true,
-    lang: 'fr',
-    lastTermsOfServiceValidatedAt: new Date(),
-    mustValidateTermsOfService: false,
-    pixCertifTermsOfServiceAccepted: false,
-    hasSeenAssessmentInstructions: false,
-  });
-
-  acceptPixOrgaTermsOfService(databaseBuilder, SCO_CERTIFICATION_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID);
-
-  await tooling.certificationCenter.createCertificationCenter({
-    databaseBuilder,
-    certificationCenterId: SCO_CERTIFICATION_CENTER_ID,
-    name: 'Centre de certification sco managing students',
-    type: CertificationCenter.types.SCO,
-    externalId: CERTIFICATION_SCO_MANAGING_STUDENTS_EXTERNAL_ID,
-    createdAt: new Date(),
-    updatedAt: new Date(),
-    members: [{ id: SCO_CERTIFICATION_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID }],
-    complementaryCertificationIds: [],
-    isV3Pilot: true,
-  });
-}
-
-async function _createPublishedScoSession({ databaseBuilder }) {
-  const sessionDate = new Date();
-
-  await tooling.session.createPublishedScoSession({
-    databaseBuilder,
-    sessionId: SCO_PUBLISHED_SESSION,
-    certificationCenterId: SCO_CERTIFICATION_CENTER_ID,
-    organizationId: SCO_MANAGING_STUDENTS_ORGANIZATION_ID,
-    accessCode: 'SCOS34',
-    address: '1 rue Certification sco',
-    certificationCenter: 'Centre de certification sco managing students',
-    date: sessionDate,
-    description: 'une description',
-    examiner: 'Un super examinateur',
-    room: '42',
-    time: '12:00',
-    examinerGlobalComment: 'Session sans pb',
-    hasIncident: false,
-    hasJoiningIssue: false,
-    createdAt: sessionDate,
-    finalizedAt: sessionDate,
-    resultsSentToPrescriberAt: sessionDate,
-    publishedAt: sessionDate,
-    assignedCertificationOfficerId: null,
-    juryComment: '',
-    juryCommentAuthorId: null,
-    juryCommentedAt: sessionDate,
-    configSession: {
-      learnersToRegisterCount: 8,
-      maxLevel: 3,
-      sessionDate,
-    },
-  });
-}
diff --git a/api/db/seeds/data/team-certification/data-builder.js b/api/db/seeds/data/team-certification/data-builder.js
index e8e344de0a8..ad241f7e7b8 100644
--- a/api/db/seeds/data/team-certification/data-builder.js
+++ b/api/db/seeds/data/team-certification/data-builder.js
@@ -1,21 +1,23 @@
 import * as tooling from '../common/tooling/index.js';
 import { acceptPixOrgaTermsOfService } from '../common/tooling/legal-documents.js';
+import simpleScoManagingStudentsCertificationCase from './cases/simple-sco-managing-students-certification.js';
 import { CERTIFIABLE_SUCCESS_USER_ID } from './constants.js';
 import { proOrganizationWithCertifCenter } from './create-pro-organization-with-certif-center.js';
 import { scoOrganizationManaginAgriStudentsWithFregata } from './create-sco-organization-managing-agri-student-with-fregata.js';
-import { scoOrganizationManaginStudentsWithSiecle } from './create-sco-organization-managing-student-with-siecle.js';
 import { scoOrganizationNotManagingStudents } from './create-sco-organization-not-managing-students.js';
 import { supCertificationCenterOnly } from './create-sup-certifification-center-only.js';
 import { setupConfigurations } from './setup-configuration.js';
 
 async function teamCertificationDataBuilder({ databaseBuilder }) {
   await scoOrganizationManaginAgriStudentsWithFregata({ databaseBuilder });
-  await scoOrganizationManaginStudentsWithSiecle({ databaseBuilder });
   await proOrganizationWithCertifCenter({ databaseBuilder });
   await supCertificationCenterOnly({ databaseBuilder });
   await scoOrganizationNotManagingStudents({ databaseBuilder });
   await _createSuccessCertifiableUser({ databaseBuilder });
   await setupConfigurations({ databaseBuilder });
+
+  // Cases
+  await simpleScoManagingStudentsCertificationCase({ databaseBuilder });
 }
 
 export { teamCertificationDataBuilder };


Reviews:
user: login: alexandrecoin
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T14:48:16Z
user: login: yaf
body: J'aime bien l'approche assez « global » que tu propose. 

Je pense que ta PR pourrait supprimer au moins le cas `scoOrganizationManaginStudentsWithSiecle`, voir aussi `scoOrganizationManaginAgriStudentsWithFregata` ....

Mais je laisse @Agnes-V en juger.
state: APPROVED
author_association: MEMBER
submitted_at: 2025-03-26T16:47:30Z
user: login: AndreiaPena
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-27T08:58:20Z
user: login: AndreiaPena
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-27T10:44:25Z
user: login: Jeyffrey
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-27T10:59:54Z
user: login: AndreiaPena
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-27T13:11:42Z

Review comments:
diff_hunk: @@ -0,0 +1,160 @@
+import { Candidate } from '../../../../../src/certification/enrolment/domain/models/Candidate.js';
+import { Subscription } from '../../../../../src/certification/enrolment/domain/models/Subscription.js';
+import { usecases as enrolmentUseCases } from '../../../../../src/certification/enrolment/domain/usecases/index.js';
+import { OrganizationForAdmin } from '../../../../../src/organizational-entities/domain/models/OrganizationForAdmin.js';
+import { usecases as organizationalEntitiesUsecases } from '../../../../../src/organizational-entities/domain/usecases/index.js';
+import * as organizationCreationValidator from '../../../../../src/organizational-entities/domain/validators/organization-creation-validator.js';
+import {
+  CertificationCenter,
+  types as certificationCenterTypes,
+} from '../../../../../src/shared/domain/models/CertificationCenter.js';
+import { Membership } from '../../../../../src/shared/domain/models/index.js';
+import { normalize } from '../../../../../src/shared/infrastructure/utils/string-utils.js';
+import { usecases as teamUsecases } from '../../../../../src/team/domain/usecases/index.js';
+import * as tooling from '../../common/tooling/index.js';
+import { acceptPixOrgaTermsOfService } from '../../common/tooling/legal-documents.js';
+import {
+  SIMPLE_SCO_CERTIFICATION_CENTER_ID,
+  SIMPLE_SCO_CERTIFICATION_USER_ID,
+  SIMPLE_SCO_ORGANIZATION_ID,
+  SIMPLE_SCO_ORGANIZATION_MEMBER_ID,
+  SIMPLE_SCO_SESSION,
+} from '../constants.js';
+
+/**
+ * --- CERTIFICATION CASE ---
+ *
+ * The goal here is to reproduce the most simple certification case:
+ *   - I'm a SCO user with a certifiable account
+ *   - I'm able to start a certification course
+ */
+export default async function simpleScoCertificationCase({ databaseBuilder }) {
+  /**
+   * 1. Create the certification session
+   */
+  const externalId = 'SCO_CERTIFICATION_ORGANIZATION';
+
+  const organizationMember = databaseBuilder.factory.buildUser.withRawPassword({
+    id: SIMPLE_SCO_ORGANIZATION_MEMBER_ID,
+    firstName: 'Sco',
+    lastName: 'Organization Member',
+    email: 'simple-sco-organization-member@example.net',
+    cgu: true,
+    lang: 'fr',
+    lastTermsOfServiceValidatedAt: new Date(),
+    pixCertifTermsOfServiceAccepted: true,
+  });
+
+  acceptPixOrgaTermsOfService(databaseBuilder, organizationMember.id);
+
+  await databaseBuilder.commit();
+
+  // Organization
+  const organization = new OrganizationForAdmin({
+    id: SIMPLE_SCO_ORGANIZATION_ID,
+    name: 'Certification Sco Organization #1',
+    type: 'SCO',
+    isManagingStudents: true,
+    externalId,
+  });
+
+  const newOrga = await organizationalEntitiesUsecases.createOrganization({
+    organization,
+    organizationCreationValidator,
+  });
+
+  const organizationMembership = await teamUsecases.createMembership({
+    organizationRole: Membership.roles.ADMIN,
+    userId: organizationMember.id,
+    organizationId: newOrga.id,
+  });
+
+  // Certification center
+  const certificationCenter = new CertificationCenter({
+    id: SIMPLE_SCO_CERTIFICATION_CENTER_ID,
+    name: 'Sco Certification Center #1',
+    type: certificationCenterTypes.SCO,
+    externalId,
+    createdAt: new Date('2022-01-30'),
+    habilitations: [],
+    isV3Pilot: true,
+  });
+
+  const certificationCenterForAdmin = await organizationalEntitiesUsecases.createCertificationCenter({
+    certificationCenter,
+    complementaryCertificationIds: [],
+  });
+
+  await teamUsecases.createCertificationCenterMembershipForScoOrganizationAdminMember({
+    membership: organizationMembership,
+  });
+
+  /**
+   * 2. Create the certifiable user
+   */
+  const scoUser = databaseBuilder.factory.buildUser.withRawPassword({
+    id: SIMPLE_SCO_CERTIFICATION_USER_ID,
+    firstName: 'Sco',
+    lastName: 'Certifiable',
+    email: 'certifiable-sco-user@example.net',
+    cgu: true,
+    lang: 'fr',
+    lastTermsOfServiceValidatedAt: new Date(),
+    pixCertifTermsOfServiceAccepted: true,
+  });
+
+  await tooling.profile.createCertifiableProfile({
+    databaseBuilder,
+    userId: scoUser.id,
+  });
+
+  const organizationLearner = databaseBuilder.factory.buildOrganizationLearner({
+    userId: scoUser.id,
+    organizationId: newOrga.id,
+  });
path: api/db/seeds/data/team-certification/cases/simple-sco-certification.js
user: login: AndreiaPena
body: le soucis vient de là, tu ne passe pas les informations du candidat que tu créé plus haut (nom/prénom etc...)
Le build va donc prendre ses noms/prénoms par défaut

Ça créé une incohérence dans les infos
created_at: 2025-03-27T08:58:20Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,167 @@
+import { Candidate } from '../../../../../src/certification/enrolment/domain/models/Candidate.js';
+import { Subscription } from '../../../../../src/certification/enrolment/domain/models/Subscription.js';
+import { usecases as enrolmentUseCases } from '../../../../../src/certification/enrolment/domain/usecases/index.js';
+import { OrganizationForAdmin } from '../../../../../src/organizational-entities/domain/models/OrganizationForAdmin.js';
+import { usecases as organizationalEntitiesUsecases } from '../../../../../src/organizational-entities/domain/usecases/index.js';
+import * as organizationCreationValidator from '../../../../../src/organizational-entities/domain/validators/organization-creation-validator.js';
+import {
+  CertificationCenter,
+  types as certificationCenterTypes,
+} from '../../../../../src/shared/domain/models/CertificationCenter.js';
+import { Membership } from '../../../../../src/shared/domain/models/index.js';
+import { normalize } from '../../../../../src/shared/infrastructure/utils/string-utils.js';
+import { usecases as teamUsecases } from '../../../../../src/team/domain/usecases/index.js';
+import * as tooling from '../../common/tooling/index.js';
+import { acceptPixOrgaTermsOfService } from '../../common/tooling/legal-documents.js';
+import {
+  SIMPLE_SCO_CERTIFICATION_CENTER_ID,
+  SIMPLE_SCO_CERTIFICATION_USER_ID,
+  SIMPLE_SCO_MANAGING_STUDENTS_ORGANIZATION_ID,
+  SIMPLE_SCO_ORGANIZATION_MEMBER_ID,
+  SIMPLE_SCO_SESSION,
+} from '../constants.js';
+
+/**
+ * --- CERTIFICATION CASE ---
+ *
+ * The goal here is to reproduce the most simple certification case:
+ *   - I'm a SCO user with a certifiable account
+ *   - I'm able to start a certification course
path: api/db/seeds/data/team-certification/cases/simple-sco-managing-students-certification.js
user: login: AndreiaPena
body: **Remarque** : Si on veut aller jusqu'à l'entrée en certification, dans ce cas il manque l'étape de l'espace surveillant qui autorise l'entrée du candidat en certification
created_at: 2025-03-27T10:44:25Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,167 @@
+import { Candidate } from '../../../../../src/certification/enrolment/domain/models/Candidate.js';
+import { Subscription } from '../../../../../src/certification/enrolment/domain/models/Subscription.js';
+import { usecases as enrolmentUseCases } from '../../../../../src/certification/enrolment/domain/usecases/index.js';
+import { OrganizationForAdmin } from '../../../../../src/organizational-entities/domain/models/OrganizationForAdmin.js';
+import { usecases as organizationalEntitiesUsecases } from '../../../../../src/organizational-entities/domain/usecases/index.js';
+import * as organizationCreationValidator from '../../../../../src/organizational-entities/domain/validators/organization-creation-validator.js';
+import {
+  CertificationCenter,
+  types as certificationCenterTypes,
+} from '../../../../../src/shared/domain/models/CertificationCenter.js';
+import { Membership } from '../../../../../src/shared/domain/models/index.js';
+import { normalize } from '../../../../../src/shared/infrastructure/utils/string-utils.js';
+import { usecases as teamUsecases } from '../../../../../src/team/domain/usecases/index.js';
+import * as tooling from '../../common/tooling/index.js';
+import { acceptPixOrgaTermsOfService } from '../../common/tooling/legal-documents.js';
+import {
+  SIMPLE_SCO_CERTIFICATION_CENTER_ID,
+  SIMPLE_SCO_CERTIFICATION_USER_ID,
+  SIMPLE_SCO_MANAGING_STUDENTS_ORGANIZATION_ID,
+  SIMPLE_SCO_ORGANIZATION_MEMBER_ID,
+  SIMPLE_SCO_SESSION,
+} from '../constants.js';
+
+/**
+ * --- CERTIFICATION CASE ---
+ *
+ * The goal here is to reproduce the most simple certification case:
+ *   - I'm a SCO user with a certifiable account
+ *   - I'm able to start a certification course
path: api/db/seeds/data/team-certification/cases/simple-sco-managing-students-certification.js
user: login: Jeyffrey
body: C'est fait ici :

```js
const candidate = new Candidate({
    authorizedToStart: true,
```
created_at: 2025-03-27T10:59:53Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,167 @@
+import { Candidate } from '../../../../../src/certification/enrolment/domain/models/Candidate.js';
+import { Subscription } from '../../../../../src/certification/enrolment/domain/models/Subscription.js';
+import { usecases as enrolmentUseCases } from '../../../../../src/certification/enrolment/domain/usecases/index.js';
+import { OrganizationForAdmin } from '../../../../../src/organizational-entities/domain/models/OrganizationForAdmin.js';
+import { usecases as organizationalEntitiesUsecases } from '../../../../../src/organizational-entities/domain/usecases/index.js';
+import * as organizationCreationValidator from '../../../../../src/organizational-entities/domain/validators/organization-creation-validator.js';
+import {
+  CertificationCenter,
+  types as certificationCenterTypes,
+} from '../../../../../src/shared/domain/models/CertificationCenter.js';
+import { Membership } from '../../../../../src/shared/domain/models/index.js';
+import { normalize } from '../../../../../src/shared/infrastructure/utils/string-utils.js';
+import { usecases as teamUsecases } from '../../../../../src/team/domain/usecases/index.js';
+import * as tooling from '../../common/tooling/index.js';
+import { acceptPixOrgaTermsOfService } from '../../common/tooling/legal-documents.js';
+import {
+  SIMPLE_SCO_CERTIFICATION_CENTER_ID,
+  SIMPLE_SCO_CERTIFICATION_USER_ID,
+  SIMPLE_SCO_MANAGING_STUDENTS_ORGANIZATION_ID,
+  SIMPLE_SCO_ORGANIZATION_MEMBER_ID,
+  SIMPLE_SCO_SESSION,
+} from '../constants.js';
+
+/**
+ * --- CERTIFICATION CASE ---
+ *
+ * The goal here is to reproduce the most simple certification case:
+ *   - I'm a SCO user with a certifiable account
+ *   - I'm able to start a certification course
path: api/db/seeds/data/team-certification/cases/simple-sco-managing-students-certification.js
user: login: AndreiaPena
body: oh j'avais pas vu ✅ 
created_at: 2025-03-27T13:11:42Z
author_association: MEMBER

PR comments:
user: login: pix-bot-github
created_at: 2025-03-26T12:01:58Z
body: Une fois les applications déployées, elles seront accessibles via les liens suivants :
  * [App (.fr)](https://app-pr11853.review.pix.fr)
  * [App (.org)](https://app-pr11853.review.pix.org)
  * [Orga (.fr)](https://orga-pr11853.review.pix.fr)
  * [Orga (.org)](https://orga-pr11853.review.pix.org)
  * [Certif (.fr)](https://certif-pr11853.review.pix.fr)
  * [Certif (.org)](https://certif-pr11853.review.pix.org)
  * [Junior](https://junior-pr11853.review.pix.fr)
  * [Admin](https://admin-pr11853.review.pix.fr)
  * [API](https://api-pr11853.review.pix.fr/api/)
  * [API MaDDo](https://pix-api-maddo-review-pr11853.osc-fr1.scalingo.io/api/)
  * [Audit Logger](https://pix-audit-logger-review-pr11853.osc-fr1.scalingo.io/api/)

Les variables d'environnement seront accessibles via les liens suivants :
  * [scalingo front](https://dashboard.scalingo.com/apps/osc-fr1/pix-front-review-pr11853/environment)
  * [scalingo api](https://dashboard.scalingo.com/apps/osc-fr1/pix-api-review-pr11853/environment)
  * [scalingo api-maddo](https://dashboard.scalingo.com/apps/osc-fr1/pix-api-maddo-review-pr11853/environment)
  * [scalingo audit-logger](https://dashboard.scalingo.com/apps/osc-fr1/pix-audit-logger-review-pr11853/environment)

author_association: NONE
user: login: Agnes-V
created_at: 2025-03-26T16:34:28Z
body: Quand je regarde dans Pix Orga, je trouve un élève qui s'appelle "first-name last-name" dans la base élèves mais dans Pix Certif je trouve un élève s'appelant "Sco Certifiable" alors qu'il devrait s'appeler "first-name last-name" comme dans le fichier importé côté Orga.
On retrouve d'ailleurs le bon prénom/nom quand on clique sur "Inscrire des candidats" côté Pix Certif/onglet "Candidats" (cf video).

https://github.com/user-attachments/assets/74f9da9c-374c-4ce0-a0cf-82b862ec70f6

L'idée de l'import SCO c'est justement de retrouver les mêmes élèves entre Pix Orga et Pix Certif. Si on souhaite modifier le nom/prénom d'un candidat SCO, il faut passer par un nouvel import côté Pix Orga (pour ne conserver qu'une seule source de vérité).
A part ça tout fonctionne 👌🏼✨
author_association: CONTRIBUTOR
user: login: Jeyffrey
created_at: 2025-03-26T16:37:54Z
body: Je comprends pas du tout d'où vient cet élève `first-name/last-name` à inscrire :( (en tout cas, il n'a aucun lien avec mes seeds)
Celui que j'ai créé est déjà inscrit à la session.

Faut que je regarde ça !

![image](https://github.com/user-attachments/assets/d22e9605-0aba-44fb-9983-ac6510787327)

author_association: CONTRIBUTOR
user: login: yaf
created_at: 2025-03-26T16:51:44Z
body: > Je comprends pas du tout d'où vient cet élève `first-name/last-name` à inscrire :( (en tout cas, il n'a aucun lien avec mes seeds) Celui que j'ai créé est déjà inscrit à la session.
> 
> Faut que je regarde ça !

C'est dans la création d'organisation  (voir https://github.com/1024pix/pix/blob/dev/api/db/seeds/data/common/tooling/organization-tooling.js).

Pour que les élèves ne soient pas créés automagiquement, il faut préciser `learnerCount = 0` pour le `OrganizationConfiguration`...

author_association: MEMBER