Skip to content

Commit

Permalink
♻️ api: fixing V3 tests
Browse files Browse the repository at this point in the history
Co-authored-by: Steph0 <[email protected]>
Co-authored-by: Guillaume Lagorce <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2024
1 parent baa2817 commit f5a4029
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand All @@ -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,
});

Expand Down Expand Up @@ -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,
Expand All @@ -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,
});

Expand All @@ -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 = {
Expand Down Expand Up @@ -776,7 +705,7 @@ const _createSession = async ({ version = 2 } = {}) => {
competences: [
{
id: 'recCompetence0',
index: '1',
index: '1.1',
tubes: [
{
id: 'recTube0_0',
Expand Down

0 comments on commit f5a4029

Please sign in to comment.