From f5a40298ec2b413b1fb4214c8139ca1ba5bac840 Mon Sep 17 00:00:00 2001 From: AndreiaPena Date: Mon, 18 Nov 2024 16:44:36 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20api:=20fixing=20V3=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Steph0 Co-authored-by: Guillaume Lagorce --- .../certification-course-route_test.js | 32 ++++ .../application/finalize-route_test.js | 157 +++++------------- 2 files changed, 75 insertions(+), 114 deletions(-) diff --git a/api/tests/certification/session-management/acceptance/application/certification-course-route_test.js b/api/tests/certification/session-management/acceptance/application/certification-course-route_test.js index 8ef2ede5781..a6d28a94203 100644 --- a/api/tests/certification/session-management/acceptance/application/certification-course-route_test.js +++ b/api/tests/certification/session-management/acceptance/application/certification-course-route_test.js @@ -1,3 +1,5 @@ +import { AlgorithmEngineVersion } from '../../../../../src/certification/shared/domain/models/AlgorithmEngineVersion.js'; +import { SESSIONS_VERSIONS } from '../../../../../src/certification/shared/domain/models/SessionVersion.js'; import { Assessment } from '../../../../../src/shared/domain/models/index.js'; import { createServer, @@ -268,14 +270,44 @@ describe('Certification | Session Management | Acceptance | Application | Routes const session = databaseBuilder.factory.buildSession({ publishedAt: new Date('2018-12-01T01:02:03Z'), + version: SESSIONS_VERSIONS.V3, }); const certificationCourse = databaseBuilder.factory.buildCertificationCourse({ sessionId: session.id, userId, isRejectedForFraud: true, + version: AlgorithmEngineVersion.V3, }); + const configurationCreatorId = databaseBuilder.factory.buildUser().id; + databaseBuilder.factory.buildCompetenceScoringConfiguration({ + createdByUserId: configurationCreatorId, + configuration: [ + { + competence: '1.1', + values: [ + { + bounds: { + max: 0, + min: -5, + }, + competenceLevel: 0, + }, + { + bounds: { + max: 5, + min: 0, + }, + competenceLevel: 1, + }, + ], + }, + ], + }); + databaseBuilder.factory.buildScoringConfiguration({ createdByUserId: configurationCreatorId }); + databaseBuilder.factory.buildFlashAlgorithmConfiguration(); + const { assessment, assessmentResult } = await createSuccessfulCertificationCourse({ sessionId: session.id, userId, diff --git a/api/tests/certification/session-management/acceptance/application/finalize-route_test.js b/api/tests/certification/session-management/acceptance/application/finalize-route_test.js index cbdecc8f90b..2911ceab8a0 100644 --- a/api/tests/certification/session-management/acceptance/application/finalize-route_test.js +++ b/api/tests/certification/session-management/acceptance/application/finalize-route_test.js @@ -1,7 +1,9 @@ +import { AlgorithmEngineVersion } from '../../../../../src/certification/shared/domain/models/AlgorithmEngineVersion.js'; import { CertificationIssueReportCategory, CertificationIssueReportSubcategories, } from '../../../../../src/certification/shared/domain/models/CertificationIssueReportCategory.js'; +import { SESSIONS_VERSIONS } from '../../../../../src/certification/shared/domain/models/SessionVersion.js'; import { AnswerStatus, Assessment, CertificationResult } from '../../../../../src/shared/domain/models/index.js'; import { createServer, @@ -190,33 +192,6 @@ describe('Certification | Session Management | Acceptance | Application | Route it('should set the finalized session as publishable when the issue reports have been resolved', async function () { // given - const learningContent = [ - { - id: 'recArea0', - code: '66', - competences: [ - { - id: 'recCompetence0', - index: '1', - tubes: [ - { - id: 'recTube0_0', - skills: [ - { - id: 'recSkill0_0', - nom: '@recSkill0_0', - challenges: [{ id: 'recChallenge0_0_0' }], - }, - ], - }, - ], - }, - ], - }, - ]; - const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); - const userId = databaseBuilder.factory.buildUser().id; const session = databaseBuilder.factory.buildSession(); const certificationCourseId = databaseBuilder.factory.buildCertificationCourse({ @@ -305,34 +280,6 @@ describe('Certification | Session Management | Acceptance | Application | Route it('should re score assessment when there is auto-neutralizable challenge', async function () { // given - - const learningContent = [ - { - id: 'recArea0', - code: '66', - competences: [ - { - id: 'recCompetence0', - index: '1', - tubes: [ - { - id: 'recTube0_0', - skills: [ - { - id: 'recSkill0_0', - nom: '@recSkill0_0', - challenges: [{ id: 'recChallenge0_0_0' }], - }, - ], - }, - ], - }, - ], - }, - ]; - const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); - const userId = databaseBuilder.factory.buildUser().id; const session = databaseBuilder.factory.buildSession(); const certificationCourseId = databaseBuilder.factory.buildCertificationCourse({ @@ -466,39 +413,13 @@ describe('Certification | Session Management | Acceptance | Application | Route it('should set the finalized session as publishable', async function () { // given - const learningContent = [ - { - id: 'recArea0', - code: '66', - competences: [ - { - id: 'recCompetence0', - index: '1', - tubes: [ - { - id: 'recTube0_0', - skills: [ - { - id: 'recSkill0_0', - nom: '@recSkill0_0', - challenges: [{ id: 'recChallenge0_0_0' }], - }, - ], - }, - ], - }, - ], - }, - ]; - const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); - const userId = databaseBuilder.factory.buildUser().id; - const session = databaseBuilder.factory.buildSession(); + const session = databaseBuilder.factory.buildSession({ version: SESSIONS_VERSIONS.V3 }); const certificationCourseId = databaseBuilder.factory.buildCertificationCourse({ userId, sessionId: session.id, completedAt: new Date(), + version: AlgorithmEngineVersion.V3, }).id; databaseBuilder.factory.buildCertificationCenterMembership({ userId, @@ -514,7 +435,7 @@ describe('Certification | Session Management | Acceptance | Application | Route certificationCourseId, category: CertificationIssueReportCategory.IN_CHALLENGE, description: '', - subcategory: CertificationIssueReportSubcategories.WEBSITE_BLOCKED, + subcategory: CertificationIssueReportSubcategories.EXTRA_TIME_PERCENTAGE, questionNumber: 1, }); @@ -577,39 +498,19 @@ describe('Certification | Session Management | Acceptance | Application | Route it('should mark the assessment as ended due to finalization', async function () { // given const abortReason = 'candidate'; - const learningContent = [ - { - id: 'recArea0', - code: '66', - competences: [ - { - id: 'recCompetence0', - index: '1', - tubes: [ - { - id: 'recTube0_0', - skills: [ - { - id: 'recSkill0_0', - nom: '@recSkill0_0', - challenges: [{ id: 'recChallenge0_0_0' }], - }, - ], - }, - ], - }, - ], - }, - ]; - const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); - const userId = databaseBuilder.factory.buildUser().id; - const session = databaseBuilder.factory.buildSession(); + const session = databaseBuilder.factory.buildSession({ version: SESSIONS_VERSIONS.V3 }); const certificationCourseId = databaseBuilder.factory.buildCertificationCourse({ + userId, sessionId: session.id, completedAt: null, + version: AlgorithmEngineVersion.V3, }).id; + databaseBuilder.factory.buildCertificationCandidate({ + sessionId: session.id, + userId, + reconciledAt: new Date('2020-01-01'), + }); databaseBuilder.factory.buildCertificationCenterMembership({ userId, certificationCenterId: session.certificationCenterId, @@ -627,7 +528,7 @@ describe('Certification | Session Management | Acceptance | Application | Route certificationCourseId, category: CertificationIssueReportCategory.IN_CHALLENGE, description: '', - subcategory: CertificationIssueReportSubcategories.WEBSITE_BLOCKED, + subcategory: CertificationIssueReportSubcategories.EXTRA_TIME_PERCENTAGE, questionNumber: 1, }); @@ -647,6 +548,34 @@ describe('Certification | Session Management | Acceptance | Application | Route result: AnswerStatus.KO.status, }); + const configurationCreatorId = databaseBuilder.factory.buildUser().id; + databaseBuilder.factory.buildCompetenceScoringConfiguration({ + createdByUserId: configurationCreatorId, + configuration: [ + { + competence: '1.1', + values: [ + { + bounds: { + max: 0, + min: -5, + }, + competenceLevel: 0, + }, + { + bounds: { + max: 5, + min: 0, + }, + competenceLevel: 1, + }, + ], + }, + ], + }); + databaseBuilder.factory.buildScoringConfiguration({ createdByUserId: configurationCreatorId }); + databaseBuilder.factory.buildFlashAlgorithmConfiguration(); + await databaseBuilder.commit(); options = { @@ -776,7 +705,7 @@ const _createSession = async ({ version = 2 } = {}) => { competences: [ { id: 'recCompetence0', - index: '1', + index: '1.1', tubes: [ { id: 'recTube0_0',