diff --git a/api/db/database-builder/database-builder.js b/api/db/database-builder/database-builder.js index 061c4a316eb..b4bff3800b4 100644 --- a/api/db/database-builder/database-builder.js +++ b/api/db/database-builder/database-builder.js @@ -192,6 +192,7 @@ class DatabaseBuilder { } const publicResults = await this.knex.raw(_constructRawQuery('public')); + const learningContentResults = await this.knex.raw(_constructRawQuery('learningcontent')); const pgbossResults = await this.knex.raw(_constructRawQuery('pgboss')); this.tablesOrderedByDependencyWithDirtinessMap = []; @@ -202,6 +203,12 @@ class DatabaseBuilder { isDirty: false, }); }); + learningContentResults.rows.forEach(({ table_name }) => { + this.tablesOrderedByDependencyWithDirtinessMap.push({ + table: `learningcontent.${table_name}`, + isDirty: false, + }); + }); pgbossResults.rows.forEach(({ table_name }) => { if (table_name === 'version') return; this.tablesOrderedByDependencyWithDirtinessMap.push({ diff --git a/api/db/database-builder/factory/index.js b/api/db/database-builder/factory/index.js index e78697aa33a..62947fc5be9 100644 --- a/api/db/database-builder/factory/index.js +++ b/api/db/database-builder/factory/index.js @@ -5,6 +5,7 @@ import { importNamedExportsFromDirectory } from '../../../src/shared/infrastruct import * as buildDataProtectionOfficer from './build-data-protection-officer.js'; import * as campaignParticipationOverviewFactory from './campaign-participation-overview-factory.js'; import * as knowledgeElementSnapshotFactory from './knowledge-elements-snapshot-factory.js'; +import * as learningContent from './learning-content/index.js'; import * as poleEmploiSendingFactory from './pole-emploi-sending-factory.js'; const path = dirname(fileURLToPath(import.meta.url)); @@ -47,4 +48,5 @@ export const factory = { knowledgeElementSnapshotFactory, poleEmploiSendingFactory, buildDataProtectionOfficer, + learningContent, }; diff --git a/api/db/database-builder/factory/learning-content/build-area.js b/api/db/database-builder/factory/learning-content/build-area.js new file mode 100644 index 00000000000..80f4368e01b --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-area.js @@ -0,0 +1,25 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildArea({ + id = 'areaIdA', + code = 'code Domaine A', + name = 'name Domaine A', + title_i18n = { fr: 'title FR Domaine A', en: 'title EN Domaine A' }, + color = 'color Domaine A', + frameworkId = 'frameworkPix', + competenceIds = ['competenceIdA'], +} = {}) { + const values = { + id, + code, + name, + title_i18n, + color, + frameworkId, + competenceIds, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.areas', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build-challenge.js b/api/db/database-builder/factory/learning-content/build-challenge.js new file mode 100644 index 00000000000..5629ae9b4a6 --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-challenge.js @@ -0,0 +1,85 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildChallenge({ + id = 'challengeIdA', + instruction = 'instruction Epreuve A', + alternativeInstruction = 'alternativeInstruction Epreuve A', + proposals = 'proposals Epreuve A', + type = 'QCU', + solution = 'solution Epreuve A', + solutionToDisplay = 'solutionToDisplay Epreuve A', + t1Status = true, + t2Status = true, + t3Status = true, + status = 'archivé', + genealogy = 'genealogy Epreuve A', + accessibility1 = 'accessibility1 Epreuve A', + accessibility2 = 'accessibility2 Epreuve B', + requireGafamWebsiteAccess = true, + isIncompatibleIpadCertif = true, + deafAndHardOfHearing = 'deafAndHardOfHearing Epreuve A', + isAwarenessChallenge = true, + toRephrase = true, + alternativeVersion = 8, + shuffled = true, + illustrationAlt = 'illustrationAlt Epreuve A', + illustrationUrl = 'illustrationUrl Epreuve A', + attachments = ['attachment1', 'attachment2'], + responsive = 'responsive Epreuve A', + alpha = 1.1, + delta = 3.3, + autoReply = true, + focusable = true, + format = 'format Epreuve A', + timer = 180, + embedHeight = 800, + embedUrl = 'embedUrl Epreuve A', + embedTitle = 'embedTitle Epreuve A', + locales = ['fr'], + competenceId = 'competenceIdA', + skillId = 'skillIdA', +} = {}) { + const values = { + id, + instruction, + alternativeInstruction, + proposals, + type, + solution, + solutionToDisplay, + t1Status, + t2Status, + t3Status, + status, + genealogy, + accessibility1, + accessibility2, + requireGafamWebsiteAccess, + isIncompatibleIpadCertif, + deafAndHardOfHearing, + isAwarenessChallenge, + toRephrase, + alternativeVersion, + shuffled, + illustrationAlt, + illustrationUrl, + attachments, + responsive, + alpha, + delta, + autoReply, + focusable, + format, + timer, + embedHeight, + embedUrl, + embedTitle, + locales, + competenceId, + skillId, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.challenges', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build-competence.js b/api/db/database-builder/factory/learning-content/build-competence.js new file mode 100644 index 00000000000..02786e8f01a --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-competence.js @@ -0,0 +1,27 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildCompetence({ + id = 'competenceIdA', + name_i18n = { fr: 'name FR Compétence A', en: 'name EN Compétence A' }, + description_i18n = { fr: 'description FR Compétence A', en: 'description EN Compétence A' }, + index = 'index Compétence A', + origin = 'origin Compétence A', + areaId = 'areaIdA', + skillIds = ['skillIdA'], + thematicIds = ['thematicIdA'], +} = {}) { + const values = { + id, + name_i18n, + description_i18n, + index, + origin, + areaId, + skillIds, + thematicIds, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.competences', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build-course.js b/api/db/database-builder/factory/learning-content/build-course.js new file mode 100644 index 00000000000..482db13cea3 --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-course.js @@ -0,0 +1,23 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildCourse({ + id = 'courseIdA', + name = 'instruction Test Statique A', + description = 'description Test Statique A', + isActive = true, + competences = ['competenceIdA'], + challenges = ['challengeIdA'], +} = {}) { + const values = { + id, + name, + description, + isActive, + competences, + challenges, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.courses', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build-framework.js b/api/db/database-builder/factory/learning-content/build-framework.js new file mode 100644 index 00000000000..7c2d55e83af --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-framework.js @@ -0,0 +1,12 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildFramework({ id = 'frameworkPix', name = 'Pix' } = {}) { + const values = { + id, + name, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.frameworks', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build-mission.js b/api/db/database-builder/factory/learning-content/build-mission.js new file mode 100644 index 00000000000..d85eba5d280 --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-mission.js @@ -0,0 +1,33 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildMission({ + id = 'missionIdA', + status = 'status Mission A', + name_i18n = { fr: 'name FR Mission A', en: 'name EN Mission A' }, + content = { some: 'content' }, + learningObjectives_i18n = { fr: 'learningObjectives FR Mission A', en: 'learningObjectives EN Mission A' }, + validatedObjectives_i18n = { fr: 'validatedObjectives FR Mission A', en: 'validatedObjectives EN Mission A' }, + introductionMediaType = 'introductionMediaType Mission A', + introductionMediaAlt_i18n = { fr: 'introductionMediaAlt FR Mission A', en: 'introductionMediaAlt EN Mission A' }, + documentationUrl = 'documentationUrl Mission A', + cardImageUrl = 'cardImageUrl Mission A', + competenceId = 'competenceIdA', +} = {}) { + const values = { + id, + status, + name_i18n, + content, + learningObjectives_i18n, + validatedObjectives_i18n, + introductionMediaType, + introductionMediaAlt_i18n, + documentationUrl, + cardImageUrl, + competenceId, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.missions', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build-skill.js b/api/db/database-builder/factory/learning-content/build-skill.js new file mode 100644 index 00000000000..ddea6456ba8 --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-skill.js @@ -0,0 +1,33 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildSkill({ + id = 'skillIdA', + name = 'name Acquis A', + status = 'status Acquis A', + pixValue = 2.9, + version = 5, + level = 2, + hintStatus = 'hintStatus Acquis A', + competenceId = 'competenceIdA', + tubeId = 'tubeIdA', + tutorialIds = ['tutorialIdA'], + learningMoreTutorialIds = [], +} = {}) { + const values = { + id, + name, + status, + pixValue, + version, + level, + hintStatus, + competenceId, + tubeId, + tutorialIds, + learningMoreTutorialIds, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.skills', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build-thematic.js b/api/db/database-builder/factory/learning-content/build-thematic.js new file mode 100644 index 00000000000..76dedfa65ee --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-thematic.js @@ -0,0 +1,21 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildThematic({ + id = 'thematicIdA', + name_i18n = { fr: 'name FR Thématique A', en: 'name EN Thématique A' }, + index = 8, + competenceId = 'competenceIdA', + tubeIds = ['tubeIdA'], +} = {}) { + const values = { + id, + name_i18n, + index, + competenceId, + tubeIds, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.thematics', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build-tube.js b/api/db/database-builder/factory/learning-content/build-tube.js new file mode 100644 index 00000000000..fd7db356dea --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-tube.js @@ -0,0 +1,33 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildTube({ + id = 'tubeIdA', + name = 'name Tube A', + title = 'title Tube A', + description = 'description Tube A', + practicalTitle_i18n = { fr: 'practicalTitle FR Tube A', en: 'practicalTitle EN Tube A' }, + practicalDescription_i18n = { fr: 'practicalDescription FR Tube A', en: 'practicalDescription EN Tube A' }, + competenceId = 'competenceIdA', + thematicId = 'thematicIdA', + skillIds = ['skillIdA'], + isMobileCompliant = true, + isTabletCompliant = true, +} = {}) { + const values = { + id, + name, + title, + description, + practicalTitle_i18n, + practicalDescription_i18n, + competenceId, + thematicId, + skillIds, + isMobileCompliant, + isTabletCompliant, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.tubes', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build-tutorial.js b/api/db/database-builder/factory/learning-content/build-tutorial.js new file mode 100644 index 00000000000..1ccd5981da9 --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build-tutorial.js @@ -0,0 +1,25 @@ +import { databaseBuffer } from '../../database-buffer.js'; + +export function buildTutorial({ + id = 'tutorialIdA', + duration = 'duration Tutoriel A', + format = 'format Tutoriel A', + title = 'title Tutoriel A', + source = 'source Tutoriel A', + link = 'link Tutoriel A', + locale = 'fr', +} = {}) { + const values = { + id, + duration, + format, + title, + source, + link, + locale, + }; + return databaseBuffer.pushInsertable({ + tableName: 'learningcontent.tutorials', + values, + }); +} diff --git a/api/db/database-builder/factory/learning-content/build.js b/api/db/database-builder/factory/learning-content/build.js new file mode 100644 index 00000000000..cd1641122e4 --- /dev/null +++ b/api/db/database-builder/factory/learning-content/build.js @@ -0,0 +1,30 @@ +import nock from 'nock'; + +import { buildArea } from './build-area.js'; +import { buildChallenge } from './build-challenge.js'; +import { buildCompetence } from './build-competence.js'; +import { buildCourse } from './build-course.js'; +import { buildFramework } from './build-framework.js'; +import { buildMission } from './build-mission.js'; +import { buildSkill } from './build-skill.js'; +import { buildThematic } from './build-thematic.js'; +import { buildTube } from './build-tube.js'; +import { buildTutorial } from './build-tutorial.js'; + +export function build(learningContent) { + learningContent.frameworks?.forEach(buildFramework); + learningContent.areas?.forEach(buildArea); + learningContent.competences?.forEach(buildCompetence); + learningContent.thematics?.forEach(buildThematic); + learningContent.tubes?.forEach(buildTube); + learningContent.skills?.forEach(buildSkill); + learningContent.challenges?.forEach(buildChallenge); + learningContent.courses?.forEach(buildCourse); + learningContent.tutorials?.forEach(buildTutorial); + learningContent.missions?.forEach(buildMission); + + return nock('https://lcms-test.pix.fr/api') + .get('/releases/latest') + .matchHeader('Authorization', 'Bearer test-api-key') + .reply(200, { content: learningContent }); +} diff --git a/api/db/database-builder/factory/learning-content/index.js b/api/db/database-builder/factory/learning-content/index.js new file mode 100644 index 00000000000..8329b287d3f --- /dev/null +++ b/api/db/database-builder/factory/learning-content/index.js @@ -0,0 +1,11 @@ +export * from './build.js'; +export * from './build-area.js'; +export * from './build-challenge.js'; +export * from './build-competence.js'; +export * from './build-course.js'; +export * from './build-framework.js'; +export * from './build-mission.js'; +export * from './build-skill.js'; +export * from './build-thematic.js'; +export * from './build-tube.js'; +export * from './build-tutorial.js'; diff --git a/api/db/migrations/20241125150331_remove-learningcontent-foreignkeys.js b/api/db/migrations/20241125150331_remove-learningcontent-foreignkeys.js new file mode 100644 index 00000000000..7002f39110d --- /dev/null +++ b/api/db/migrations/20241125150331_remove-learningcontent-foreignkeys.js @@ -0,0 +1,36 @@ +const SCHEMA_NAME = 'learningcontent'; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +export async function up(knex) { + await knex.schema.withSchema(SCHEMA_NAME).alterTable('areas', function (table) { + table.dropForeign('frameworkId'); + }); + await knex.schema.withSchema(SCHEMA_NAME).alterTable('competences', function (table) { + table.dropForeign('areaId'); + }); + await knex.schema.withSchema(SCHEMA_NAME).alterTable('thematics', function (table) { + table.dropForeign('competenceId'); + }); + await knex.schema.withSchema(SCHEMA_NAME).alterTable('tubes', function (table) { + table.dropForeign('competenceId'); + table.dropForeign('thematicId'); + }); + await knex.schema.withSchema(SCHEMA_NAME).alterTable('skills', function (table) { + table.dropForeign('competenceId'); + table.dropForeign('tubeId'); + }); + await knex.schema.withSchema(SCHEMA_NAME).alterTable('challenges', function (table) { + table.dropForeign('competenceId'); + table.dropForeign('skillId'); + }); + await knex.schema.withSchema(SCHEMA_NAME).alterTable('missions', function (table) { + table.dropForeign('competenceId'); + }); +} + +export function down() { + // non +} diff --git a/api/tests/acceptance/application/courses/course-controller_test.js b/api/tests/acceptance/application/courses/course-controller_test.js index 6514fb8f985..1398ffa03c6 100644 --- a/api/tests/acceptance/application/courses/course-controller_test.js +++ b/api/tests/acceptance/application/courses/course-controller_test.js @@ -16,7 +16,7 @@ describe('Acceptance | API | Courses', function () { }); describe('GET /api/courses/:course_id', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = [ { id: '1. Information et données', @@ -57,7 +57,7 @@ describe('Acceptance | API | Courses', function () { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); after(function () { diff --git a/api/tests/acceptance/application/frameworks/frameworks-controller_test.js b/api/tests/acceptance/application/frameworks/frameworks-controller_test.js index 07fc48c05ce..7037d68a699 100644 --- a/api/tests/acceptance/application/frameworks/frameworks-controller_test.js +++ b/api/tests/acceptance/application/frameworks/frameworks-controller_test.js @@ -193,7 +193,7 @@ describe('Acceptance | Controller | frameworks-controller', function () { beforeEach(async function () { userId = databaseBuilder.factory.buildUser().id; await databaseBuilder.commit(); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should return response code 200', async function () { @@ -442,7 +442,7 @@ describe('Acceptance | Controller | frameworks-controller', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const options = { method: 'GET', url: `/api/admin/frameworks/fmk1/areas`, diff --git a/api/tests/acceptance/application/scenario-simulator/scenario-simulator-controller_test.js b/api/tests/acceptance/application/scenario-simulator/scenario-simulator-controller_test.js index b4815805084..5731e2fab0f 100644 --- a/api/tests/acceptance/application/scenario-simulator/scenario-simulator-controller_test.js +++ b/api/tests/acceptance/application/scenario-simulator/scenario-simulator-controller_test.js @@ -129,7 +129,7 @@ describe('Acceptance | Controller | scenario-simulator-controller', function () ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); server = await createServer(); }); diff --git a/api/tests/acceptance/application/users/users-controller-get-user-profile-for-admin_test.js b/api/tests/acceptance/application/users/users-controller-get-user-profile-for-admin_test.js index 07766c7443b..8ea03937129 100644 --- a/api/tests/acceptance/application/users/users-controller-get-user-profile-for-admin_test.js +++ b/api/tests/acceptance/application/users/users-controller-get-user-profile-for-admin_test.js @@ -98,7 +98,7 @@ describe('Acceptance | Controller | users-controller-get-user-profile-for-admin' const superAdmin = await insertUserWithRoleSuperAdmin(); options.headers.authorization = generateValidRequestAuthorizationHeader(superAdmin.id); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); knowledgeElement = databaseBuilder.factory.buildKnowledgeElement({ userId, diff --git a/api/tests/acceptance/application/users/users-controller-get-user-profile_test.js b/api/tests/acceptance/application/users/users-controller-get-user-profile_test.js index 553201cef5d..d103ae41962 100644 --- a/api/tests/acceptance/application/users/users-controller-get-user-profile_test.js +++ b/api/tests/acceptance/application/users/users-controller-get-user-profile_test.js @@ -97,7 +97,7 @@ describe('Acceptance | Controller | users-controller-get-user-profile', function beforeEach(async function () { options.headers.authorization = generateValidRequestAuthorizationHeader(userId); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); knowledgeElement = databaseBuilder.factory.buildKnowledgeElement({ userId, diff --git a/api/tests/acceptance/application/users/users-controller-reset-scorecard_test.js b/api/tests/acceptance/application/users/users-controller-reset-scorecard_test.js index 7fde402426e..d4ed556e5d4 100644 --- a/api/tests/acceptance/application/users/users-controller-reset-scorecard_test.js +++ b/api/tests/acceptance/application/users/users-controller-reset-scorecard_test.js @@ -100,7 +100,7 @@ describe('Acceptance | Controller | users-controller-reset-scorecard', function }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); server = await createServer(); }); diff --git a/api/tests/certification/enrolment/acceptance/application/session-route_test.js b/api/tests/certification/enrolment/acceptance/application/session-route_test.js index cb3dd9bdaac..ff40c0a4088 100644 --- a/api/tests/certification/enrolment/acceptance/application/session-route_test.js +++ b/api/tests/certification/enrolment/acceptance/application/session-route_test.js @@ -355,7 +355,7 @@ describe('Certification | Enrolment | Acceptance | Routes | session-route', func }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); context('not SCO / isManagingStudents', function () { diff --git a/api/tests/certification/enrolment/acceptance/application/subscription-route_test.js b/api/tests/certification/enrolment/acceptance/application/subscription-route_test.js index 934d81221eb..3c9ecbb4a05 100644 --- a/api/tests/certification/enrolment/acceptance/application/subscription-route_test.js +++ b/api/tests/certification/enrolment/acceptance/application/subscription-route_test.js @@ -15,7 +15,7 @@ describe('Certification | Enrolment | Acceptance | Application | Routes | subscr const server = await createServer(); const learningContent = _buildLearningContent(); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const userId = databaseBuilder.factory.buildUser().id; diff --git a/api/tests/certification/enrolment/acceptance/application/user-route_test.js b/api/tests/certification/enrolment/acceptance/application/user-route_test.js index 9ee32c43c53..4d07f3a17a1 100644 --- a/api/tests/certification/enrolment/acceptance/application/user-route_test.js +++ b/api/tests/certification/enrolment/acceptance/application/user-route_test.js @@ -175,7 +175,7 @@ describe('Certification | Enrolment | Acceptance | Routes | User', function () { ], }, ]); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); learningContent.skills.forEach(({ id: skillId, competenceId }) => { databaseBuilder.factory.buildKnowledgeElement({ userId: user.id, earnedPix: 10, competenceId, skillId }); diff --git a/api/tests/certification/evaluation/acceptance/answer-route_test.js b/api/tests/certification/evaluation/acceptance/answer-route_test.js index 00f38e41c26..85e9ce545b5 100644 --- a/api/tests/certification/evaluation/acceptance/answer-route_test.js +++ b/api/tests/certification/evaluation/acceptance/answer-route_test.js @@ -19,7 +19,7 @@ describe('Certification | Evaluation | Acceptance | answer-route', function () { context('when the candidate needs an accessibility adjustment', function () { it('should save the answer as correct', async function () { // given - const { competenceId, challengeId } = _buildLearningContent(); + const { competenceId, challengeId } = await _buildLearningContent(); const { assessmentId, userId } = await _setupTestData(databaseBuilder, { competenceId, doesCandidateNeedAccessibilityAdjustment: true, @@ -39,7 +39,7 @@ describe('Certification | Evaluation | Acceptance | answer-route', function () { context('when the candidate does not need an accessibility adjustment', function () { it('should save the answer as focused out', async function () { // given - const { competenceId, challengeId } = _buildLearningContent(); + const { competenceId, challengeId } = await _buildLearningContent(); const { assessmentId, userId } = await _setupTestData(databaseBuilder, { competenceId, doesCandidateNeedAccessibilityAdjustment: false, @@ -118,7 +118,7 @@ function _setupRequestOptions({ userId, challengeId, assessmentId }) { }; } -function _buildLearningContent() { +async function _buildLearningContent() { const challengeId = 'a_challenge_id'; const competenceId = 'recCompetence'; @@ -160,7 +160,7 @@ function _buildLearningContent() { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); return { competenceId, diff --git a/api/tests/certification/evaluation/acceptance/application/certification-courses/certification-course-controller_test.js b/api/tests/certification/evaluation/acceptance/application/certification-courses/certification-course-controller_test.js index 59dfcedb1d4..70c438e62c7 100644 --- a/api/tests/certification/evaluation/acceptance/application/certification-courses/certification-course-controller_test.js +++ b/api/tests/certification/evaluation/acceptance/application/certification-courses/certification-course-controller_test.js @@ -4,7 +4,7 @@ import { SessionVersion, } from '../../../../../../src/certification/shared/domain/models/SessionVersion.js'; import { config } from '../../../../../../src/shared/config.js'; -import { KnowledgeElement } from '../../../../../../src/shared/domain/models/KnowledgeElement.js'; +import { KnowledgeElement } from '../../../../../../src/shared/domain/models/index.js'; import { createServer, databaseBuilder, @@ -12,7 +12,6 @@ import { generateValidRequestAuthorizationHeader, knex, learningContentBuilder, - mockLearningContent, } from '../../../../../test-helper.js'; describe('Acceptance | API | Certification Course', function () { @@ -270,7 +269,7 @@ describe('Acceptance | API | Certification Course', function () { id: 'recCompetence5', tubes: [ { - id: 'recTube0_0', + id: 'recTube5_0', skills: [ { id: 'recSkill5_0', @@ -295,7 +294,7 @@ describe('Acceptance | API | Certification Course', function () { id: 'recCompetence6', tubes: [ { - id: 'recTube0_0', + id: 'recTube6_0', skills: [ { id: 'recSkill6_0', @@ -513,7 +512,7 @@ function _createRequestOptions( function _createNonExistingCertifCourseSetup({ learningContent, sessionId, userId }) { const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + databaseBuilder.factory.learningContent.build(learningContentObjects); const certificationCandidate = databaseBuilder.factory.buildCertificationCandidate({ sessionId, userId, diff --git a/api/tests/certification/evaluation/acceptance/application/certification-courses/index_test.js b/api/tests/certification/evaluation/acceptance/application/certification-courses/index_test.js index 3c840cf5622..3e031e18972 100644 --- a/api/tests/certification/evaluation/acceptance/application/certification-courses/index_test.js +++ b/api/tests/certification/evaluation/acceptance/application/certification-courses/index_test.js @@ -18,7 +18,7 @@ describe('Acceptance | Route | Certification Courses', function () { describe('POST /api/certification-courses', function () { context('when the certification course does not exist', function () { let learningContent; - beforeEach(function () { + beforeEach(async function () { learningContent = [ { id: 'recArea0', @@ -167,7 +167,7 @@ describe('Acceptance | Route | Certification Courses', function () { id: 'recCompetence5', tubes: [ { - id: 'recTube0_0', + id: 'recTube5_0', skills: [ { id: 'recSkill5_0', @@ -192,7 +192,7 @@ describe('Acceptance | Route | Certification Courses', function () { id: 'recCompetence6', tubes: [ { - id: 'recTube0_0', + id: 'recTube6_0', skills: [ { id: 'recSkill6_0', @@ -214,7 +214,7 @@ describe('Acceptance | Route | Certification Courses', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should create a certification course in database', async function () { // given diff --git a/api/tests/certification/evaluation/integration/evaluation/jobs/certification-completed-job-controller_test.js b/api/tests/certification/evaluation/integration/evaluation/jobs/certification-completed-job-controller_test.js index 90ab02e3bca..d3070f12aad 100644 --- a/api/tests/certification/evaluation/integration/evaluation/jobs/certification-completed-job-controller_test.js +++ b/api/tests/certification/evaluation/integration/evaluation/jobs/certification-completed-job-controller_test.js @@ -171,7 +171,7 @@ describe('Integration | Certification | Application | jobs | CertificationComple index: '2.2', tubes: [ { - id: 'recTube4_0', + id: 'recTube5_0', skills: [ { id: 'recSkill5_0', @@ -187,7 +187,7 @@ describe('Integration | Certification | Application | jobs | CertificationComple index: '2.3', tubes: [ { - id: 'recTube4_0', + id: 'recTube6_0', skills: [ { id: 'recSkill6_0', @@ -295,7 +295,7 @@ describe('Integration | Certification | Application | jobs | CertificationComple index: '4.1', tubes: [ { - id: 'recTube4_0', + id: 'recTube12_0', skills: [ { id: 'recSkill12_0', @@ -382,7 +382,7 @@ describe('Integration | Certification | Application | jobs | CertificationComple beforeEach(async function () { const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); certificationCompletedJobController = new CertificationCompletedJobController(); diff --git a/api/tests/certification/evaluation/integration/infrastructure/repositories/certified-profile-repository_test.js b/api/tests/certification/evaluation/integration/infrastructure/repositories/certified-profile-repository_test.js index 8002452b48f..0eca9ca8c5a 100644 --- a/api/tests/certification/evaluation/integration/infrastructure/repositories/certified-profile-repository_test.js +++ b/api/tests/certification/evaluation/integration/infrastructure/repositories/certified-profile-repository_test.js @@ -2,7 +2,7 @@ import * as certifiedProfileRepository from '../../../../../../src/certification import { NotFoundError } from '../../../../../../src/shared/domain/errors.js'; import { KnowledgeElement } from '../../../../../../src/shared/domain/models/KnowledgeElement.js'; import { CertifiedProfile } from '../../../../../../src/shared/domain/read-models/CertifiedProfile.js'; -import { catchErr, databaseBuilder, domainBuilder, expect, mockLearningContent } from '../../../../../test-helper.js'; +import { catchErr, databaseBuilder, domainBuilder, expect } from '../../../../../test-helper.js'; describe('Integration | Repository | Certified Profile', function () { describe('#get', function () { @@ -174,7 +174,7 @@ describe('Integration | Repository | Certified Profile', function () { certifiedCompetences: [competence1_1, competence1_2], certifiedAreas: [area1], }); - mockLearningContent(learningContent); + databaseBuilder.factory.learningContent.build(learningContent); await databaseBuilder.commit(); // when @@ -295,7 +295,7 @@ describe('Integration | Repository | Certified Profile', function () { associatedSkillId: 'recArea1_Competence1_Tube1_Skill2', }); - mockLearningContent(learningContent); + databaseBuilder.factory.learningContent.build(learningContent); await databaseBuilder.commit(); // when diff --git a/api/tests/certification/results/acceptance/application/certification-attestation-route_test.js b/api/tests/certification/results/acceptance/application/certification-attestation-route_test.js index 8b94fdef53c..0d78e0d7b54 100644 --- a/api/tests/certification/results/acceptance/application/certification-attestation-route_test.js +++ b/api/tests/certification/results/acceptance/application/certification-attestation-route_test.js @@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises'; import * as url from 'node:url'; import { generateCertificateVerificationCode } from '../../../../../lib/domain/services/verify-certificate-code-service.js'; -import { Assessment } from '../../../../../src/shared/domain/models/Assessment.js'; +import { Assessment } from '../../../../../src/shared/domain/models/index.js'; import { AssessmentResult, Membership } from '../../../../../src/shared/domain/models/index.js'; import { createServer, @@ -36,13 +36,13 @@ describe('Certification | Results | Acceptance | Application | Routes | certific { id: 'recSkillId1', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD1' }, + { id: 'rec0gm0GFue3PQB3k1' }, + { id: 'rec0hoSlSwCeNNLkq1' }, + { id: 'rec2FcZ4jsPuY1QYt1' }, + { id: 'rec39bDMnaVw3MyMR1' }, + { id: 'rec3FMoD8h9USTktb1' }, + { id: 'rec3P7fvPSpFkIFLV1' }, ], }, ], @@ -60,13 +60,13 @@ describe('Certification | Results | Acceptance | Application | Routes | certific { id: 'recSkillId2', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD2' }, + { id: 'rec0gm0GFue3PQB3k2' }, + { id: 'rec0hoSlSwCeNNLkq2' }, + { id: 'rec2FcZ4jsPuY1QYt2' }, + { id: 'rec39bDMnaVw3MyMR2' }, + { id: 'rec3FMoD8h9USTktb2' }, + { id: 'rec3P7fvPSpFkIFLV2' }, ], }, ], @@ -84,13 +84,13 @@ describe('Certification | Results | Acceptance | Application | Routes | certific { id: 'recSkillId3', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD3' }, + { id: 'rec0gm0GFue3PQB3k3' }, + { id: 'rec0hoSlSwCeNNLkq3' }, + { id: 'rec2FcZ4jsPuY1QYt3' }, + { id: 'rec39bDMnaVw3MyMR3' }, + { id: 'rec3FMoD8h9USTktb3' }, + { id: 'rec3P7fvPSpFkIFLV3' }, ], }, ], @@ -102,7 +102,7 @@ describe('Certification | Results | Acceptance | Application | Routes | certific ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); nock('http://tarte.fr') diff --git a/api/tests/certification/results/acceptance/application/certification-route_test.js b/api/tests/certification/results/acceptance/application/certification-route_test.js index 5ee67c4b20c..6f8f1bca3fd 100644 --- a/api/tests/certification/results/acceptance/application/certification-route_test.js +++ b/api/tests/certification/results/acceptance/application/certification-route_test.js @@ -1,7 +1,7 @@ import { generateCertificateVerificationCode } from '../../../../../lib/domain/services/verify-certificate-code-service.js'; import { AutoJuryCommentKeys } from '../../../../../src/certification/shared/domain/models/JuryComment.js'; import { SESSIONS_VERSIONS } from '../../../../../src/certification/shared/domain/models/SessionVersion.js'; -import { Assessment } from '../../../../../src/shared/domain/models/Assessment.js'; +import { Assessment } from '../../../../../src/shared/domain/models/index.js'; import { createServer, databaseBuilder, @@ -39,13 +39,13 @@ describe('Certification | Results | Acceptance | Application | Certification', f { id: 'recSkillId1', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD1' }, + { id: 'rec0gm0GFue3PQB3k1' }, + { id: 'rec0hoSlSwCeNNLkq1' }, + { id: 'rec2FcZ4jsPuY1QYt1' }, + { id: 'rec39bDMnaVw3MyMR1' }, + { id: 'rec3FMoD8h9USTktb1' }, + { id: 'rec3P7fvPSpFkIFLV1' }, ], }, ], @@ -63,13 +63,13 @@ describe('Certification | Results | Acceptance | Application | Certification', f { id: 'recSkillId2', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD2' }, + { id: 'rec0gm0GFue3PQB3k2' }, + { id: 'rec0hoSlSwCeNNLkq2' }, + { id: 'rec2FcZ4jsPuY1QYt2' }, + { id: 'rec39bDMnaVw3MyMR2' }, + { id: 'rec3FMoD8h9USTktb2' }, + { id: 'rec3P7fvPSpFkIFLV2' }, ], }, ], @@ -87,13 +87,13 @@ describe('Certification | Results | Acceptance | Application | Certification', f { id: 'recSkillId3', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD3' }, + { id: 'rec0gm0GFue3PQB3k3' }, + { id: 'rec0hoSlSwCeNNLkq3' }, + { id: 'rec2FcZ4jsPuY1QYt3' }, + { id: 'rec39bDMnaVw3MyMR3' }, + { id: 'rec3FMoD8h9USTktb3' }, + { id: 'rec3P7fvPSpFkIFLV3' }, ], }, ], @@ -105,7 +105,7 @@ describe('Certification | Results | Acceptance | Application | Certification', f ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); ({ userId, session, badge, certificationCourse, assessmentResult } = await _buildDatabaseForV2Certification()); databaseBuilder.factory.buildCompetenceMark({ @@ -292,13 +292,13 @@ describe('Certification | Results | Acceptance | Application | Certification', f { id: 'recSkillId1', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD1' }, + { id: 'rec0gm0GFue3PQB3k1' }, + { id: 'rec0hoSlSwCeNNLkq1' }, + { id: 'rec2FcZ4jsPuY1QYt1' }, + { id: 'rec39bDMnaVw3MyMR1' }, + { id: 'rec3FMoD8h9USTktb1' }, + { id: 'rec3P7fvPSpFkIFLV1' }, ], }, ], @@ -316,13 +316,13 @@ describe('Certification | Results | Acceptance | Application | Certification', f { id: 'recSkillId2', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD2' }, + { id: 'rec0gm0GFue3PQB3k2' }, + { id: 'rec0hoSlSwCeNNLkq2' }, + { id: 'rec2FcZ4jsPuY1QYt2' }, + { id: 'rec39bDMnaVw3MyMR2' }, + { id: 'rec3FMoD8h9USTktb2' }, + { id: 'rec3P7fvPSpFkIFLV2' }, ], }, ], @@ -340,13 +340,13 @@ describe('Certification | Results | Acceptance | Application | Certification', f { id: 'recSkillId3', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD3' }, + { id: 'rec0gm0GFue3PQB3k3' }, + { id: 'rec0hoSlSwCeNNLkq3' }, + { id: 'rec2FcZ4jsPuY1QYt3' }, + { id: 'rec39bDMnaVw3MyMR3' }, + { id: 'rec3FMoD8h9USTktb3' }, + { id: 'rec3P7fvPSpFkIFLV3' }, ], }, ], @@ -358,7 +358,7 @@ describe('Certification | Results | Acceptance | Application | Certification', f ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); context('when certification is v2', function () { @@ -526,13 +526,13 @@ describe('Certification | Results | Acceptance | Application | Certification', f { id: 'recSkillId1', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD1' }, + { id: 'rec0gm0GFue3PQB3k1' }, + { id: 'rec0hoSlSwCeNNLkq1' }, + { id: 'rec2FcZ4jsPuY1QYt1' }, + { id: 'rec39bDMnaVw3MyMR1' }, + { id: 'rec3FMoD8h9USTktb1' }, + { id: 'rec3P7fvPSpFkIFLV1' }, ], }, ], @@ -550,13 +550,13 @@ describe('Certification | Results | Acceptance | Application | Certification', f { id: 'recSkillId2', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD2' }, + { id: 'rec0gm0GFue3PQB3k2' }, + { id: 'rec0hoSlSwCeNNLkq2' }, + { id: 'rec2FcZ4jsPuY1QYt2' }, + { id: 'rec39bDMnaVw3MyMR2' }, + { id: 'rec3FMoD8h9USTktb2' }, + { id: 'rec3P7fvPSpFkIFLV2' }, ], }, ], @@ -574,13 +574,13 @@ describe('Certification | Results | Acceptance | Application | Certification', f { id: 'recSkillId3', challenges: [ - 'rec02tVrimXNkgaLD', - 'rec0gm0GFue3PQB3k', - 'rec0hoSlSwCeNNLkq', - 'rec2FcZ4jsPuY1QYt', - 'rec39bDMnaVw3MyMR', - 'rec3FMoD8h9USTktb', - 'rec3P7fvPSpFkIFLV', + { id: 'rec02tVrimXNkgaLD3' }, + { id: 'rec0gm0GFue3PQB3k3' }, + { id: 'rec0hoSlSwCeNNLkq3' }, + { id: 'rec2FcZ4jsPuY1QYt3' }, + { id: 'rec39bDMnaVw3MyMR3' }, + { id: 'rec3FMoD8h9USTktb3' }, + { id: 'rec3P7fvPSpFkIFLV3' }, ], }, ], @@ -592,7 +592,7 @@ describe('Certification | Results | Acceptance | Application | Certification', f ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); ({ session, badge, certificationCourse, assessmentResult } = await _buildDatabaseForV2Certification()); databaseBuilder.factory.buildCompetenceMark({ diff --git a/api/tests/certification/results/integration/infrastructure/repositories/certificate-repository_test.js b/api/tests/certification/results/integration/infrastructure/repositories/certificate-repository_test.js index 9e66b1d1aa5..b8d846ac5ac 100644 --- a/api/tests/certification/results/integration/infrastructure/repositories/certificate-repository_test.js +++ b/api/tests/certification/results/integration/infrastructure/repositories/certificate-repository_test.js @@ -192,7 +192,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should return a CertificationAttestation', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const certificationAttestationData = { id: 123, @@ -306,7 +306,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( }); const learningContentObjects = learningContentBuilder.fromAreas([{ ...area1, title_i18n: { fr: area1.title } }]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const certificationAttestation = await certificateRepository.getCertificationAttestation({ @@ -325,7 +325,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should take into account the latest validated assessment result of a student', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const certificationAttestationData = { id: 123, firstName: 'Sarah Michelle', @@ -370,7 +370,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it(`should get the certified badge images when the certifications were acquired`, async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const certificationAttestationData = { id: 123, firstName: 'Sarah Michelle', @@ -487,7 +487,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should return an empty array when there are no certification attestations for given organization', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SCO', isManagingStudents: true }); databaseBuilder.factory.buildOrganization({ id: 456, type: 'SCO', isManagingStudents: true }); const certificationAttestationData = { @@ -535,7 +535,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should return an empty array when the organization is not SCO IS MANAGING STUDENTS', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SUP', isManagingStudents: false }); const certificationAttestationData = { id: 123, @@ -582,7 +582,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should return an empty array when the certification does not belong to an organization learner in the right division', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SCO', isManagingStudents: true }); const certificationAttestationData = { id: 123, @@ -629,7 +629,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should not return certifications that have no validated assessment-result', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SCO', isManagingStudents: true }); const certificationAttestationData = { id: 123, @@ -676,7 +676,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should not return cancelled certifications', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SCO', isManagingStudents: true }); const certificationAttestationData = { id: 123, @@ -723,7 +723,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should not return non published certifications', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SCO', isManagingStudents: true }); const certificationAttestationData = { id: 123, @@ -770,7 +770,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should return an array of certification attestations ordered by last name, first name', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SCO', isManagingStudents: true }); const certificationAttestationDataA = { id: 456, @@ -893,7 +893,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should ignore disabled shooling-registrations', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SCO', isManagingStudents: true }); const certificationAttestationDataA = { id: 456, @@ -1014,7 +1014,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should take into account the latest valid certification', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SCO', isManagingStudents: true }); const certificationAttestationData = { id: 123, @@ -1100,7 +1100,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should take into account the latest certification of an organization learner', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildOrganization({ id: 123, type: 'SCO', isManagingStudents: true }); const organizationLearnerId = databaseBuilder.factory.buildOrganizationLearner({ organizationId: 123, @@ -1716,7 +1716,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should return a PrivateCertificate', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const userId = databaseBuilder.factory.buildUser().id; const privateCertificateData = { @@ -1754,7 +1754,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( it('should return a PrivateCertificate with matching key', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const userId = databaseBuilder.factory.buildUser().id; const privateCertificateData = { @@ -1877,7 +1877,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( ], }, ]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const privateCertificate = await certificateRepository.getPrivateCertificate(certificationCourseId, { @@ -1988,7 +1988,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( ], }, ]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const privateCertificate = await certificateRepository.getPrivateCertificate(certificationCourseId, { @@ -2036,7 +2036,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( }).id; const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const userId = databaseBuilder.factory.buildUser().id; const privateCertificateData = { @@ -2426,7 +2426,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( ], }, ]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const shareableCertificate = await certificateRepository.getShareableCertificateByVerificationCode( @@ -2539,7 +2539,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( ], }, ]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const shareableCertificate = await certificateRepository.getShareableCertificateByVerificationCode( @@ -2590,7 +2590,7 @@ describe('Integration | Infrastructure | Repository | Certification', function ( }).id; const learningContentObjects = learningContentBuilder.fromAreas(minimalLearningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const userId = databaseBuilder.factory.buildUser().id; const shareableCertificateData = { id: 123, diff --git a/api/tests/certification/scoring/acceptance/application/scoring-and-capacity-simulator-route_test.js b/api/tests/certification/scoring/acceptance/application/scoring-and-capacity-simulator-route_test.js index 3542eb91268..aa7e96441b8 100644 --- a/api/tests/certification/scoring/acceptance/application/scoring-and-capacity-simulator-route_test.js +++ b/api/tests/certification/scoring/acceptance/application/scoring-and-capacity-simulator-route_test.js @@ -250,7 +250,7 @@ describe('Acceptance | Application | scoring-and-capacity-simulator-route', func index: '2.2', tubes: [ { - id: 'recTube4_0', + id: 'recTube5_0', skills: [ { id: 'recSkill5_0', @@ -266,7 +266,7 @@ describe('Acceptance | Application | scoring-and-capacity-simulator-route', func index: '2.3', tubes: [ { - id: 'recTube4_0', + id: 'recTube6_0', skills: [ { id: 'recSkill6_0', @@ -374,7 +374,7 @@ describe('Acceptance | Application | scoring-and-capacity-simulator-route', func index: '4.1', tubes: [ { - id: 'recTube4_0', + id: 'recTube12_0', skills: [ { id: 'recSkill12_0', @@ -459,7 +459,7 @@ describe('Acceptance | Application | scoring-and-capacity-simulator-route', func }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const superAdmin = databaseBuilder.factory.buildUser.withRole({ role: PIX_ADMIN.ROLES.SUPER_ADMIN, diff --git a/api/tests/certification/session-management/acceptance/application/certification-candidate-route_test.js b/api/tests/certification/session-management/acceptance/application/certification-candidate-route_test.js index 8149b118096..e91b47140cb 100644 --- a/api/tests/certification/session-management/acceptance/application/certification-candidate-route_test.js +++ b/api/tests/certification/session-management/acceptance/application/certification-candidate-route_test.js @@ -149,7 +149,7 @@ describe('Certification | Session Management | Acceptance | Application | Routes const certificationChallenge = databaseBuilder.factory.buildCertificationChallenge({ courseId: certificationCourseId, }); - mockLearningContent({ + await mockLearningContent({ frameworks: [{ id: 'frameworkId' }], challenges: [ { diff --git a/api/tests/certification/session-management/acceptance/application/certification-details-route_test.js b/api/tests/certification/session-management/acceptance/application/certification-details-route_test.js index 07d37fbd655..9a15eaf94f8 100644 --- a/api/tests/certification/session-management/acceptance/application/certification-details-route_test.js +++ b/api/tests/certification/session-management/acceptance/application/certification-details-route_test.js @@ -52,7 +52,7 @@ describe('Certification | Session Management | Acceptance | Application | Routes ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const sessionId = databaseBuilder.factory.buildSession().id; const userId = databaseBuilder.factory.buildUser().id; 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 2911ceab8a0..89e5bbd0780 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 @@ -723,7 +723,7 @@ const _createSession = async ({ version = 2 } = {}) => { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); return { session, diff --git a/api/tests/certification/shared/fixtures/certification-course.js b/api/tests/certification/shared/fixtures/certification-course.js index 5f7a35f8bc2..d3e1841b757 100644 --- a/api/tests/certification/shared/fixtures/certification-course.js +++ b/api/tests/certification/shared/fixtures/certification-course.js @@ -1,7 +1,7 @@ import { AnswerStatus } from '../../../../src/shared/domain/models/AnswerStatus.js'; import { Assessment } from '../../../../src/shared/domain/models/Assessment.js'; import { KnowledgeElement } from '../../../../src/shared/domain/models/index.js'; -import { databaseBuilder, domainBuilder, mockLearningContent } from '../../../test-helper.js'; +import { databaseBuilder, domainBuilder } from '../../../test-helper.js'; import { buildArea, buildChallenge, @@ -73,7 +73,7 @@ const createLearningContent = () => { area.competences = [competence]; framework.areas = [area]; const learningContent = buildLearningContent([framework]); - mockLearningContent(learningContent); + databaseBuilder.factory.learningContent.build(learningContent); return { challenges: [challenge1], diff --git a/api/tests/certification/shared/integration/domain/services/certification-badges-service_test.js b/api/tests/certification/shared/integration/domain/services/certification-badges-service_test.js index e64e6e4491e..8f2d239f41b 100644 --- a/api/tests/certification/shared/integration/domain/services/certification-badges-service_test.js +++ b/api/tests/certification/shared/integration/domain/services/certification-badges-service_test.js @@ -98,7 +98,7 @@ describe('Integration | Service | Certification-Badges Service', function () { }); await databaseBuilder.commit(); const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const badgeAcquisitions = await DomainTransaction.execute(async () => { @@ -160,7 +160,7 @@ describe('Integration | Service | Certification-Badges Service', function () { }); await databaseBuilder.commit(); const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const badgeAcquisitions = await DomainTransaction.execute(async () => { @@ -222,7 +222,7 @@ describe('Integration | Service | Certification-Badges Service', function () { }); await databaseBuilder.commit(); const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const badgeAcquisitions = await DomainTransaction.execute(async () => { diff --git a/api/tests/certification/shared/integration/infrastructure/repositories/certification-assessment-repository_test.js b/api/tests/certification/shared/integration/infrastructure/repositories/certification-assessment-repository_test.js index 867ecfcd026..b23098bd9dd 100644 --- a/api/tests/certification/shared/integration/infrastructure/repositories/certification-assessment-repository_test.js +++ b/api/tests/certification/shared/integration/infrastructure/repositories/certification-assessment-repository_test.js @@ -10,7 +10,7 @@ import { Challenge } from '../../../../../../src/shared/domain/models/Challenge. import { catchErr, databaseBuilder, expect, mockLearningContent } from '../../../../../test-helper.js'; describe('Integration | Infrastructure | Repositories | certification-assessment-repository', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = { areas: [ { @@ -83,7 +83,7 @@ describe('Integration | Infrastructure | Repositories | certification-assessment }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); describe('#get', function () { diff --git a/api/tests/certification/shared/integration/infrastructure/repositories/scoring-configuration-repository_test.js b/api/tests/certification/shared/integration/infrastructure/repositories/scoring-configuration-repository_test.js index cffd566c2fb..de8ac307477 100644 --- a/api/tests/certification/shared/integration/infrastructure/repositories/scoring-configuration-repository_test.js +++ b/api/tests/certification/shared/integration/infrastructure/repositories/scoring-configuration-repository_test.js @@ -65,7 +65,7 @@ describe('Integration | Repository | scoring-configuration-repository', function const framework = buildFramework({ id: frameworkId, name: 'someFramework', areas }); const learningContent = buildLearningContent([framework]); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); databaseBuilder.factory.buildCompetenceScoringConfiguration({ configuration: competenceScoringConfiguration, diff --git a/api/tests/devcomp/acceptance/application/trainings/training-controller_test.js b/api/tests/devcomp/acceptance/application/trainings/training-controller_test.js index 5e21523deb8..40abcc63822 100644 --- a/api/tests/devcomp/acceptance/application/trainings/training-controller_test.js +++ b/api/tests/devcomp/acceptance/application/trainings/training-controller_test.js @@ -67,7 +67,7 @@ describe('Acceptance | Controller | training-controller', function () { ]; const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should get a training with the specific id', async function () { @@ -374,7 +374,7 @@ describe('Acceptance | Controller | training-controller', function () { ]; const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should update training trigger', async function () { diff --git a/api/tests/devcomp/acceptance/application/tutorial-evaulations/tutorial-evaluations-controller_test.js b/api/tests/devcomp/acceptance/application/tutorial-evaulations/tutorial-evaluations-controller_test.js index 89d994709b8..7296c3681dd 100644 --- a/api/tests/devcomp/acceptance/application/tutorial-evaulations/tutorial-evaluations-controller_test.js +++ b/api/tests/devcomp/acceptance/application/tutorial-evaulations/tutorial-evaluations-controller_test.js @@ -35,7 +35,7 @@ describe('Acceptance | Controller | tutorial-evaluations-controller', function ( }); await databaseBuilder.commit(); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); describe('PUT /api/users/tutorials/{tutorialId}/evaluate', function () { diff --git a/api/tests/devcomp/acceptance/application/user-tutorials/user-tutorials-controller_test.js b/api/tests/devcomp/acceptance/application/user-tutorials/user-tutorials-controller_test.js index f90ab1263b1..4cb69aa9857 100644 --- a/api/tests/devcomp/acceptance/application/user-tutorials/user-tutorials-controller_test.js +++ b/api/tests/devcomp/acceptance/application/user-tutorials/user-tutorials-controller_test.js @@ -48,7 +48,7 @@ describe('Acceptance | Controller | user-tutorial-controller', function () { ], }; - beforeEach(function () { + beforeEach(async function () { options = { method: 'PUT', url: '/api/users/tutorials/tutorialId', @@ -57,7 +57,7 @@ describe('Acceptance | Controller | user-tutorial-controller', function () { }, }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); describe('nominal case', function () { @@ -278,7 +278,7 @@ describe('Acceptance | Controller | user-tutorial-controller', function () { describe('nominal case', function () { it('should respond with a 200 and return tutorials saved for user', async function () { // given - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildUserSavedTutorial({ id: 101, @@ -333,7 +333,7 @@ describe('Acceptance | Controller | user-tutorial-controller', function () { it('should respond with a 200 and return tutorials recommended for user', async function () { // given - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildKnowledgeElement({ userId, @@ -468,7 +468,7 @@ describe('Acceptance | Controller | user-tutorial-controller', function () { ], }; - beforeEach(function () { + beforeEach(async function () { options = { method: 'DELETE', url: '/api/users/tutorials/tutorialId', @@ -477,7 +477,7 @@ describe('Acceptance | Controller | user-tutorial-controller', function () { }, }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); describe('nominal case', function () { diff --git a/api/tests/devcomp/integration/infrastructure/datasources/tutorial-datasource_test.js b/api/tests/devcomp/integration/infrastructure/datasources/tutorial-datasource_test.js index d4169ca88e1..cd861955186 100644 --- a/api/tests/devcomp/integration/infrastructure/datasources/tutorial-datasource_test.js +++ b/api/tests/devcomp/integration/infrastructure/datasources/tutorial-datasource_test.js @@ -11,7 +11,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Tutoria const rawTutorial2 = { id: 'FAKE_REC_ID_RAW_TUTORIAL_2' }; const rawTutorial3 = { id: 'FAKE_REC_ID_RAW_TUTORIAL_3' }; const records = [rawTutorial1, rawTutorial2, rawTutorial3]; - const lcmsApiCall = mockLearningContent({ tutorials: records }); + const lcmsApiCall = await mockLearningContent({ tutorials: records }); // when const foundTutorials = await tutorialDatasource.findByRecordIds([rawTutorial1.id, rawTutorial3.id]); diff --git a/api/tests/devcomp/integration/infrastructure/repositories/training-repository_test.js b/api/tests/devcomp/integration/infrastructure/repositories/training-repository_test.js index b27f1d5f710..2a3dbcede60 100644 --- a/api/tests/devcomp/integration/infrastructure/repositories/training-repository_test.js +++ b/api/tests/devcomp/integration/infrastructure/repositories/training-repository_test.js @@ -114,7 +114,7 @@ describe('Integration | Repository | training-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should throw an error when training does not exist', async function () { @@ -396,7 +396,7 @@ describe('Integration | Repository | training-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should find trainings by campaignParticipationId and locale', async function () { diff --git a/api/tests/devcomp/integration/infrastructure/repositories/training-trigger-repository_test.js b/api/tests/devcomp/integration/infrastructure/repositories/training-trigger-repository_test.js index 9d8756c8059..880dfb14fc6 100644 --- a/api/tests/devcomp/integration/infrastructure/repositories/training-trigger-repository_test.js +++ b/api/tests/devcomp/integration/infrastructure/repositories/training-trigger-repository_test.js @@ -102,7 +102,7 @@ describe('Integration | Repository | training-trigger-repository', function () { }, ]; const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); describe('#createOrUpdate', function () { diff --git a/api/tests/devcomp/integration/infrastructure/repositories/tutorial-repository_test.js b/api/tests/devcomp/integration/infrastructure/repositories/tutorial-repository_test.js index b7c07ac993d..6094220b02e 100644 --- a/api/tests/devcomp/integration/infrastructure/repositories/tutorial-repository_test.js +++ b/api/tests/devcomp/integration/infrastructure/repositories/tutorial-repository_test.js @@ -40,7 +40,7 @@ describe('Integration | Repository | tutorial-repository', function () { }, ]; const learningContent = { tutorials: tutorialsList }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const tutorials = await tutorialRepository.findByRecordIdsForCurrentUser({ @@ -69,7 +69,7 @@ describe('Integration | Repository | tutorial-repository', function () { id: 'recTutorial0', }; const learningContent = { tutorials: [tutorial] }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const tutorials = await tutorialRepository.findByRecordIdsForCurrentUser({ ids: ['recTutorial0'], userId }); @@ -96,7 +96,7 @@ describe('Integration | Repository | tutorial-repository', function () { id: 'recTutorial0', }; const learningContent = { tutorials: [tutorial] }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const tutorials = await tutorialRepository.findByRecordIdsForCurrentUser({ ids: ['recTutorial0'], userId }); @@ -122,7 +122,7 @@ describe('Integration | Repository | tutorial-repository', function () { const learningContent = { tutorials: [{ id: tutorialId1 }, { id: tutorialId2 }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const firstUserSavedTutorial = databaseBuilder.factory.buildUserSavedTutorial({ tutorialId: tutorialId1, @@ -163,7 +163,7 @@ describe('Integration | Repository | tutorial-repository', function () { const learningContent = { tutorials: [{ id: tutorialId }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); databaseBuilder.factory.buildUserSavedTutorial({ tutorialId, userId }); databaseBuilder.factory.buildTutorialEvaluation({ tutorialId, userId }); @@ -209,7 +209,7 @@ describe('Integration | Repository | tutorial-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); databaseBuilder.factory.buildUserSavedTutorial({ tutorialId: tutorialId1, @@ -246,7 +246,7 @@ describe('Integration | Repository | tutorial-repository', function () { context('when user has not saved tutorial', function () { it('should return an empty list', async function () { - mockLearningContent({ tutorials: [] }); + await mockLearningContent({ tutorials: [] }); const { models: tutorialsForUser } = await tutorialRepository.findPaginatedFilteredForCurrentUser({ userId, @@ -259,7 +259,7 @@ describe('Integration | Repository | tutorial-repository', function () { context('when user has saved a tutorial which is not available anymore', function () { it('should return an empty list', async function () { - mockLearningContent({ tutorials: [] }); + await mockLearningContent({ tutorials: [] }); databaseBuilder.factory.buildUserSavedTutorial({ tutorialId: 'recTutorial', userId }); await databaseBuilder.commit(); @@ -277,7 +277,7 @@ describe('Integration | Repository | tutorial-repository', function () { tutorials: [{ id: 'tuto1' }, { id: 'tuto2' }, { id: 'tuto3' }, { id: 'tuto4' }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); databaseBuilder.factory.buildUserSavedTutorial({ tutorialId: 'tuto1', @@ -330,7 +330,7 @@ describe('Integration | Repository | tutorial-repository', function () { domainBuilder.buildTutorial({ id: 'tutorialain' }), domainBuilder.buildTutorial({ id: 'tutorialadin' }), ]; - mockLearningContent({ tutorials }); + await mockLearningContent({ tutorials }); tutorials.forEach((tutorial) => databaseBuilder.factory.buildUserSavedTutorial({ userId, tutorialId: tutorial.id }), ); @@ -376,7 +376,7 @@ describe('Integration | Repository | tutorial-repository', function () { }, ]; const learningContent = { tutorials: tutorials }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const tutorial = await tutorialRepository.get({ tutorialId: 'recTutorial0' }); @@ -422,7 +422,7 @@ describe('Integration | Repository | tutorial-repository', function () { }, ]; const learningContent = { tutorials: [...frenchTutorials, ...englishTutorials] }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const tutorials = await tutorialRepository.list({}); @@ -456,7 +456,7 @@ describe('Integration | Repository | tutorial-repository', function () { locale: 'en-us', }; const learningContent = { tutorials: [frenchTutorial, englishTutorial] }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const tutorials = await tutorialRepository.list({ locale }); @@ -479,7 +479,7 @@ describe('Integration | Repository | tutorial-repository', function () { id: 'recTutorial0', }; const learningContent = { tutorials: [tutorial] }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const tutorials = await tutorialRepository.list({ locale }); @@ -500,7 +500,7 @@ describe('Integration | Repository | tutorial-repository', function () { describe('when there are no invalidated and direct KE', function () { it('should return an empty page', async function () { // given - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto1', @@ -538,7 +538,7 @@ describe('Integration | Repository | tutorial-repository', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto1', @@ -581,7 +581,7 @@ describe('Integration | Repository | tutorial-repository', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto1', @@ -646,7 +646,7 @@ describe('Integration | Repository | tutorial-repository', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto1', @@ -693,7 +693,7 @@ describe('Integration | Repository | tutorial-repository', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto4', @@ -732,7 +732,7 @@ describe('Integration | Repository | tutorial-repository', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto1', @@ -791,7 +791,7 @@ describe('Integration | Repository | tutorial-repository', function () { }).id; await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto4', @@ -838,7 +838,7 @@ describe('Integration | Repository | tutorial-repository', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto4', @@ -907,7 +907,7 @@ describe('Integration | Repository | tutorial-repository', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto1', @@ -1009,7 +1009,7 @@ describe('Integration | Repository | tutorial-repository', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ tutorials: [ { id: 'tuto1', diff --git a/api/tests/evaluation/acceptance/application/answers/answer-controller-get-correction_test.js b/api/tests/evaluation/acceptance/application/answers/answer-controller-get-correction_test.js index 6d43924c4af..c9e625614c7 100644 --- a/api/tests/evaluation/acceptance/application/answers/answer-controller-get-correction_test.js +++ b/api/tests/evaluation/acceptance/application/answers/answer-controller-get-correction_test.js @@ -188,7 +188,7 @@ describe('Acceptance | Controller | answer-controller-get-correction', function tutorialId: 'french-tutorial-id', }); await databaseBuilder.commit(); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); context('when Accept-Language header is specified', function () { diff --git a/api/tests/evaluation/acceptance/application/answers/answer-controller-save_test.js b/api/tests/evaluation/acceptance/application/answers/answer-controller-save_test.js index 00303dcd5b2..87249ef2ff0 100644 --- a/api/tests/evaluation/acceptance/application/answers/answer-controller-save_test.js +++ b/api/tests/evaluation/acceptance/application/answers/answer-controller-save_test.js @@ -77,7 +77,7 @@ describe('Acceptance | Controller | answer-controller-save', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); postAnswersOptions = { method: 'POST', @@ -259,7 +259,7 @@ describe('Acceptance | Controller | answer-controller-save', function () { }); context('when the answer is empty and has timed out', function () { - beforeEach(function () { + beforeEach(async function () { // given const learningContent = { areas: [{ id: 'recArea1', competenceIds: ['recCompetence'] }], @@ -292,7 +292,7 @@ describe('Acceptance | Controller | answer-controller-save', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); postAnswersOptions = { method: 'POST', @@ -337,7 +337,7 @@ describe('Acceptance | Controller | answer-controller-save', function () { }); context('when the answer is empty but not in timeout', function () { - beforeEach(function () { + beforeEach(async function () { // given const learningContent = { areas: [{ id: 'recArea1', competenceIds: ['recCompetence'] }], @@ -370,7 +370,7 @@ describe('Acceptance | Controller | answer-controller-save', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); postAnswersOptions = { method: 'POST', diff --git a/api/tests/evaluation/acceptance/application/autonomous-courses/autonomous-course-controller_test.js b/api/tests/evaluation/acceptance/application/autonomous-courses/autonomous-course-controller_test.js index 4351aeecfde..95d3ce4c4ef 100644 --- a/api/tests/evaluation/acceptance/application/autonomous-courses/autonomous-course-controller_test.js +++ b/api/tests/evaluation/acceptance/application/autonomous-courses/autonomous-course-controller_test.js @@ -43,7 +43,7 @@ describe('Acceptance | API | Autonomous Course', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); describe('POST /api/autonomous-course', function () { diff --git a/api/tests/evaluation/acceptance/application/competence-evaluations/competence-evaluation-controller_test.js b/api/tests/evaluation/acceptance/application/competence-evaluations/competence-evaluation-controller_test.js index 19f25e53791..a2de4081900 100644 --- a/api/tests/evaluation/acceptance/application/competence-evaluations/competence-evaluation-controller_test.js +++ b/api/tests/evaluation/acceptance/application/competence-evaluations/competence-evaluation-controller_test.js @@ -37,7 +37,7 @@ describe('Acceptance | API | Competence Evaluations', function () { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); context('and competence exists', function () { diff --git a/api/tests/evaluation/acceptance/application/progressions/progression-controller_test.js b/api/tests/evaluation/acceptance/application/progressions/progression-controller_test.js index 8542e45746e..541d4a363fc 100644 --- a/api/tests/evaluation/acceptance/application/progressions/progression-controller_test.js +++ b/api/tests/evaluation/acceptance/application/progressions/progression-controller_test.js @@ -42,7 +42,7 @@ describe('Acceptance | API | Progressions', function () { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); userId = databaseBuilder.factory.buildUser({}).id; const campaignId = databaseBuilder.factory.buildCampaign({ name: 'Campaign' }).id; diff --git a/api/tests/evaluation/acceptance/application/scorecards/scorecard-controller_test.js b/api/tests/evaluation/acceptance/application/scorecards/scorecard-controller_test.js index e43c7161878..cb03b1da9ba 100644 --- a/api/tests/evaluation/acceptance/application/scorecards/scorecard-controller_test.js +++ b/api/tests/evaluation/acceptance/application/scorecards/scorecard-controller_test.js @@ -103,7 +103,7 @@ describe('Acceptance | Controller | scorecard-controller', function () { server = await createServer(); databaseBuilder.factory.buildUser({ id: userId }); await databaseBuilder.commit(); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); describe('GET /scorecards/{id}', function () { diff --git a/api/tests/evaluation/acceptance/application/stage-collections/stage-collection-controller_test.js b/api/tests/evaluation/acceptance/application/stage-collections/stage-collection-controller_test.js index e21d1899a1f..f6442918c2c 100644 --- a/api/tests/evaluation/acceptance/application/stage-collections/stage-collection-controller_test.js +++ b/api/tests/evaluation/acceptance/application/stage-collections/stage-collection-controller_test.js @@ -15,10 +15,10 @@ describe('Acceptance | Controller | stage-collection', function () { }); describe('PATCH api/admin/stage-collections/{id}', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = [{ id: 'recArea0', competences: [] }]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); context('when the target-profile is not linked to a campaign', function () { diff --git a/api/tests/evaluation/acceptance/application/stages/stage-controller_test.js b/api/tests/evaluation/acceptance/application/stages/stage-controller_test.js index 7b4a5b0b805..eee4cc926dd 100644 --- a/api/tests/evaluation/acceptance/application/stages/stage-controller_test.js +++ b/api/tests/evaluation/acceptance/application/stages/stage-controller_test.js @@ -29,7 +29,7 @@ describe('Acceptance | API | Stages', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); describe('PATCH /api/admin/stages/{id}', function () { diff --git a/api/tests/evaluation/integration/application/smart-random-simulator/smart-random-simulator-controller_test.js b/api/tests/evaluation/integration/application/smart-random-simulator/smart-random-simulator-controller_test.js index 5d8350f0519..8342ea87a7d 100644 --- a/api/tests/evaluation/integration/application/smart-random-simulator/smart-random-simulator-controller_test.js +++ b/api/tests/evaluation/integration/application/smart-random-simulator/smart-random-simulator-controller_test.js @@ -48,14 +48,14 @@ const request = { describe('Integration | Application | Smart Random Simulator', function () { context('#getNextChallenge', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = { areas: [], competences: [], thematics: [], tubes: [{ id: 'tubeId1' }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should empty smart random log after execution', async function () { diff --git a/api/tests/evaluation/integration/application/stage-collections/stage-collection-controller_test.js b/api/tests/evaluation/integration/application/stage-collections/stage-collection-controller_test.js index 59de11c3d8f..133a8832221 100644 --- a/api/tests/evaluation/integration/application/stage-collections/stage-collection-controller_test.js +++ b/api/tests/evaluation/integration/application/stage-collections/stage-collection-controller_test.js @@ -4,14 +4,14 @@ import { databaseBuilder, expect, hFake, mockLearningContent } from '../../../.. describe('Integration | Application | stage-collection-controller', function () { context('update', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = { areas: [], competences: [], thematics: [], tubes: [{ id: 'tubeId1' }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should modify stage collection according to the request', async function () { diff --git a/api/tests/evaluation/integration/domain/usecases/create-badge_test.js b/api/tests/evaluation/integration/domain/usecases/create-badge_test.js index ae674e7bcbf..64f6f0f4a99 100644 --- a/api/tests/evaluation/integration/domain/usecases/create-badge_test.js +++ b/api/tests/evaluation/integration/domain/usecases/create-badge_test.js @@ -24,7 +24,7 @@ describe('Integration | UseCases | create-badge', function () { skills: [{ id: 'recSkill1' }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); targetProfileId = databaseBuilder.factory.buildTargetProfile().id; databaseBuilder.factory.buildTargetProfileTube({ tubeId: 'monTubeA', level: 2, targetProfileId }); diff --git a/api/tests/evaluation/integration/domain/usecases/get-campaign-parameters-for-simulator_test.js b/api/tests/evaluation/integration/domain/usecases/get-campaign-parameters-for-simulator_test.js index 585e1eb2fd6..c1d173b3836 100644 --- a/api/tests/evaluation/integration/domain/usecases/get-campaign-parameters-for-simulator_test.js +++ b/api/tests/evaluation/integration/domain/usecases/get-campaign-parameters-for-simulator_test.js @@ -1,17 +1,11 @@ import { evaluationUsecases } from '../../../../../src/evaluation/domain/usecases/index.js'; import { NotFoundError } from '../../../../../src/shared/domain/errors.js'; -import { - databaseBuilder, - domainBuilder, - expect, - learningContentBuilder, - mockLearningContent, -} from '../../../../test-helper.js'; +import { databaseBuilder, domainBuilder, expect, learningContentBuilder } from '../../../../test-helper.js'; function buildLearningContent() { const learningContent = domainBuilder.buildCampaignLearningContent.withSimpleContent(); const learningContentObjects = learningContentBuilder([learningContent]); - mockLearningContent(learningContentObjects); + databaseBuilder.factory.learningContent.build(learningContentObjects); } describe('Integration | Domain | UseCases | get-campaign-parameters-for-simulator', function () { @@ -33,9 +27,9 @@ describe('Integration | Domain | UseCases | get-campaign-parameters-for-simulato databaseBuilder.factory.buildCampaign({ id: campaignId }); databaseBuilder.factory.buildCampaignSkill({ campaignId, skillId: 'skillId' }); + buildLearningContent(); await databaseBuilder.commit(); - buildLearningContent(); // when const result = await evaluationUsecases.getCampaignParametersForSimulator({ diff --git a/api/tests/evaluation/integration/domain/usecases/save-autonomous-course_test.js b/api/tests/evaluation/integration/domain/usecases/save-autonomous-course_test.js index 033a4510a80..14b6650798b 100644 --- a/api/tests/evaluation/integration/domain/usecases/save-autonomous-course_test.js +++ b/api/tests/evaluation/integration/domain/usecases/save-autonomous-course_test.js @@ -26,7 +26,7 @@ describe('Integration | Usecases | Save autonomous course', function () { const learningContent = domainBuilder.buildCampaignLearningContent.withSimpleContent(); const learningContentObjects = learningContentBuilder([learningContent]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); context('when target-profile does not exist', function () { diff --git a/api/tests/evaluation/integration/domain/usecases/update-badge_test.js b/api/tests/evaluation/integration/domain/usecases/update-badge_test.js index 502cc73da61..b51309d6ca0 100644 --- a/api/tests/evaluation/integration/domain/usecases/update-badge_test.js +++ b/api/tests/evaluation/integration/domain/usecases/update-badge_test.js @@ -13,7 +13,7 @@ describe('Integration | UseCases | create-badge', function () { skills: [{ id: 'recSkill1' }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); targetProfileId = databaseBuilder.factory.buildTargetProfile().id; databaseBuilder.factory.buildTargetProfileTube({ tubeId: 'monTubeA', level: 2, targetProfileId }); diff --git a/api/tests/evaluation/integration/domain/usecases/update-stage_test.js b/api/tests/evaluation/integration/domain/usecases/update-stage_test.js index 8692fbd50aa..869d5f93a19 100644 --- a/api/tests/evaluation/integration/domain/usecases/update-stage_test.js +++ b/api/tests/evaluation/integration/domain/usecases/update-stage_test.js @@ -1,19 +1,12 @@ import { StageWithLinkedCampaignError } from '../../../../../src/evaluation/domain/errors.js'; import { Stage } from '../../../../../src/evaluation/domain/models/Stage.js'; import { evaluationUsecases } from '../../../../../src/evaluation/domain/usecases/index.js'; -import { - catchErr, - databaseBuilder, - domainBuilder, - expect, - learningContentBuilder, - mockLearningContent, -} from '../../../../test-helper.js'; +import { catchErr, databaseBuilder, domainBuilder, expect, learningContentBuilder } from '../../../../test-helper.js'; function _buildLearningContent() { const learningContent = domainBuilder.buildCampaignLearningContent.withSimpleContent(); const learningContentObjects = learningContentBuilder([learningContent]); - mockLearningContent(learningContentObjects); + databaseBuilder.factory.learningContent.build(learningContentObjects); } describe('Integration | Domain | UseCases | update-stage', function () { @@ -28,8 +21,8 @@ describe('Integration | Domain | UseCases | update-stage', function () { level: 1, }); - await databaseBuilder.commit(); _buildLearningContent(); + await databaseBuilder.commit(); const payload = { id: stage.id, @@ -70,9 +63,8 @@ describe('Integration | Domain | UseCases | update-stage', function () { threshold: null, }); - await databaseBuilder.commit(); - _buildLearningContent(); + await databaseBuilder.commit(); const payload = { id: stage.id, @@ -107,8 +99,8 @@ describe('Integration | Domain | UseCases | update-stage', function () { threshold: null, }); - await databaseBuilder.commit(); _buildLearningContent(); + await databaseBuilder.commit(); const payload = { id: stage.id, @@ -154,9 +146,8 @@ describe('Integration | Domain | UseCases | update-stage', function () { threshold: 10, }); - await databaseBuilder.commit(); - _buildLearningContent(); + await databaseBuilder.commit(); const payload = { id: stage.id, @@ -190,8 +181,8 @@ describe('Integration | Domain | UseCases | update-stage', function () { threshold: 10, }); - await databaseBuilder.commit(); _buildLearningContent(); + await databaseBuilder.commit(); const payload = { id: stage.id, diff --git a/api/tests/evaluation/integration/infrastructure/repositories/autonomous-course-repository_test.js b/api/tests/evaluation/integration/infrastructure/repositories/autonomous-course-repository_test.js index 0874b510bc8..39ed31af878 100644 --- a/api/tests/evaluation/integration/infrastructure/repositories/autonomous-course-repository_test.js +++ b/api/tests/evaluation/integration/infrastructure/repositories/autonomous-course-repository_test.js @@ -90,7 +90,7 @@ describe('Integration | Repository | Autonomous Course', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); sinon.stub(constants, 'AUTONOMOUS_COURSES_ORGANIZATION_ID').value(777); const { id: organizationId } = databaseBuilder.factory.buildOrganization({ id: constants.AUTONOMOUS_COURSES_ORGANIZATION_ID, diff --git a/api/tests/integration/domain/event/handle-complementary-certifications-scoring_test.js b/api/tests/integration/domain/event/handle-complementary-certifications-scoring_test.js index 828b0c2c508..94483aeee55 100644 --- a/api/tests/integration/domain/event/handle-complementary-certifications-scoring_test.js +++ b/api/tests/integration/domain/event/handle-complementary-certifications-scoring_test.js @@ -156,7 +156,7 @@ describe('Integration | Event | Handle Complementary Certifications Scoring', fu }); describe('when the lower level is acquired', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = { challenges: [ { @@ -174,7 +174,7 @@ describe('Integration | Event | Handle Complementary Certifications Scoring', fu ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should save a result', async function () { diff --git a/api/tests/integration/domain/services/certification-challenges-service_test.js b/api/tests/integration/domain/services/certification-challenges-service_test.js index 5b427dde959..4d42ce92b0d 100644 --- a/api/tests/integration/domain/services/certification-challenges-service_test.js +++ b/api/tests/integration/domain/services/certification-challenges-service_test.js @@ -72,7 +72,7 @@ describe('Integration | CertificationChallengeService | pickCertificationChallen ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await _buildCorrectAnswerAndKnowledgeElement({ userId: certifiableUserId, @@ -163,7 +163,7 @@ describe('Integration | CertificationChallengeService | pickCertificationChallen ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await _buildCorrectAnswerAndKnowledgeElement({ userId: certifiableUserId, @@ -265,7 +265,7 @@ describe('Integration | CertificationChallengeService | pickCertificationChallen ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await _buildCorrectAnswerAndKnowledgeElement({ userId: certifiableUserId, @@ -366,7 +366,7 @@ describe('Integration | CertificationChallengeService | pickCertificationChallen ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await _buildCorrectAnswerAndKnowledgeElement({ userId: certifiableUserId, @@ -457,7 +457,7 @@ describe('Integration | CertificationChallengeService | pickCertificationChallen ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await _buildCorrectAnswerAndKnowledgeElement({ userId: certifiableUserId, @@ -540,7 +540,7 @@ describe('Integration | CertificationChallengeService | pickCertificationChallen ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await _buildCorrectAnswerAndKnowledgeElement({ userId: certifiableUserId, @@ -673,7 +673,7 @@ describe('Integration | CertificationChallengeService | pickCertificationChallen ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await _buildCorrectAnswerAndKnowledgeElement({ userId: certifiableUserId, diff --git a/api/tests/integration/domain/usecases/handle-badge-acquisition_test.js b/api/tests/integration/domain/usecases/handle-badge-acquisition_test.js index e5003ba7279..13e4605e0e2 100644 --- a/api/tests/integration/domain/usecases/handle-badge-acquisition_test.js +++ b/api/tests/integration/domain/usecases/handle-badge-acquisition_test.js @@ -104,7 +104,7 @@ describe('Integration | Usecase | Handle Badge Acquisition', function () { }); const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); return databaseBuilder.commit(); }); diff --git a/api/tests/integration/domain/usecases/handle-stage-acquisition_test.js b/api/tests/integration/domain/usecases/handle-stage-acquisition_test.js index 3a7556f0937..b309bed8e9e 100644 --- a/api/tests/integration/domain/usecases/handle-stage-acquisition_test.js +++ b/api/tests/integration/domain/usecases/handle-stage-acquisition_test.js @@ -90,7 +90,7 @@ describe('Integration | Usecase | Handle Stage Acquisition', function () { type: Assessment.types.CAMPAIGN, }); - mockLearningContent(learningContentBuilder(learningContent)); + await mockLearningContent(learningContentBuilder(learningContent)); }); context('when some KEs are acquired', function () { diff --git a/api/tests/integration/domain/usecases/send-completed-participation-results-to-pole-emploi_test.js b/api/tests/integration/domain/usecases/send-completed-participation-results-to-pole-emploi_test.js index 64b5a261fec..e4c6e164e62 100644 --- a/api/tests/integration/domain/usecases/send-completed-participation-results-to-pole-emploi_test.js +++ b/api/tests/integration/domain/usecases/send-completed-participation-results-to-pole-emploi_test.js @@ -30,7 +30,7 @@ describe('Integration | Domain | UseCases | send-completed-participation-results campaignParticipationId = databaseBuilder.factory.buildCampaignParticipation({ campaignId, userId }).id; databaseBuilder.factory.buildAssessment({ campaignParticipationId, userId }); const learningContentObjects = learningContentBuilder.fromAreas([]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); return databaseBuilder.commit(); }); diff --git a/api/tests/integration/domain/usecases/send-shared-participation-results-to-pole-emploi_test.js b/api/tests/integration/domain/usecases/send-shared-participation-results-to-pole-emploi_test.js index 7ec8f217faf..07424add40e 100644 --- a/api/tests/integration/domain/usecases/send-shared-participation-results-to-pole-emploi_test.js +++ b/api/tests/integration/domain/usecases/send-shared-participation-results-to-pole-emploi_test.js @@ -30,7 +30,7 @@ describe('Integration | Domain | UseCases | send-shared-participation-results-to campaignParticipationId = databaseBuilder.factory.buildCampaignParticipation({ campaignId, userId }).id; databaseBuilder.factory.buildAssessment({ campaignParticipationId, userId }); const learningContentObjects = learningContentBuilder.fromAreas([]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); return databaseBuilder.commit(); }); diff --git a/api/tests/integration/domain/usecases/send-started-participation-results-to-pole-emploi_test.js b/api/tests/integration/domain/usecases/send-started-participation-results-to-pole-emploi_test.js index 3d603d273e2..82a53312c92 100644 --- a/api/tests/integration/domain/usecases/send-started-participation-results-to-pole-emploi_test.js +++ b/api/tests/integration/domain/usecases/send-started-participation-results-to-pole-emploi_test.js @@ -30,7 +30,7 @@ describe('Integration | Application | send-started-participation-results-to-pole campaignParticipationId = databaseBuilder.factory.buildCampaignParticipation({ campaignId, userId }).id; databaseBuilder.factory.buildAssessment({ campaignParticipationId, userId }); const learningContentObjects = learningContentBuilder.fromAreas([]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); return databaseBuilder.commit(); }); diff --git a/api/tests/integration/infrastructure/repositories/area-repository_test.js b/api/tests/integration/infrastructure/repositories/area-repository_test.js index 6a322744e36..7fc10615498 100644 --- a/api/tests/integration/infrastructure/repositories/area-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/area-repository_test.js @@ -34,8 +34,8 @@ describe('Integration | Repository | area-repository', function () { const learningContent = { areas: [area0, area1] }; - beforeEach(function () { - mockLearningContent(learningContent); + beforeEach(async function () { + await mockLearningContent(learningContent); }); it('should return all areas without fetching competences', async function () { @@ -109,8 +109,8 @@ describe('Integration | Repository | area-repository', function () { const learningContent = { areas: [area0, area1] }; - beforeEach(function () { - mockLearningContent(learningContent); + beforeEach(async function () { + await mockLearningContent(learningContent); }); it('should return the code area', async function () { @@ -142,8 +142,8 @@ describe('Integration | Repository | area-repository', function () { competences: [{ id: 'recCompetence0', origin: 'NotPix' }], }; - beforeEach(function () { - mockLearningContent(learningContent); + beforeEach(async function () { + await mockLearningContent(learningContent); }); it('should ignore the area', async function () { @@ -192,8 +192,8 @@ describe('Integration | Repository | area-repository', function () { ], }; - beforeEach(function () { - mockLearningContent(learningContent); + beforeEach(async function () { + await mockLearningContent(learningContent); }); it('should return the areas with only pix competences in it', async function () { @@ -308,8 +308,8 @@ describe('Integration | Repository | area-repository', function () { ], }; - beforeEach(function () { - mockLearningContent(learningContent); + beforeEach(async function () { + await mockLearningContent(learningContent); }); it('should return a list of areas from the proper framework', async function () { @@ -417,7 +417,7 @@ describe('Integration | Repository | area-repository', function () { frameworkId: 'recFwkId2', }; - mockLearningContent({ areas: [learningContentArea0, learningContentArea1, learningContentArea2] }); + await mockLearningContent({ areas: [learningContentArea0, learningContentArea1, learningContentArea2] }); // when const areas = await areaRepository.findByRecordIds({ areaIds: ['recArea1', 'recArea2'] }); @@ -481,7 +481,7 @@ describe('Integration | Repository | area-repository', function () { frameworkId: 'recFwkId2', }; - mockLearningContent({ areas: [learningContentArea0, learningContentArea1, learningContentArea2] }); + await mockLearningContent({ areas: [learningContentArea0, learningContentArea1, learningContentArea2] }); // when const areas = await areaRepository.findByRecordIds({ areaIds: ['recArea1', 'recArea2'], locale: 'en' }); @@ -492,7 +492,7 @@ describe('Integration | Repository | area-repository', function () { }); describe('#get', function () { - beforeEach(function () { + beforeEach(async function () { const learningContentArea0 = { id: 'recArea0', code: 1, @@ -515,7 +515,7 @@ describe('Integration | Repository | area-repository', function () { color: 'blue1', frameworkId: 'recFwkId1', }; - mockLearningContent({ areas: [learningContentArea0, learningContentArea1] }); + await mockLearningContent({ areas: [learningContentArea0, learningContentArea1] }); }); it('should return the area', async function () { @@ -545,7 +545,7 @@ describe('Integration | Repository | area-repository', function () { }); describe('#findByFrameworkId', function () { - beforeEach(function () { + beforeEach(async function () { const area0 = { id: 'recArea0', code: 'area0code', @@ -582,7 +582,7 @@ describe('Integration | Repository | area-repository', function () { const learningContent = { areas: [area0, area1, area2], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should return a list of areas from the proper framework', async function () { diff --git a/api/tests/integration/infrastructure/repositories/badge-for-calculation-repository_test.js b/api/tests/integration/infrastructure/repositories/badge-for-calculation-repository_test.js index ec9f56236d5..c7b7bc2f1e5 100644 --- a/api/tests/integration/infrastructure/repositories/badge-for-calculation-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/badge-for-calculation-repository_test.js @@ -1,12 +1,6 @@ import * as badgeForCalculationRepository from '../../../../lib/infrastructure/repositories/badge-for-calculation-repository.js'; import { SCOPES } from '../../../../src/shared/domain/models/BadgeDetails.js'; -import { - databaseBuilder, - domainBuilder, - expect, - learningContentBuilder, - mockLearningContent, -} from '../../../test-helper.js'; +import { databaseBuilder, domainBuilder, expect, learningContentBuilder } from '../../../test-helper.js'; describe('Integration | Repository | BadgeForCalculation', function () { const campaignSkillsId = [ @@ -101,7 +95,7 @@ describe('Integration | Repository | BadgeForCalculation', function () { }, ]; const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); + databaseBuilder.factory.learningContent.build(learningContentObjects); targetProfileId = databaseBuilder.factory.buildTargetProfile().id; campaignId = databaseBuilder.factory.buildCampaign({ targetProfileId }).id; campaignSkillsId.map((skillId) => { diff --git a/api/tests/integration/infrastructure/repositories/campaign-participation-result-repository_test.js b/api/tests/integration/infrastructure/repositories/campaign-participation-result-repository_test.js index 53c6cce864a..8fb8c4e4187 100644 --- a/api/tests/integration/infrastructure/repositories/campaign-participation-result-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/campaign-participation-result-repository_test.js @@ -1,7 +1,7 @@ import { campaignParticipationResultRepository } from '../../../../lib/infrastructure/repositories/campaign-participation-result-repository.js'; import { CampaignParticipationStatuses } from '../../../../src/prescription/shared/domain/constants.js'; import { KnowledgeElement } from '../../../../src/shared/domain/models/KnowledgeElement.js'; -import { databaseBuilder, expect, mockLearningContent } from '../../../test-helper.js'; +import { databaseBuilder, expect } from '../../../test-helper.js'; const { STARTED } = CampaignParticipationStatuses; @@ -54,7 +54,7 @@ describe('Integration | Repository | Campaign Participation Result', function () ], }; - mockLearningContent(learningContent); + databaseBuilder.factory.learningContent.build(learningContent); return databaseBuilder.commit(); }); diff --git a/api/tests/integration/infrastructure/repositories/campaign-repository_test.js b/api/tests/integration/infrastructure/repositories/campaign-repository_test.js index 8727ae01c0e..cf12105b909 100644 --- a/api/tests/integration/infrastructure/repositories/campaign-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/campaign-repository_test.js @@ -123,7 +123,7 @@ describe('Integration | Repository | Campaign', function () { area.competences = [competence]; framework.areas = [area]; const learningContent = buildLearningContent([framework]); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const targetProfileId = databaseBuilder.factory.buildTargetProfile().id; databaseBuilder.factory.buildTargetProfileTube({ targetProfileId, tubeId: 'tubeId1' }); diff --git a/api/tests/integration/infrastructure/repositories/framework-repository_test.js b/api/tests/integration/infrastructure/repositories/framework-repository_test.js index bd0f218b9e0..82dabf2cd6b 100644 --- a/api/tests/integration/infrastructure/repositories/framework-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/framework-repository_test.js @@ -18,8 +18,8 @@ describe('Integration | Repository | framework-repository', function () { const learningContent = { frameworks: [framework0, framework1, framework2] }; - beforeEach(function () { - mockLearningContent(learningContent); + beforeEach(async function () { + await mockLearningContent(learningContent); }); describe('#list', function () { diff --git a/api/tests/integration/infrastructure/repositories/learning-content-repository_test.js b/api/tests/integration/infrastructure/repositories/learning-content-repository_test.js index 5ff56121281..0d17055889c 100644 --- a/api/tests/integration/infrastructure/repositories/learning-content-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/learning-content-repository_test.js @@ -18,7 +18,7 @@ describe('Integration | Repository | learning-content', function () { let tube1Fr, tube1En, tube2Fr, tube2En, tube4Fr, tube4En; let skill1, skill2, skill3, skill8; - beforeEach(function () { + beforeEach(async function () { learningContent = learningContentBuilder([ { id: 'recFramework1', @@ -235,7 +235,7 @@ describe('Integration | Repository | learning-content', function () { [tube1En, tube2En, , tube4En] = _buildDomainTubesFromLearningContent(learningContent, 'en'); [skill1, skill2, skill3, , , , , skill8] = _buildDomainSkillsFromLearningContent(learningContent); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); describe('#findByCampaignId', function () { diff --git a/api/tests/integration/infrastructure/repositories/participant-results-shared-repository_test.js b/api/tests/integration/infrastructure/repositories/participant-results-shared-repository_test.js index 901ba1e0cd0..2a250c49028 100644 --- a/api/tests/integration/infrastructure/repositories/participant-results-shared-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/participant-results-shared-repository_test.js @@ -101,7 +101,7 @@ describe('Integration | Repository | Campaign Participant Result Shared Reposito skills: [{ id: 'skill_1' }, { id: 'skill_2' }, { id: 'skill_3' }], competences: [], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); //when const participantResultsShared = await participantResultsSharedRepository.get(participation.id); @@ -141,7 +141,7 @@ describe('Integration | Repository | Campaign Participant Result Shared Reposito { id: 'competence_5', origin: 'Pix' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); //when const participantResultsShared = await participantResultsSharedRepository.get(participation.id); @@ -178,7 +178,7 @@ describe('Integration | Repository | Campaign Participant Result Shared Reposito { id: 'competence_5', origin: 'Pix' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); //when const participantResultsShared = await participantResultsSharedRepository.get(participation.id); @@ -209,7 +209,7 @@ describe('Integration | Repository | Campaign Participant Result Shared Reposito ], competences: [], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); //when const participantResultsShared = await participantResultsSharedRepository.get(participation.id); @@ -242,7 +242,7 @@ describe('Integration | Repository | Campaign Participant Result Shared Reposito ], competences: [], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); //when const participantResultsShared = await participantResultsSharedRepository.get(participation.id); @@ -275,7 +275,7 @@ describe('Integration | Repository | Campaign Participant Result Shared Reposito ], competences: [], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); //when const participantResultsShared = await participantResultsSharedRepository.get(participation.id); @@ -318,7 +318,7 @@ describe('Integration | Repository | Campaign Participant Result Shared Reposito { id: 'competence_5', origin: 'Pix' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); //when const participantResultsShared = await participantResultsSharedRepository.get(participation.id); @@ -339,7 +339,7 @@ describe('Integration | Repository | Campaign Participant Result Shared Reposito await databaseBuilder.commit(); const learningContent = { skills: [{ id: 'skill_1', status: 'actif' }], competences: [] }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); //when const participantResultsShared = await participantResultsSharedRepository.get(participation.id); diff --git a/api/tests/integration/infrastructure/repositories/thematic-repository_test.js b/api/tests/integration/infrastructure/repositories/thematic-repository_test.js index 1455d249247..e6777d51e9a 100644 --- a/api/tests/integration/infrastructure/repositories/thematic-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/thematic-repository_test.js @@ -12,7 +12,7 @@ describe('Integration | Repository | thematic-repository', function () { thematics: [{ ...thematic, name_i18n: { fr: 'frName' } }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualThematics = await thematicRepository.list(); @@ -30,7 +30,7 @@ describe('Integration | Repository | thematic-repository', function () { thematics: [{ ...thematic, name_i18n: { fr: 'frName', en: 'enName' } }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualThematics = await thematicRepository.list({ locale }); @@ -85,8 +85,8 @@ describe('Integration | Repository | thematic-repository', function () { thematics, }; - beforeEach(function () { - mockLearningContent(learningContent); + beforeEach(async function () { + await mockLearningContent(learningContent); }); it('should return thematics of a competence', async function () { @@ -142,14 +142,14 @@ describe('Integration | Repository | thematic-repository', function () { }); describe('#findByRecordIds', function () { - beforeEach(function () { + beforeEach(async function () { const learningContentThematic0 = { id: 'recThematic0', name_i18n: { fr: 'nameThemaFR0', en: 'nameThemaEN0', }, - index: 'indexThema0', + index: 0, description: 'tubeDescription0', competenceId: 'recComp0', }; @@ -159,7 +159,7 @@ describe('Integration | Repository | thematic-repository', function () { fr: 'nameThemaFR1', en: 'nameThemaEN1', }, - index: 'indexThema1', + index: 1, description: 'tubeDescription1', competenceId: 'recComp1', }; @@ -169,11 +169,11 @@ describe('Integration | Repository | thematic-repository', function () { fr: 'nameThemaFR2', en: 'nameThemaEN2', }, - index: 'indexThema2', + index: 2, description: 'tubeDescription2', competenceId: 'recComp2', }; - mockLearningContent({ + await mockLearningContent({ thematics: [learningContentThematic0, learningContentThematic1, learningContentThematic2], }); }); @@ -183,14 +183,14 @@ describe('Integration | Repository | thematic-repository', function () { const thematic1 = new Thematic({ id: 'recThematic1', name: 'nameThemaFR1', - index: 'indexThema1', + index: 1, competenceId: 'recComp1', tubeIds: [], }); const thematic2 = new Thematic({ id: 'recThematic2', name: 'nameThemaFR2', - index: 'indexThema2', + index: 2, competenceId: 'recComp2', tubeIds: [], }); @@ -207,14 +207,14 @@ describe('Integration | Repository | thematic-repository', function () { const thematic1 = new Thematic({ id: 'recThematic1', name: 'nameThemaEN1', - index: 'indexThema1', + index: 1, competenceId: 'recComp1', tubeIds: [], }); const thematic2 = new Thematic({ id: 'recThematic2', name: 'nameThemaEN2', - index: 'indexThema2', + index: 2, competenceId: 'recComp2', tubeIds: [], }); diff --git a/api/tests/integration/infrastructure/repositories/tube-repository_test.js b/api/tests/integration/infrastructure/repositories/tube-repository_test.js index 88113809123..bc71889c661 100644 --- a/api/tests/integration/infrastructure/repositories/tube-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/tube-repository_test.js @@ -38,7 +38,7 @@ describe('Integration | Repository | tube-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const tube = await tubeRepository.get(expectedTube.id); @@ -106,7 +106,7 @@ describe('Integration | Repository | tube-repository', function () { thematicId: 'thematicCava', skillIds: ['skillPoire', 'skillPeche'], }; - mockLearningContent({ tubes: [learningContentTube0, learningContentTube1] }); + await mockLearningContent({ tubes: [learningContentTube0, learningContentTube1] }); // when const tubes = await tubeRepository.list(); @@ -178,7 +178,7 @@ describe('Integration | Repository | tube-repository', function () { thematicId: 'thematicCava', skillIds: ['skillPoire', 'skillPeche'], }; - mockLearningContent({ tubes: [learningContentTube1, learningContentTube0] }); + await mockLearningContent({ tubes: [learningContentTube1, learningContentTube0] }); // when const tubes = await tubeRepository.findByNames({ tubeNames: ['tubeName1', 'tubeName0'] }); @@ -222,7 +222,7 @@ describe('Integration | Repository | tube-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const tubes = await tubeRepository.findByNames({ tubeNames: ['tubeName'] }); @@ -269,7 +269,7 @@ describe('Integration | Repository | tube-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const locale = 'en'; // when @@ -283,7 +283,7 @@ describe('Integration | Repository | tube-repository', function () { }); describe('#findByRecordIds', function () { - beforeEach(function () { + beforeEach(async function () { const learningContentTube0 = { id: 'recTube0', name: 'tubeName0', @@ -349,7 +349,7 @@ describe('Integration | Repository | tube-repository', function () { tubeId: 'recTube2', }, ]; - mockLearningContent({ tubes: [learningContentTube1, learningContentTube0, learningContentTube2], skills }); + await mockLearningContent({ tubes: [learningContentTube1, learningContentTube0, learningContentTube2], skills }); }); it('should return a list of tubes (locale FR - default)', async function () { @@ -502,7 +502,7 @@ describe('Integration | Repository | tube-repository', function () { tubeId: 'recTube2', }, ]; - mockLearningContent({ tubes: [learningContentTube1, learningContentTube0, learningContentTube2], skills }); + await mockLearningContent({ tubes: [learningContentTube1, learningContentTube0, learningContentTube2], skills }); // when const tubes = await tubeRepository.findActiveByRecordIds(['recTube1', 'recTube2']); @@ -598,7 +598,7 @@ describe('Integration | Repository | tube-repository', function () { tubeId: 'recTube2', }, ]; - mockLearningContent({ tubes: [learningContentTube1, learningContentTube0, learningContentTube2], skills }); + await mockLearningContent({ tubes: [learningContentTube1, learningContentTube0, learningContentTube2], skills }); // when const tubes = await tubeRepository.findActiveByRecordIds(['recTube1', 'recTube2'], 'en'); diff --git a/api/tests/integration/infrastructure/repositories/user-campaign-results/stage-collection-repository_test.js b/api/tests/integration/infrastructure/repositories/user-campaign-results/stage-collection-repository_test.js index f8b234a149b..2ebac615916 100644 --- a/api/tests/integration/infrastructure/repositories/user-campaign-results/stage-collection-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/user-campaign-results/stage-collection-repository_test.js @@ -50,7 +50,7 @@ describe('Integration | Infrastructure | Repository | stage-collection-repositor beforeEach(async function () { const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); targetProfileId = databaseBuilder.factory.buildTargetProfile().id; campaignId = databaseBuilder.factory.buildCampaign({ type: 'ASSESSMENT', targetProfileId }).id; databaseBuilder.factory.buildCampaignSkill({ skillId: 'skillWeb1', campaignId }); diff --git a/api/tests/integration/scripts/data-generation/generate-campaign-with-participant_test.js b/api/tests/integration/scripts/data-generation/generate-campaign-with-participant_test.js index 9be968bb5c2..562c5fd9f4e 100644 --- a/api/tests/integration/scripts/data-generation/generate-campaign-with-participant_test.js +++ b/api/tests/integration/scripts/data-generation/generate-campaign-with-participant_test.js @@ -4,7 +4,7 @@ import { databaseBuilder, expect, knex, learningContentBuilder, mockLearningCont describe('Integration | Scripts | generate-campaign-with-participants', function () { it('should create a profiles collection campaign with participants', async function () { // given - mockLearningContent(learningContentBuilder.fromAreas([])); + await mockLearningContent(learningContentBuilder.fromAreas([])); const organizationId = databaseBuilder.factory.buildOrganization().id; const userId = databaseBuilder.factory.buildUser({ id: 1 }).id; databaseBuilder.factory.buildMembership({ organizationId, organizationRole: 'ADMIN', userId }); @@ -25,7 +25,7 @@ describe('Integration | Scripts | generate-campaign-with-participants', function it('should create a assessment campaign with participants', async function () { // given - mockLearningContent(learningContentBuilder.fromAreas([])); + await mockLearningContent(learningContentBuilder.fromAreas([])); const organizationId = databaseBuilder.factory.buildOrganization().id; const userId = databaseBuilder.factory.buildUser({ id: 1 }).id; databaseBuilder.factory.buildMembership({ organizationId, organizationRole: 'ADMIN', userId }); diff --git a/api/tests/integration/scripts/data-generation/generate-certif-cli_test.js b/api/tests/integration/scripts/data-generation/generate-certif-cli_test.js index e366a1cb07b..ff1969e7cfb 100644 --- a/api/tests/integration/scripts/data-generation/generate-certif-cli_test.js +++ b/api/tests/integration/scripts/data-generation/generate-certif-cli_test.js @@ -24,7 +24,7 @@ describe('Integration | Scripts | generate-certif-cli.js', function () { skills: [{ tubeId: 'xxx', skillId: 'yyy', status: 'actif' }], challenges: [], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); afterEach(function () { diff --git a/api/tests/integration/scripts/prod/compute-participation-results_test.js b/api/tests/integration/scripts/prod/compute-participation-results_test.js index 0bf9111cdfe..0417f9d4ce1 100644 --- a/api/tests/integration/scripts/prod/compute-participation-results_test.js +++ b/api/tests/integration/scripts/prod/compute-participation-results_test.js @@ -29,7 +29,7 @@ describe('computeParticipationResults', function () { { id: 'competence_3', origin: 'Pix' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await computeParticipationResults(1, false); @@ -62,7 +62,7 @@ describe('computeParticipationResults', function () { ], competences: [], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await computeParticipationResults(1, false); @@ -110,7 +110,7 @@ describe('computeParticipationResults', function () { { id: 'competence_5', origin: 'Pix' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await computeParticipationResults(1, false); const campaignParticipations = await knex('campaign-participations') @@ -140,7 +140,7 @@ describe('computeParticipationResults', function () { await databaseBuilder.commit(); - mockLearningContent({ skills: [], competences: [] }); + await mockLearningContent({ skills: [], competences: [] }); await computeParticipationResults(1, false); const campaignParticipations = await knex('campaign-participations') @@ -171,7 +171,7 @@ describe('computeParticipationResults', function () { await databaseBuilder.commit(); - mockLearningContent({ skills: [], competences: [] }); + await mockLearningContent({ skills: [], competences: [] }); await computeParticipationResults(1, false); @@ -200,7 +200,7 @@ describe('computeParticipationResults', function () { await databaseBuilder.commit(); - mockLearningContent({ skills: [], competences: [] }); + await mockLearningContent({ skills: [], competences: [] }); await computeParticipationResults(1, false); @@ -221,7 +221,7 @@ describe('computeParticipationResults', function () { await databaseBuilder.commit(); - mockLearningContent({ skills: [] }); + await mockLearningContent({ skills: [] }); await computeParticipationResults(1, false); diff --git a/api/tests/integration/scripts/prod/insert-missing-pole-emploi-sending-from-date_test.js b/api/tests/integration/scripts/prod/insert-missing-pole-emploi-sending-from-date_test.js index c6ad7778b67..f4a2fe9336d 100644 --- a/api/tests/integration/scripts/prod/insert-missing-pole-emploi-sending-from-date_test.js +++ b/api/tests/integration/scripts/prod/insert-missing-pole-emploi-sending-from-date_test.js @@ -41,7 +41,7 @@ describe('Script | Prod | Delete Organization Learners From Organization', funct ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); context('validation', function () { diff --git a/api/tests/prescription/campaign-participation/acceptance/application/campaign-participation-route_test.js b/api/tests/prescription/campaign-participation/acceptance/application/campaign-participation-route_test.js index f235751b546..3ad4930ec84 100644 --- a/api/tests/prescription/campaign-participation/acceptance/application/campaign-participation-route_test.js +++ b/api/tests/prescription/campaign-participation/acceptance/application/campaign-participation-route_test.js @@ -47,9 +47,9 @@ describe('Acceptance | API | Campaign Participations', function () { }); describe('GET /api/campaigns/{campaignId}/profiles-collection-participations/{campaignParticipationId}', function () { - beforeEach(function () { + beforeEach(async function () { const learningObjects = learningContentBuilder.fromAreas([]); - mockLearningContent(learningObjects); + await mockLearningContent(learningObjects); }); it('should return the campaign profile as JSONAPI', async function () { @@ -158,7 +158,7 @@ describe('Acceptance | API | Campaign Participations', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should return the campaign participation analyses', async function () { @@ -263,7 +263,7 @@ describe('Acceptance | API | Campaign Participations', function () { }); describe('GET /api/campaigns/{campaignId}/assessment-participations/{campaignParticipationId}/results', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = [ { id: 'recArea1', @@ -298,7 +298,7 @@ describe('Acceptance | API | Campaign Participations', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should return the assessment participation results', async function () { @@ -331,9 +331,9 @@ describe('Acceptance | API | Campaign Participations', function () { }); describe('GET /api/campaigns/{campaignId}/organization-learners/{organizationLearnerId}/participations', function () { - beforeEach(function () { + beforeEach(async function () { const learningObjects = learningContentBuilder.fromAreas([]); - mockLearningContent(learningObjects); + await mockLearningContent(learningObjects); }); it('should return the campaign profile as JSONAPI', async function () { @@ -610,7 +610,7 @@ describe('Acceptance | API | Campaign Participations', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); await databaseBuilder.commit(); }); @@ -810,7 +810,7 @@ describe('Acceptance | API | Campaign Participations', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + databaseBuilder.factory.learningContent.build(learningContentObjects); return databaseBuilder.commit(); }); diff --git a/api/tests/prescription/campaign-participation/acceptance/application/learner-participation-route_test.js b/api/tests/prescription/campaign-participation/acceptance/application/learner-participation-route_test.js index bafc18b3f1a..2082cfdc516 100644 --- a/api/tests/prescription/campaign-participation/acceptance/application/learner-participation-route_test.js +++ b/api/tests/prescription/campaign-participation/acceptance/application/learner-participation-route_test.js @@ -57,7 +57,7 @@ describe('Acceptance | Routes | Campaign Participations', function () { }, ]; const learningObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningObjects); + await mockLearningContent(learningObjects); options = { method: 'PATCH', @@ -194,7 +194,7 @@ describe('Acceptance | Routes | Campaign Participations', function () { area.competences = [competence]; framework.areas = [area]; const learningContent = buildLearningContent([framework]); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); await databaseBuilder.commit(); }); @@ -407,7 +407,7 @@ describe('Acceptance | Routes | Campaign Participations', function () { }; beforeEach(async function () { - mockLearningContent(learningContent); + await mockLearningContent(learningContent); userId = 100; databaseBuilder.factory.buildUser({ id: userId }); const campaign = databaseBuilder.factory.buildCampaign(); diff --git a/api/tests/prescription/campaign-participation/integration/domain/usecases/get-campaign-profile_test.js b/api/tests/prescription/campaign-participation/integration/domain/usecases/get-campaign-profile_test.js index 9d63f7811d4..e850b20072e 100644 --- a/api/tests/prescription/campaign-participation/integration/domain/usecases/get-campaign-profile_test.js +++ b/api/tests/prescription/campaign-participation/integration/domain/usecases/get-campaign-profile_test.js @@ -6,8 +6,8 @@ const { FRENCH_SPOKEN } = LOCALE; describe('Integration | UseCase | get-campaign-profile', function () { const locale = FRENCH_SPOKEN; - beforeEach(function () { - mockLearningContent({ competences: [], areas: [], skills: [] }); + beforeEach(async function () { + await mockLearningContent({ competences: [], areas: [], skills: [] }); }); it('should return the campaign profile', async function () { diff --git a/api/tests/prescription/campaign-participation/integration/domain/usecases/start-campaign-participation_test.js b/api/tests/prescription/campaign-participation/integration/domain/usecases/start-campaign-participation_test.js index bf2bfcfb89b..0071f03a7b0 100644 --- a/api/tests/prescription/campaign-participation/integration/domain/usecases/start-campaign-participation_test.js +++ b/api/tests/prescription/campaign-participation/integration/domain/usecases/start-campaign-participation_test.js @@ -6,7 +6,7 @@ describe('Integration | UseCases | startCampaignParticipation', function () { it('start a new participation', async function () { const { id: campaignId } = databaseBuilder.factory.buildCampaign({ type: 'PROFILES_COLLECTION', idPixLabel: null }); const { id: userId } = databaseBuilder.factory.buildUser(); - mockLearningContent({ + await mockLearningContent({ skills: [], }); await databaseBuilder.commit(); diff --git a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-assessment-participation-repository_test.js b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-assessment-participation-repository_test.js index 6d7955d9945..e81f6b66183 100644 --- a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-assessment-participation-repository_test.js +++ b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-assessment-participation-repository_test.js @@ -26,7 +26,7 @@ describe('Integration | Repository | Campaign Assessment Participation', functio beforeEach(async function () { const skill1 = { id: 'skill1' }; const skill2 = { id: 'skill2' }; - mockLearningContent({ skills: [skill1, skill2] }); + await mockLearningContent({ skills: [skill1, skill2] }); campaignId = databaseBuilder.factory.buildAssessmentCampaign({}).id; const assessment = databaseBuilder.factory.buildAssessmentFromParticipation( @@ -85,7 +85,7 @@ describe('Integration | Repository | Campaign Assessment Participation', functio beforeEach(async function () { const skill1 = { id: 'skill1', status: 'actif' }; const skill2 = { id: 'skill2', status: 'actif' }; - mockLearningContent({ skills: [skill1, skill2] }); + await mockLearningContent({ skills: [skill1, skill2] }); campaignId = databaseBuilder.factory.buildAssessmentCampaignForSkills({}, [skill1, skill2]).id; const userId = databaseBuilder.factory.buildUser().id; @@ -130,7 +130,7 @@ describe('Integration | Repository | Campaign Assessment Participation', functio context('When campaign participation is not shared', function () { beforeEach(async function () { const skill1 = { id: 'skill1', status: 'actif' }; - mockLearningContent({ skills: [skill1] }); + await mockLearningContent({ skills: [skill1] }); campaignId = databaseBuilder.factory.buildAssessmentCampaign({}, [skill1]).id; campaignParticipationId = databaseBuilder.factory.buildAssessmentFromParticipation({ status: STARTED, @@ -161,7 +161,7 @@ describe('Integration | Repository | Campaign Assessment Participation', functio const skill2 = { id: 'skill2', status: 'actif' }; const skill3 = { id: 'skill3', status: 'actif' }; const skill4 = { id: 'skill4', status: 'périmé' }; - mockLearningContent({ skills: [skill1, skill2, skill3] }); + await mockLearningContent({ skills: [skill1, skill2, skill3] }); campaignId = databaseBuilder.factory.buildAssessmentCampaignForSkills({}, [skill1, skill3, skill4]).id; userId = databaseBuilder.factory.buildUser().id; @@ -232,7 +232,7 @@ describe('Integration | Repository | Campaign Assessment Participation', functio beforeEach(async function () { const skill = { id: 'skill', status: 'actif' }; - mockLearningContent({ skills: [skill] }); + await mockLearningContent({ skills: [skill] }); const otherOrganizationId = databaseBuilder.factory.buildOrganization().id; const organizationId = databaseBuilder.factory.buildOrganization().id; campaignId = databaseBuilder.factory.buildAssessmentCampaignForSkills({ organizationId }, [skill]).id; @@ -284,7 +284,7 @@ describe('Integration | Repository | Campaign Assessment Participation', functio context('When something is wrong with a campaign participations', function () { it('throw a NotFoundError when campaign participation does not exist', async function () { const skill1 = { id: 'skill1', status: 'actif' }; - mockLearningContent({ skills: [skill1] }); + await mockLearningContent({ skills: [skill1] }); campaignId = databaseBuilder.factory.buildAssessmentCampaign({}, [skill1]).id; @@ -300,7 +300,7 @@ describe('Integration | Repository | Campaign Assessment Participation', functio it('throw a NotFoundError when campaign participation is deleted', async function () { const skill1 = { id: 'skill1', status: 'actif' }; - mockLearningContent({ skills: [skill1] }); + await mockLearningContent({ skills: [skill1] }); campaignId = databaseBuilder.factory.buildAssessmentCampaign({}, [skill1]).id; campaignParticipationId = databaseBuilder.factory.buildAssessmentFromParticipation({ diff --git a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-assessment-participation-result-repository_test.js b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-assessment-participation-result-repository_test.js index 5b172fa243e..cf3a623630f 100644 --- a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-assessment-participation-result-repository_test.js +++ b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-assessment-participation-result-repository_test.js @@ -11,7 +11,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result', describe('#getByCampaignIdAndCampaignParticipationId', function () { let campaignId, campaignParticipationId; - beforeEach(function () { + beforeEach(async function () { const learningContent = { frameworks: [{ id: 'frameworkId', name: 'frameworkName' }], areas: [ @@ -76,7 +76,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result', challenges: [], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); return databaseBuilder.commit(); }); diff --git a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-participant-repository_test.js b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-participant-repository_test.js index 6eab44367f1..e11eca2e31b 100644 --- a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-participant-repository_test.js +++ b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-participant-repository_test.js @@ -12,7 +12,7 @@ import { OrganizationLearnersCouldNotBeSavedError, } from '../../../../../../src/shared/domain/errors.js'; import { NotFoundError } from '../../../../../../src/shared/domain/errors.js'; -import { catchErr, databaseBuilder, expect, mockLearningContent, sinon } from '../../../../../test-helper.js'; +import { catchErr, databaseBuilder, expect, sinon } from '../../../../../test-helper.js'; const campaignParticipationDBAttributes = [ 'id', @@ -30,16 +30,24 @@ describe('Integration | Infrastructure | Repository | CampaignParticipant', func describe('get', function () { let organizationId, organizationFeatureAPI; - beforeEach(function () { + beforeEach(async function () { organizationId = 12; - const learningContent = { skills: [{ id: 'skill1', status: 'actif' }] }; + const learningContent = { + skills: [ + { id: 'skill1', status: 'actif' }, + { id: 'skill2', status: 'actif' }, + { id: 'skill3', status: 'archivé' }, + { id: 'skill4', status: 'inactif' }, + ], + }; organizationFeatureAPI = { getAllFeaturesFromOrganization: sinon.stub().resolves({ hasLearnersImportFeature: false }), }; featureId = databaseBuilder.factory.buildFeature(CAMPAIGN_FEATURES.EXTERNAL_ID).id; - mockLearningContent(learningContent); + databaseBuilder.factory.learningContent.build(learningContent); + await databaseBuilder.commit(); }); afterEach(function () { @@ -477,15 +485,6 @@ describe('Integration | Infrastructure | Repository | CampaignParticipant', func context('when there is one campaign', function () { it('find campaign with operative skills', async function () { - const learningContent = { - skills: [ - { id: 'skill1', status: 'actif' }, - { id: 'skill2', status: 'archivé' }, - { id: 'skill3', status: 'inactif' }, - ], - }; - - mockLearningContent(learningContent); const campaignToStartParticipation = buildCampaignWithSkills( { idPixLabel: 'email', @@ -496,7 +495,7 @@ describe('Integration | Infrastructure | Repository | CampaignParticipant', func assessmentMethod: 'SMART_RANDOM', skillCount: 1, }, - ['skill1'], + ['skill2'], ); const { id: userId } = databaseBuilder.factory.buildUser(); @@ -517,15 +516,6 @@ describe('Integration | Infrastructure | Repository | CampaignParticipant', func context('when there are several campaigns', function () { it('find skills for the correct campaign', async function () { - const learningContent = { - skills: [ - { id: 'skill1', status: 'actif' }, - { id: 'skill2', status: 'actif' }, - ], - }; - - mockLearningContent(learningContent); - const campaignToStartParticipation = buildCampaignWithSkills( { idPixLabel: 'email', diff --git a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-participation-overview-repository_test.js b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-participation-overview-repository_test.js index 703e078e71a..4611ebc2e4f 100644 --- a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-participation-overview-repository_test.js +++ b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-participation-overview-repository_test.js @@ -47,7 +47,7 @@ describe('Integration | Repository | Campaign Participation Overview', function }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); targetProfile = databaseBuilder.factory.buildTargetProfile(); databaseBuilder.factory.buildStage({ targetProfileId: targetProfile.id }); await databaseBuilder.commit(); diff --git a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-profile-repository_test.js b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-profile-repository_test.js index 090645a3cfc..75be3f9b251 100644 --- a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-profile-repository_test.js +++ b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/campaign-profile-repository_test.js @@ -11,8 +11,8 @@ describe('Integration | Repository | CampaignProfileRepository', function () { describe('#findProfile', function () { context('campaign participation infos', function () { - beforeEach(function () { - mockLearningContent({ areas: [], competences: [], skills: [] }); + beforeEach(async function () { + await mockLearningContent({ areas: [], competences: [], skills: [] }); }); it('return the creation date, the sharing date and the participantExternalId', async function () { @@ -79,8 +79,8 @@ describe('Integration | Repository | CampaignProfileRepository', function () { }); context('organization learner infos', function () { - beforeEach(function () { - mockLearningContent({ areas: [], competences: [], skills: [] }); + beforeEach(async function () { + await mockLearningContent({ areas: [], competences: [], skills: [] }); }); it('return the first name and last name of the organization learner', async function () { @@ -131,7 +131,7 @@ describe('Integration | Repository | CampaignProfileRepository', function () { }); context('certification infos', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = { areas: [{ id: 'recArea1', competenceIds: ['recArea1_Competence1'] }], competences: [ @@ -158,7 +158,7 @@ describe('Integration | Repository | CampaignProfileRepository', function () { ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('return the number of competences', async function () { @@ -292,8 +292,8 @@ describe('Integration | Repository | CampaignProfileRepository', function () { }); context('when there is no campaign-participation with the given id', function () { - beforeEach(function () { - mockLearningContent({ areas: [], competences: [], skills: [] }); + beforeEach(async function () { + await mockLearningContent({ areas: [], competences: [], skills: [] }); }); it('throws an NotFoundError error', async function () { @@ -309,8 +309,8 @@ describe('Integration | Repository | CampaignProfileRepository', function () { }); context('when there is no campaign-participation with the given id for the given campaign', function () { - beforeEach(function () { - mockLearningContent({ areas: [], competences: [], skills: [] }); + beforeEach(async function () { + await mockLearningContent({ areas: [], competences: [], skills: [] }); }); it('throws an NotFoundError error', async function () { @@ -331,8 +331,8 @@ describe('Integration | Repository | CampaignProfileRepository', function () { }); context('when the campaign-participation is deleted with the given id for the given campaign', function () { - beforeEach(function () { - mockLearningContent({ areas: [], competences: [], skills: [] }); + beforeEach(async function () { + await mockLearningContent({ areas: [], competences: [], skills: [] }); }); it('throws a NotFoundError error', async function () { diff --git a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/participant-result-repository_test.js b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/participant-result-repository_test.js index 343a80093cc..02649de61ac 100644 --- a/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/participant-result-repository_test.js +++ b/api/tests/prescription/campaign-participation/integration/infrastructure/repositories/participant-result-repository_test.js @@ -5,7 +5,7 @@ import { CampaignParticipationStatuses, KnowledgeElement, } from '../../../../../../src/shared/domain/models/index.js'; -import { catchErr, databaseBuilder, domainBuilder, expect, mockLearningContent } from '../../../../../test-helper.js'; +import { catchErr, databaseBuilder, domainBuilder, expect } from '../../../../../test-helper.js'; const { STARTED } = CampaignParticipationStatuses; @@ -86,7 +86,7 @@ describe('Integration | Repository | ParticipantResultRepository', function () { ], }; - mockLearningContent(learningContent); + databaseBuilder.factory.learningContent.build(learningContent); return databaseBuilder.commit(); }); diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-administration-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-administration-route_test.js index ec53377933d..d21f87fee14 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-administration-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-administration-route_test.js @@ -52,7 +52,7 @@ describe('Acceptance | API | campaign-administration-route', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const payload = { @@ -176,7 +176,7 @@ describe('Acceptance | API | campaign-administration-route', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const payload = { diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-detail-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-detail-route_test.js index 0d5a8613370..4cc86abd2da 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-detail-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-detail-route_test.js @@ -97,7 +97,7 @@ describe('Acceptance | API | campaign-detail-route', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should return the campaign by id', async function () { @@ -165,7 +165,7 @@ describe('Acceptance | API | campaign-detail-route', function () { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should return csv file with statusCode 200', async function () { @@ -251,7 +251,7 @@ describe('Acceptance | API | campaign-detail-route', function () { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should return csv file with statusCode 200', async function () { diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-results-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-results-route_test.js index 215d40fa660..009d8dc78f8 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-results-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-results-route_test.js @@ -49,7 +49,7 @@ describe('Acceptance | API | campaign-results-route', function () { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); campaign = databaseBuilder.factory.buildAssessmentCampaignForSkills({ organizationId: organization.id }, [skill]); @@ -139,7 +139,7 @@ describe('Acceptance | API | campaign-results-route', function () { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); context('Division filter', function () { @@ -611,7 +611,7 @@ describe('Acceptance | API | campaign-results-route', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should return campaign collective result with status code 200', async function () { diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-route_test.js index 2b100735f17..63d85c76196 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-route_test.js @@ -134,7 +134,7 @@ describe('Acceptance | API | Campaign Route', function () { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should return campaign analysis with status code 200', async function () { @@ -276,7 +276,7 @@ describe('Acceptance | API | Campaign Route', function () { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should return campaign analysis with status code 200', async function () { @@ -374,7 +374,7 @@ describe('Acceptance | API | Campaign Route', function () { const learningContent = domainBuilder.buildLearningContent.withSimpleContent(); const learningContentObjects = learningContentBuilder.fromAreas(learningContent.frameworks[0].areas); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildCampaignSkill({ campaignId: campaign.id, diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-stats-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-stats-route_test.js index b20e637f2fc..d226af09fcd 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-stats-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-stats-route_test.js @@ -42,7 +42,7 @@ describe('Acceptance | API | Campaign Stats Route', function () { ], }, ]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const targetProfileId = databaseBuilder.factory.buildTargetProfile().id; const stage1 = databaseBuilder.factory.buildStage({ diff --git a/api/tests/prescription/campaign/integration/domain/usecases/create-campaign_test.js b/api/tests/prescription/campaign/integration/domain/usecases/create-campaign_test.js index 98a53c1eb52..d768729c231 100644 --- a/api/tests/prescription/campaign/integration/domain/usecases/create-campaign_test.js +++ b/api/tests/prescription/campaign/integration/domain/usecases/create-campaign_test.js @@ -34,7 +34,7 @@ describe('Integration | UseCases | create-campaign', function () { skills: [{ id: 'recSkill1' }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should save a new campaign of type ASSESSMENT', async function () { diff --git a/api/tests/prescription/campaign/integration/domain/usecases/find-assessment-participation-result-list_test.js b/api/tests/prescription/campaign/integration/domain/usecases/find-assessment-participation-result-list_test.js index d0d068bd865..90260e14459 100644 --- a/api/tests/prescription/campaign/integration/domain/usecases/find-assessment-participation-result-list_test.js +++ b/api/tests/prescription/campaign/integration/domain/usecases/find-assessment-participation-result-list_test.js @@ -27,7 +27,14 @@ describe('Integration | UseCase | find-assessment-participation-result-list', fu const participant2 = { firstName: 'Tonari', lastName: 'No Totoro' }; databaseBuilder.factory.buildCampaignParticipationWithOrganizationLearner(participant2, participation2); - mockLearningContent({ skills: [skill], tubes: [], thematics: [], competences: [], areas: [], challenges: [] }); + await mockLearningContent({ + skills: [skill], + tubes: [], + thematics: [], + competences: [], + areas: [], + challenges: [], + }); await databaseBuilder.commit(); }); diff --git a/api/tests/prescription/campaign/integration/domain/usecases/find-campaign-profiles-collection-participation-summaries_test.js b/api/tests/prescription/campaign/integration/domain/usecases/find-campaign-profiles-collection-participation-summaries_test.js index 11d74bcf0b5..0a09c3ce6b7 100644 --- a/api/tests/prescription/campaign/integration/domain/usecases/find-campaign-profiles-collection-participation-summaries_test.js +++ b/api/tests/prescription/campaign/integration/domain/usecases/find-campaign-profiles-collection-participation-summaries_test.js @@ -15,7 +15,7 @@ describe('Integration | UseCase | find-campaign-profiles-collection-participatio databaseBuilder.factory.buildMembership({ organizationId, userId }); - mockLearningContent({ skills: [], tubes: [], competences: [], areas: [] }); + await mockLearningContent({ skills: [], tubes: [], competences: [], areas: [] }); await databaseBuilder.commit(); }); diff --git a/api/tests/prescription/campaign/integration/domain/usecases/get-campaign_test.js b/api/tests/prescription/campaign/integration/domain/usecases/get-campaign_test.js index 89f68b0debd..a0ce02b6cf0 100644 --- a/api/tests/prescription/campaign/integration/domain/usecases/get-campaign_test.js +++ b/api/tests/prescription/campaign/integration/domain/usecases/get-campaign_test.js @@ -48,7 +48,7 @@ describe('Integration | UseCase | get-campaign', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const organizationId = databaseBuilder.factory.buildOrganization().id; userId = databaseBuilder.factory.buildUser().id; diff --git a/api/tests/prescription/campaign/integration/domain/usecases/get-presentation-steps_test.js b/api/tests/prescription/campaign/integration/domain/usecases/get-presentation-steps_test.js index 7756ffabae7..457bbabe75f 100644 --- a/api/tests/prescription/campaign/integration/domain/usecases/get-presentation-steps_test.js +++ b/api/tests/prescription/campaign/integration/domain/usecases/get-presentation-steps_test.js @@ -16,7 +16,7 @@ describe('Integration | Campaign | UseCase | get-presentation-steps', function ( beforeEach(async function () { const learningContent = domainBuilder.buildLearningContent.withSimpleContent(); const learningContentObjects = learningContentBuilder.fromAreas(learningContent.frameworks[0].areas); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const targetProfileId = databaseBuilder.factory.buildTargetProfile().id; diff --git a/api/tests/prescription/campaign/integration/domain/usecases/start-writing-campaign-assessment-results-to-stream_test.js b/api/tests/prescription/campaign/integration/domain/usecases/start-writing-campaign-assessment-results-to-stream_test.js index 7846fd848ea..0c2ee80e86a 100644 --- a/api/tests/prescription/campaign/integration/domain/usecases/start-writing-campaign-assessment-results-to-stream_test.js +++ b/api/tests/prescription/campaign/integration/domain/usecases/start-writing-campaign-assessment-results-to-stream_test.js @@ -68,7 +68,7 @@ describe('Integration | Domain | Use Cases | start-writing-campaign-assessment-r ], challenges: [], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); writableStream = new PassThrough(); csvPromise = streamToPromise(writableStream); diff --git a/api/tests/prescription/campaign/integration/domain/usecases/start-writing-campaign-profiles-collection-results-to-stream_test.js b/api/tests/prescription/campaign/integration/domain/usecases/start-writing-campaign-profiles-collection-results-to-stream_test.js index 2cff3190f5a..e5d2a4ba74c 100644 --- a/api/tests/prescription/campaign/integration/domain/usecases/start-writing-campaign-profiles-collection-results-to-stream_test.js +++ b/api/tests/prescription/campaign/integration/domain/usecases/start-writing-campaign-profiles-collection-results-to-stream_test.js @@ -119,7 +119,7 @@ describe('Integration | Domain | Use Cases | start-writing-profiles-collection-c ], skills, }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); writableStream = new PassThrough(); csvPromise = streamToPromise(writableStream); diff --git a/api/tests/prescription/campaign/integration/domain/usecases/statistics/get-campaign-participations-counts-by-stage_test.js b/api/tests/prescription/campaign/integration/domain/usecases/statistics/get-campaign-participations-counts-by-stage_test.js index 66cf6985820..eb45df4f79b 100644 --- a/api/tests/prescription/campaign/integration/domain/usecases/statistics/get-campaign-participations-counts-by-stage_test.js +++ b/api/tests/prescription/campaign/integration/domain/usecases/statistics/get-campaign-participations-counts-by-stage_test.js @@ -45,7 +45,7 @@ describe('Integration | UseCase | get-campaign-participations-counts-by-stage', ], }, ]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const targetProfileId = databaseBuilder.factory.buildTargetProfile().id; organizationId = databaseBuilder.factory.buildOrganization().id; diff --git a/api/tests/prescription/campaign/integration/domain/usecases/update-campaign-details_test.js b/api/tests/prescription/campaign/integration/domain/usecases/update-campaign-details_test.js index ebdda2768c0..354754799eb 100644 --- a/api/tests/prescription/campaign/integration/domain/usecases/update-campaign-details_test.js +++ b/api/tests/prescription/campaign/integration/domain/usecases/update-campaign-details_test.js @@ -44,7 +44,7 @@ describe('Integration | UseCases | update-campaign-details', function () { skills: [{ id: 'recSkill1' }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should update campaign', async function () { diff --git a/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-administration-repository_test.js b/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-administration-repository_test.js index 38b3e5d6560..27e4546359e 100644 --- a/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-administration-repository_test.js +++ b/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-administration-repository_test.js @@ -210,7 +210,7 @@ describe('Integration | Repository | Campaign Administration', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); databaseBuilder.factory.buildTargetProfileTube({ targetProfileId, tubeId: 'recTube1', level: 2 }); databaseBuilder.factory.buildTargetProfileTube({ targetProfileId, tubeId: 'recTube2', level: 8 }); @@ -274,7 +274,7 @@ describe('Integration | Repository | Campaign Administration', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); databaseBuilder.factory.buildTargetProfileTube({ targetProfileId, tubeId: 'recTube1', level: 2 }); await databaseBuilder.commit(); diff --git a/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-assessment-participation-result-list-repository_test.js b/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-assessment-participation-result-list-repository_test.js index 8cc1e4cec53..31a334520e6 100644 --- a/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-assessment-participation-result-list-repository_test.js +++ b/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-assessment-participation-result-list-repository_test.js @@ -55,7 +55,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('returns the list of participations shared for the given campaign', async function () { @@ -106,7 +106,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('returns the list of participations shared for the given campaign', async function () { @@ -225,7 +225,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('returns the name from the organization learner', async function () { @@ -282,7 +282,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('returns acquired badges during the campaign', async function () { @@ -330,7 +330,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('does not return deleted participations', async function () { @@ -376,7 +376,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('computes the mastery percentage', async function () { @@ -596,7 +596,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const { participations } = await campaignAssessmentParticipationResultListRepository.findPaginatedByCampaignId({ @@ -639,7 +639,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('should return paginated campaign participations based on the given size and number', async function () { @@ -754,7 +754,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const { participations } = await campaignAssessmentParticipationResultListRepository.findPaginatedByCampaignId({ @@ -775,7 +775,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li let user1; let user2; - beforeEach(function () { + beforeEach(async function () { campaign = databaseBuilder.factory.buildAssessmentCampaignForSkills({}, [{ id: 'Skill1' }]); badge1 = databaseBuilder.factory.buildBadge({ key: 'badge1', targetProfileId: campaign.targetProfileId }); badge2 = databaseBuilder.factory.buildBadge({ key: 'badge2', targetProfileId: campaign.targetProfileId }); @@ -799,7 +799,8 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + databaseBuilder.factory.learningContent.build(learningContentObjects); + await databaseBuilder.commit(); }); it('returns participants which have one badge', async function () { const campaignParticipation1 = databaseBuilder.factory.buildCampaignParticipation({ @@ -934,7 +935,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }); context('when there is a filter on stage', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = [ { id: 'recArea1', @@ -952,7 +953,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('returns participants which have the given stage', async function () { @@ -1238,7 +1239,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const { participations } = await campaignAssessmentParticipationResultListRepository.findPaginatedByCampaignId({ @@ -1277,7 +1278,7 @@ describe('Integration | Repository | Campaign Assessment Participation Result Li }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); it('returns all participants if the filter is empty', async function () { diff --git a/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-profiles-collection-participation-summary-repository_test.js b/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-profiles-collection-participation-summary-repository_test.js index 991cf7f496f..0d39edf8dd5 100644 --- a/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-profiles-collection-participation-summary-repository_test.js +++ b/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-profiles-collection-participation-summary-repository_test.js @@ -4,7 +4,7 @@ import { CampaignParticipationStatuses, CampaignTypes, } from '../../../../../../src/prescription/shared/domain/constants.js'; -import { databaseBuilder, expect, mockLearningContent } from '../../../../../test-helper.js'; +import { databaseBuilder, expect } from '../../../../../test-helper.js'; const { STARTED, TO_SHARE, SHARED } = CampaignParticipationStatuses; @@ -1142,7 +1142,7 @@ const buildLearningContentData = () => { skills, }; - mockLearningContent(learningContent); + databaseBuilder.factory.learningContent.build(learningContent); return { competences, skills }; }; diff --git a/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-report-repository_test.js b/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-report-repository_test.js index af974767ede..e21f9daed68 100644 --- a/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-report-repository_test.js +++ b/api/tests/prescription/campaign/integration/infrastructure/repositories/campaign-report-repository_test.js @@ -22,7 +22,7 @@ describe('Integration | Repository | Campaign-Report', function () { ownerId: creator.id, multipleSendings: false, }); - mockLearningContent({ skills: [] }); + await mockLearningContent({ skills: [] }); await databaseBuilder.commit(); const result = await campaignReportRepository.get(campaign.id); @@ -61,7 +61,7 @@ describe('Integration | Repository | Campaign-Report', function () { }, }); - mockLearningContent({ skills: [] }); + await mockLearningContent({ skills: [] }); await databaseBuilder.commit(); const result = await campaignReportRepository.get(campaign.id); @@ -97,7 +97,7 @@ describe('Integration | Repository | Campaign-Report', function () { ], }; - mockLearningContent(learningContent); + databaseBuilder.factory.learningContent.build(learningContent); return databaseBuilder.commit(); }); @@ -190,7 +190,7 @@ describe('Integration | Repository | Campaign-Report', function () { const learningContent = { skills: [{ id: 'skill1' }] }; - mockLearningContent(learningContent); + databaseBuilder.factory.learningContent.build(learningContent); return databaseBuilder.commit(); }); diff --git a/api/tests/prescription/target-profile/acceptance/application/admin-target-profile-route_test.js b/api/tests/prescription/target-profile/acceptance/application/admin-target-profile-route_test.js index 557825f026f..40c2602d6af 100644 --- a/api/tests/prescription/target-profile/acceptance/application/admin-target-profile-route_test.js +++ b/api/tests/prescription/target-profile/acceptance/application/admin-target-profile-route_test.js @@ -59,7 +59,7 @@ describe('Acceptance | TargetProfile | Application | Route | admin-target-profil }; beforeEach(async function () { - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); describe('when there is no tube to update', function () { @@ -174,7 +174,7 @@ describe('Acceptance | TargetProfile | Application | Route | admin-target-profil }; beforeEach(async function () { - mockLearningContent(learningContent); + await mockLearningContent(learningContent); user = databaseBuilder.factory.buildUser.withRole(); }); @@ -374,8 +374,7 @@ describe('Acceptance | TargetProfile | Application | Route | admin-target-profil ], }, ]); - mockLearningContent(learningContent); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); targetProfileId = databaseBuilder.factory.buildTargetProfile({ name: 'Roxane est très jolie' }).id; databaseBuilder.factory.buildTargetProfileTube({ targetProfileId, tubeId: 'recTube2', level: 2 }); @@ -686,7 +685,7 @@ describe('Acceptance | TargetProfile | Application | Route | admin-target-profil }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); targetProfileId = databaseBuilder.factory.buildTargetProfile().id; user = databaseBuilder.factory.buildUser.withRole(); organizationId = databaseBuilder.factory.buildOrganization().id; @@ -726,7 +725,7 @@ describe('Acceptance | TargetProfile | Application | Route | admin-target-profil }, ], }; - mockLearningContent(learningContentForTest); + databaseBuilder.factory.learningContent.build(learningContentForTest); return databaseBuilder.commit(); }); @@ -867,7 +866,7 @@ describe('Acceptance | TargetProfile | Application | Route | admin-target-profil }, ], }; - mockLearningContent(learningContentForTest); + databaseBuilder.factory.learningContent.build(learningContentForTest); return databaseBuilder.commit(); }); diff --git a/api/tests/prescription/target-profile/acceptance/application/target-profile-route_test.js b/api/tests/prescription/target-profile/acceptance/application/target-profile-route_test.js index d5972ef28b4..a5c0709e59b 100644 --- a/api/tests/prescription/target-profile/acceptance/application/target-profile-route_test.js +++ b/api/tests/prescription/target-profile/acceptance/application/target-profile-route_test.js @@ -35,7 +35,7 @@ describe('Acceptance | Route | target-profile', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); user = databaseBuilder.factory.buildUser({}); linkedOrganization = databaseBuilder.factory.buildOrganization({}); @@ -259,7 +259,7 @@ describe('Acceptance | Route | target-profile', function () { userId = databaseBuilder.factory.buildUser().id; databaseBuilder.factory.buildMembership({ userId }); await databaseBuilder.commit(); - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should return response code 200', async function () { diff --git a/api/tests/prescription/target-profile/integration/infrastructure/repositories/target-profile-administration-repository_test.js b/api/tests/prescription/target-profile/integration/infrastructure/repositories/target-profile-administration-repository_test.js index 36edbda0635..337147f4246 100644 --- a/api/tests/prescription/target-profile/integration/infrastructure/repositories/target-profile-administration-repository_test.js +++ b/api/tests/prescription/target-profile/integration/infrastructure/repositories/target-profile-administration-repository_test.js @@ -107,7 +107,7 @@ describe('Integration | Repository | Target-profile', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const err = await catchErr(targetProfileAdministrationRepository.get)({ id: 1 }); @@ -352,7 +352,7 @@ describe('Integration | Repository | Target-profile', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualTargetProfile = await targetProfileAdministrationRepository.get({ id: 1 }); @@ -564,7 +564,7 @@ describe('Integration | Repository | Target-profile', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualTargetProfile = await targetProfileAdministrationRepository.get({ id: 1, locale: 'en' }); @@ -643,7 +643,7 @@ describe('Integration | Repository | Target-profile', function () { const learningContent = domainBuilder.buildCampaignLearningContent.withSimpleContent(); const learningContentObjects = learningContentBuilder([learningContent]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); // when const actualTargetProfile = await targetProfileAdministrationRepository.get({ id }); @@ -661,7 +661,7 @@ describe('Integration | Repository | Target-profile', function () { const learningContent = domainBuilder.buildCampaignLearningContent.withSimpleContent(); const learningContentObjects = learningContentBuilder([learningContent]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const { id: organizationId } = databaseBuilder.factory.buildOrganization({ id: constants.AUTONOMOUS_COURSES_ORGANIZATION_ID, @@ -691,7 +691,7 @@ describe('Integration | Repository | Target-profile', function () { const learningContent = domainBuilder.buildCampaignLearningContent.withSimpleContent(); const learningContentObjects = learningContentBuilder([learningContent]); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const { id: ownerOrganizationId } = databaseBuilder.factory.buildOrganization({ id: 9999 }); diff --git a/api/tests/school/acceptance/application/assessments/activity-answer-controller_test.js b/api/tests/school/acceptance/application/assessments/activity-answer-controller_test.js index bd7731bc687..dafd8b4a0b4 100644 --- a/api/tests/school/acceptance/application/assessments/activity-answer-controller_test.js +++ b/api/tests/school/acceptance/application/assessments/activity-answer-controller_test.js @@ -20,7 +20,7 @@ describe('Acceptance | Controller | activity-answer-controller', function () { databaseBuilder.factory.buildActivity({ assessmentId, stepIndex: 0, level: Activity.levels.VALIDATION }); await databaseBuilder.commit(); - mockLearningContentForMission(missionId); + await mockLearningContentForMission(missionId); const payload = { data: { @@ -66,7 +66,7 @@ describe('Acceptance | Controller | activity-answer-controller', function () { skills: [skill], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const payload = { data: { @@ -122,8 +122,8 @@ describe('Acceptance | Controller | activity-answer-controller', function () { }); }); -function mockLearningContentForMission(missionId) { - mockLearningContent({ +async function mockLearningContentForMission(missionId) { + await mockLearningContent({ skills: [ learningContentBuilder.buildSkill({ id: 'skill_id', diff --git a/api/tests/school/acceptance/application/assessments/assessment-controller_test.js b/api/tests/school/acceptance/application/assessments/assessment-controller_test.js index f460635456e..9c8408d6b01 100644 --- a/api/tests/school/acceptance/application/assessments/assessment-controller_test.js +++ b/api/tests/school/acceptance/application/assessments/assessment-controller_test.js @@ -73,7 +73,7 @@ describe('Acceptance | Controller | assessment-controller', function () { missions: [mission], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const postAssessmentRequest = { method: 'POST', @@ -116,7 +116,7 @@ describe('Acceptance | Controller | assessment-controller', function () { missions: [mission], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const learner = databaseBuilder.factory.buildOrganizationLearner(); const missionAssessment = databaseBuilder.factory.buildMissionAssessment({ diff --git a/api/tests/school/acceptance/application/challenge-route_test.js b/api/tests/school/acceptance/application/challenge-route_test.js index a68d3956337..a6005a35db4 100644 --- a/api/tests/school/acceptance/application/challenge-route_test.js +++ b/api/tests/school/acceptance/application/challenge-route_test.js @@ -15,7 +15,7 @@ describe('Integration | Controller | challenge-controller', function () { }); const skill = learningContentBuilder.buildSkill({ id: challenge.skillId }); - mockLearningContent({ + await mockLearningContent({ challenges: [challenge], skills: [skill], }); diff --git a/api/tests/school/integration/domain/services/correct-answer_test.js b/api/tests/school/integration/domain/services/correct-answer_test.js index 59b8d3d3ba5..df384b921b7 100644 --- a/api/tests/school/integration/domain/services/correct-answer_test.js +++ b/api/tests/school/integration/domain/services/correct-answer_test.js @@ -39,7 +39,7 @@ describe('Integration | UseCases | correct-answer', function () { skills: [skill], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); assessment = databaseBuilder.factory.buildAssessment({ state: Assessment.states.STARTED, @@ -199,7 +199,7 @@ describe('Integration | UseCases | correct-answer', function () { challenges: [challenge], skills: [skill], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const assessmentId = 10; const activityAnswer = domainBuilder.buildActivityAnswer({ diff --git a/api/tests/school/integration/domain/services/init-mission-activity_test.js b/api/tests/school/integration/domain/services/init-mission-activity_test.js index e20e35eecbb..d501b507460 100644 --- a/api/tests/school/integration/domain/services/init-mission-activity_test.js +++ b/api/tests/school/integration/domain/services/init-mission-activity_test.js @@ -45,7 +45,7 @@ describe('Integration | Usecase | init-mission-activity', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [learningContentBuilder.buildMission({ id: missionId })], }); @@ -96,7 +96,7 @@ describe('Integration | Usecase | init-mission-activity', function () { const lastActivity = domainBuilder.buildActivity(tutorialActivity); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -149,7 +149,7 @@ describe('Integration | Usecase | init-mission-activity', function () { const lastActivity = domainBuilder.buildActivity(firstStepValidationActivity); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -193,7 +193,7 @@ describe('Integration | Usecase | init-mission-activity', function () { const { assessmentId } = databaseBuilder.factory.buildMissionAssessment({ missionId }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, diff --git a/api/tests/school/integration/domain/services/update-current-activity_test.js b/api/tests/school/integration/domain/services/update-current-activity_test.js index 2dd87f603cb..826add70f5f 100644 --- a/api/tests/school/integration/domain/services/update-current-activity_test.js +++ b/api/tests/school/integration/domain/services/update-current-activity_test.js @@ -36,7 +36,7 @@ describe('Integration | UseCase | update current activity', function () { await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -98,7 +98,7 @@ describe('Integration | UseCase | update current activity', function () { await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -145,7 +145,7 @@ describe('Integration | UseCase | update current activity', function () { result: AnswerStatus.statuses.KO, }); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -194,7 +194,7 @@ describe('Integration | UseCase | update current activity', function () { await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -246,7 +246,7 @@ describe('Integration | UseCase | update current activity', function () { await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -292,7 +292,7 @@ describe('Integration | UseCase | update current activity', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, diff --git a/api/tests/school/integration/domain/usecases/correct-preview-answer_test.js b/api/tests/school/integration/domain/usecases/correct-preview-answer_test.js index c305e4d58f9..63fa3b080d8 100644 --- a/api/tests/school/integration/domain/usecases/correct-preview-answer_test.js +++ b/api/tests/school/integration/domain/usecases/correct-preview-answer_test.js @@ -20,7 +20,7 @@ describe('Integration | UseCases | correct-preview-answer', function () { skills: [skill], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const alwaysTrueExaminer = new Examiner({ validator: new ValidatorAlwaysOK() }); diff --git a/api/tests/school/integration/domain/usecases/find-all-active-missions_test.js b/api/tests/school/integration/domain/usecases/find-all-active-missions_test.js index a8341813709..2b4c66f7f2d 100644 --- a/api/tests/school/integration/domain/usecases/find-all-active-missions_test.js +++ b/api/tests/school/integration/domain/usecases/find-all-active-missions_test.js @@ -8,7 +8,7 @@ describe('Integration | UseCases | find-all-active-missions', function () { it('returns empty array without missions from LCMS', async function () { const expectedMissions = []; - mockLearningContent({ + await mockLearningContent({ missions: [], }); @@ -75,7 +75,7 @@ describe('Integration | UseCases | find-all-active-missions', function () { }, }; - mockLearningContent({ + await mockLearningContent({ missions: [validatedMission, experimentalMission, inactiveMission], areas: [area], competences: [competence], @@ -159,7 +159,7 @@ describe('Integration | UseCases | find-all-active-missions', function () { }, }; - mockLearningContent({ + await mockLearningContent({ missions: [validatedMission, experimentalMission, inactiveMission], areas: [area], competences: [competence], diff --git a/api/tests/school/integration/domain/usecases/get-mission_test.js b/api/tests/school/integration/domain/usecases/get-mission_test.js index 2351110c0cb..9d10d35570d 100644 --- a/api/tests/school/integration/domain/usecases/get-mission_test.js +++ b/api/tests/school/integration/domain/usecases/get-mission_test.js @@ -30,7 +30,7 @@ describe('Integration | UseCase | getMission', function () { const organizationId = databaseBuilder.factory.buildOrganization().id; - mockLearningContent({ + await mockLearningContent({ missions: [mission], areas: [area], competences: [{ id: 'competenceId', name_i18n: { fr: 'Name' }, index: '1.3' }], diff --git a/api/tests/school/integration/domain/usecases/get-next-challenge_test.js b/api/tests/school/integration/domain/usecases/get-next-challenge_test.js index ae2abc731bb..5430bb72317 100644 --- a/api/tests/school/integration/domain/usecases/get-next-challenge_test.js +++ b/api/tests/school/integration/domain/usecases/get-next-challenge_test.js @@ -65,7 +65,7 @@ describe('Integration | Usecase | get-next-challenge', function () { await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ challenges: [ learningContentBuilder.buildChallenge({ id: 'second_va_challenge_on_step_2_id', skillId: 'skill_id' }), ], diff --git a/api/tests/school/integration/domain/usecases/handle-activity-answer_test.js b/api/tests/school/integration/domain/usecases/handle-activity-answer_test.js index f4e1da32520..bb4645da6b4 100644 --- a/api/tests/school/integration/domain/usecases/handle-activity-answer_test.js +++ b/api/tests/school/integration/domain/usecases/handle-activity-answer_test.js @@ -51,7 +51,7 @@ describe('Integration | UseCase | handle activity answer', function () { }); await databaseBuilder.commit(); - mockLearningContentForMission(missionId); + await mockLearningContentForMission(missionId); await handleActivityAnswer({ activityAnswer, @@ -92,7 +92,7 @@ describe('Integration | UseCase | handle activity answer', function () { }); await databaseBuilder.commit(); - mockLearningContentForMission(missionId); + await mockLearningContentForMission(missionId); await handleActivityAnswer({ activityAnswer, @@ -134,7 +134,7 @@ describe('Integration | UseCase | handle activity answer', function () { await databaseBuilder.commit(); - mockLearningContentForMission(missionId); + await mockLearningContentForMission(missionId); await handleActivityAnswer({ activityAnswer, @@ -180,7 +180,7 @@ describe('Integration | UseCase | handle activity answer', function () { await databaseBuilder.commit(); - mockLearningContentForMission(missionId); + await mockLearningContentForMission(missionId); await handleActivityAnswer({ activityAnswer, @@ -221,7 +221,7 @@ describe('Integration | UseCase | handle activity answer', function () { }); await databaseBuilder.commit(); - mockLearningContentForMission(missionId); + await mockLearningContentForMission(missionId); await handleActivityAnswer({ activityAnswer, @@ -265,7 +265,7 @@ describe('Integration | UseCase | handle activity answer', function () { await databaseBuilder.commit(); - mockLearningContentForMission(missionId); + await mockLearningContentForMission(missionId); await handleActivityAnswer({ activityAnswer, @@ -306,7 +306,7 @@ describe('Integration | UseCase | handle activity answer', function () { }); await databaseBuilder.commit(); - mockLearningContentForMission(missionId); + await mockLearningContentForMission(missionId); await handleActivityAnswer({ activityAnswer, @@ -355,7 +355,7 @@ describe('Integration | UseCase | handle activity answer', function () { await databaseBuilder.commit(); - mockLearningContentForMission(missionId); + await mockLearningContentForMission(missionId); await handleActivityAnswer({ activityAnswer, @@ -397,7 +397,7 @@ describe('Integration | UseCase | handle activity answer', function () { }); await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ skills: [ learningContentBuilder.buildSkill({ id: 'skill_id', @@ -436,8 +436,8 @@ async function expectStatesAndLevel({ assessmentId, activityLevel, activityStatu expect(currentAssessment.state).to.equal(assessmentState); } -function mockLearningContentForMission(missionId) { - mockLearningContent({ +async function mockLearningContentForMission(missionId) { + await mockLearningContent({ skills: [ learningContentBuilder.buildSkill({ id: 'skill_id', diff --git a/api/tests/school/integration/domain/usecases/play-mission_test.js b/api/tests/school/integration/domain/usecases/play-mission_test.js index 6fc2b0d825a..9f1bb46c458 100644 --- a/api/tests/school/integration/domain/usecases/play-mission_test.js +++ b/api/tests/school/integration/domain/usecases/play-mission_test.js @@ -24,7 +24,7 @@ describe('Integration | UseCases | play-mission', function () { const organizationLearnerId = databaseBuilder.factory.buildOrganizationLearner().id; await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -60,7 +60,7 @@ describe('Integration | UseCases | play-mission', function () { const organizationLearnerId = databaseBuilder.factory.buildOrganizationLearner().id; await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -95,7 +95,7 @@ describe('Integration | UseCases | play-mission', function () { const organizationLearnerId = databaseBuilder.factory.buildOrganizationLearner().id; await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, @@ -130,7 +130,7 @@ describe('Integration | UseCases | play-mission', function () { const organizationLearnerId = databaseBuilder.factory.buildOrganizationLearner().id; await databaseBuilder.commit(); - mockLearningContent({ + await mockLearningContent({ missions: [ learningContentBuilder.buildMission({ id: missionId, diff --git a/api/tests/school/integration/infrastructure/repositories/mission-repository_test.js b/api/tests/school/integration/infrastructure/repositories/mission-repository_test.js index 5458d88ab8c..42d851cf8b4 100644 --- a/api/tests/school/integration/infrastructure/repositories/mission-repository_test.js +++ b/api/tests/school/integration/infrastructure/repositories/mission-repository_test.js @@ -28,7 +28,7 @@ describe('Integration | Repository | mission-repository', function () { }, }); - mockLearningContent({ + await mockLearningContent({ missions: [ { id: 1, @@ -62,7 +62,7 @@ describe('Integration | Repository | mission-repository', function () { context('when there is no mission for the given id', function () { it('should return the not found error', async function () { // given - mockLearningContent({ + await mockLearningContent({ thematics: [], }); const missionId = 'recThematic1'; @@ -101,7 +101,7 @@ describe('Integration | Repository | mission-repository', function () { }, }); - mockLearningContent({ + await mockLearningContent({ missions: [ { id: 1, diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-auto-validate-next-challenge_test.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-auto-validate-next-challenge_test.js index 7a1ca5eff08..750456bff14 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-auto-validate-next-challenge_test.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-auto-validate-next-challenge_test.js @@ -56,7 +56,7 @@ describe('Acceptance | API | assessment-controller-auto-validate-next-challenge' server = await createServer(); const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); afterEach(function () { diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-complete-assessment_test.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-complete-assessment_test.js index e4616e7445e..8ecb9b61722 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-complete-assessment_test.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-complete-assessment_test.js @@ -175,7 +175,7 @@ describe('Acceptance | Controller | assessment-controller-complete-assessment', index: '2.2', tubes: [ { - id: 'recTube4_0', + id: 'recTube5_0', skills: [ { id: 'recSkill5_0', @@ -191,7 +191,7 @@ describe('Acceptance | Controller | assessment-controller-complete-assessment', index: '2.3', tubes: [ { - id: 'recTube4_0', + id: 'recTube6_0', skills: [ { id: 'recSkill6_0', @@ -299,7 +299,7 @@ describe('Acceptance | Controller | assessment-controller-complete-assessment', index: '4.1', tubes: [ { - id: 'recTube4_0', + id: 'recTube12_0', skills: [ { id: 'recSkill12_0', @@ -386,7 +386,7 @@ describe('Acceptance | Controller | assessment-controller-complete-assessment', beforeEach(async function () { const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); server = await createServer(); diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-campaign-assessment_test.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-campaign-assessment_test.js index a0e8a72776a..d9e10f22e66 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-campaign-assessment_test.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-campaign-assessment_test.js @@ -70,7 +70,7 @@ describe('Acceptance | API | assessment-controller-get-next-challenge-for-campai beforeEach(async function () { server = await createServer(); const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); describe('GET /api/assessments/:assessment_id/next', function () { diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-certification_test.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-certification_test.js index f74a163f558..465df907842 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-certification_test.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-certification_test.js @@ -72,7 +72,7 @@ describe('Acceptance | API | assessment-controller-get-next-challenge-for-certif beforeEach(async function () { server = await createServer(); const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); describe('GET /api/assessments/:assessment_id/next', function () { diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-competence-evaluation_test.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-competence-evaluation_test.js index cf7aebeaac2..091f2c5f5bf 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-competence-evaluation_test.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-competence-evaluation_test.js @@ -71,7 +71,7 @@ describe('Acceptance | API | assessment-controller-get-next-challenge-for-compet beforeEach(async function () { server = await createServer(); const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); describe('GET /api/assessments/:assessment_id/next', function () { diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-demo_test.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-demo_test.js index e29fb1fd904..70bfc17a02c 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-demo_test.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-for-demo_test.js @@ -46,7 +46,7 @@ describe('Acceptance | API | assessment-controller-get-next-challenge-for-demo', ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); describe('(demo) GET /api/assessments/:assessment_id/next', function () { diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-locale-management.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-locale-management.js index 3d2a97f2509..573c935eecd 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-locale-management.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-get-next-challenge-locale-management.js @@ -70,7 +70,7 @@ describe('Acceptance | API | assessment-controller-get-next-challenge-locale-man context('when there is one challenge in the accepted language (fr-fr)', function () { beforeEach(async function () { const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); databaseBuilder.factory.buildUser({ id: userId }); databaseBuilder.factory.buildAssessment({ diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-get_test.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-get_test.js index 7b64a87a892..c87b34a0ff7 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-get_test.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-get_test.js @@ -77,7 +77,7 @@ describe('Acceptance | API | assessment-controller-get', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); const assessmentId = databaseBuilder.factory.buildAssessment({ userId: null, diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-pause-assessment_test.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-pause-assessment_test.js index 46531cdf5d0..30d4ad82307 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-pause-assessment_test.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-pause-assessment_test.js @@ -56,7 +56,7 @@ describe('Acceptance | API | assessment-controller-pause-assessment', function ( }, }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); return databaseBuilder.commit(); }); diff --git a/api/tests/shared/acceptance/application/assessments/assessment-controller-update-last-challenge-state_test.js b/api/tests/shared/acceptance/application/assessments/assessment-controller-update-last-challenge-state_test.js index bdd880c77bd..1fd72365329 100644 --- a/api/tests/shared/acceptance/application/assessments/assessment-controller-update-last-challenge-state_test.js +++ b/api/tests/shared/acceptance/application/assessments/assessment-controller-update-last-challenge-state_test.js @@ -57,7 +57,7 @@ describe('Acceptance | API | assessment-controller-update-last-challenge-state', beforeEach(async function () { server = await createServer(); const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); describe('PATCH /api/assessments/{id}/last-challenge-state/{state}', function () { diff --git a/api/tests/shared/acceptance/application/challenges/challenge-controller_test.js b/api/tests/shared/acceptance/application/challenges/challenge-controller_test.js index f0430c4363c..d95058691d0 100644 --- a/api/tests/shared/acceptance/application/challenges/challenge-controller_test.js +++ b/api/tests/shared/acceptance/application/challenges/challenge-controller_test.js @@ -18,7 +18,7 @@ describe('Acceptance | API | ChallengeController', function () { const challengeId = 'recLt9uwa2dR3IYpi'; const challengeType = 'QCM'; - beforeEach(function () { + beforeEach(async function () { const learningContent = [ { id: 'recArea0', @@ -51,7 +51,7 @@ describe('Acceptance | API | ChallengeController', function () { }, ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + await mockLearningContent(learningContentObjects); }); const options = { diff --git a/api/tests/shared/acceptance/application/lcms/lcms-controller_test.js b/api/tests/shared/acceptance/application/lcms/lcms-controller_test.js index e45906ac336..82fc2bd4d40 100644 --- a/api/tests/shared/acceptance/application/lcms/lcms-controller_test.js +++ b/api/tests/shared/acceptance/application/lcms/lcms-controller_test.js @@ -69,7 +69,7 @@ describe('Acceptance | Controller | lcms-controller', function () { it('should store patches in Redis', async function () { // given - mockLearningContent({ frameworks: [{ id: `frameworkId` }] }); + await mockLearningContent({ frameworks: [{ id: `frameworkId` }] }); const superAdminUserId = databaseBuilder.factory.buildUser.withRole({ role: ROLES.SUPER_ADMIN, }).id; diff --git a/api/tests/shared/integration/domain/services/placement-profile-service_test.js b/api/tests/shared/integration/domain/services/placement-profile-service_test.js index 9a2b6a15fbe..41c6dd0fa93 100644 --- a/api/tests/shared/integration/domain/services/placement-profile-service_test.js +++ b/api/tests/shared/integration/domain/services/placement-profile-service_test.js @@ -1,7 +1,7 @@ import { LOCALE } from '../../../../../src/shared/domain/constants.js'; import { KnowledgeElement } from '../../../../../src/shared/domain/models/KnowledgeElement.js'; import * as placementProfileService from '../../../../../src/shared/domain/services/placement-profile-service.js'; -import { databaseBuilder, expect, learningContentBuilder, mockLearningContent } from '../../../../test-helper.js'; +import { databaseBuilder, expect, learningContentBuilder } from '../../../../test-helper.js'; const { ENGLISH_SPOKEN } = LOCALE; @@ -28,7 +28,6 @@ describe('Shared | Integration | Domain | Services | Placement Profile Service', id: 'recCitation4', nom: '@citation4', pixValue: 1, - challenges: ['challengeRecordIdOne', 'challengeRecordIdTwo', 'challengeRecordIdTen'], version: 1, level: 4, }, @@ -48,7 +47,6 @@ describe('Shared | Integration | Domain | Services | Placement Profile Service', id: 'recRemplir2', nom: '@remplir2', pixValue: 1, - challenges: ['challengeRecordIdOne', 'challengeRecordIdFive'], version: 1, level: 2, }, @@ -56,7 +54,6 @@ describe('Shared | Integration | Domain | Services | Placement Profile Service', id: 'recRemplir4', nom: '@remplir4', pixValue: 1, - challenges: ['challengeRecordIdSix'], version: 1, level: 4, }, @@ -76,7 +73,6 @@ describe('Shared | Integration | Domain | Services | Placement Profile Service', id: 'recRequin5', nom: '@requin5', pixValue: 1, - challenges: ['challengeRecordIdNine'], version: 1, level: 5, }, @@ -89,7 +85,7 @@ describe('Shared | Integration | Domain | Services | Placement Profile Service', ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + databaseBuilder.factory.learningContent.build(learningContentObjects); userId = databaseBuilder.factory.buildUser().id; assessmentId = databaseBuilder.factory.buildAssessment({ userId }).id; diff --git a/api/tests/shared/integration/infrastructure/caches/learning-content-cache_test.js b/api/tests/shared/integration/infrastructure/caches/learning-content-cache_test.js index 95bc25a68c0..ad68943366d 100644 --- a/api/tests/shared/integration/infrastructure/caches/learning-content-cache_test.js +++ b/api/tests/shared/integration/infrastructure/caches/learning-content-cache_test.js @@ -8,7 +8,7 @@ describe('Integration | Infrastructure | Caches | LearningContentCache', functio it('should get learning content from underlying cache (redis not used in test)', async function () { // given const learningContent = { models: [{ id: 'recId' }] }; - const lcmsApiCall = mockLearningContent(learningContent); + const lcmsApiCall = await mockLearningContent(learningContent); // when const result = await learningContentCache.get(); @@ -23,7 +23,7 @@ describe('Integration | Infrastructure | Caches | LearningContentCache', functio it('should set learning content in underlying cache', async function () { // given const learningContent = { models: [{ id: 'recId' }] }; - const lcmsApiCall = mockLearningContent(learningContent); + const lcmsApiCall = await mockLearningContent(learningContent); const underlyingCacheSpy = sinon.spy(learningContentCache._underlyingCache, 'set'); // when diff --git a/api/tests/shared/integration/infrastructure/datasources/learning-content/area-datasource_test.js b/api/tests/shared/integration/infrastructure/datasources/learning-content/area-datasource_test.js index a3897e0ea4b..46715fa58c5 100644 --- a/api/tests/shared/integration/infrastructure/datasources/learning-content/area-datasource_test.js +++ b/api/tests/shared/integration/infrastructure/datasources/learning-content/area-datasource_test.js @@ -6,7 +6,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | AreaDat it('should return an array of matching learning content area data objects', async function () { // given const records = [{ id: 'recArea0' }, { id: 'recArea1' }, { id: 'recArea2' }]; - mockLearningContent({ areas: records }); + await mockLearningContent({ areas: records }); const expectedAreaIds = ['recArea0', 'recArea1']; // when @@ -18,7 +18,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | AreaDat it('should return an empty array when there are no objects matching the ids', async function () { // given const records = [{ id: 'recArea0' }]; - mockLearningContent({ areas: records }); + await mockLearningContent({ areas: records }); // when const foundAreas = await areaDatasource.findByRecordIds(['some_other_id']); @@ -45,7 +45,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | AreaDat competenceIds: ['competenceId_4'], }, ]; - mockLearningContent({ areas }); + await mockLearningContent({ areas }); // when const foundArea = await areaDatasource.findOneFromCompetenceId('competenceId_1'); @@ -64,11 +64,11 @@ describe('Integration | Infrastructure | Datasource | Learning Content | AreaDat competenceIds: ['competenceId_1', 'competenceId_2', 'competenceId_3'], }, { - id: 'area_1', + id: 'area_2', competenceIds: ['competenceId_4'], }, ]; - mockLearningContent({ areas }); + await mockLearningContent({ areas }); // when const foundArea = await areaDatasource.findOneFromCompetenceId('competenceId_10'); @@ -85,7 +85,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | AreaDat { id: 'recArea1', frameworkId: 'framework2' }, { id: 'recArea2', frameworkId: 'framework1' }, ]; - mockLearningContent({ areas: records }); + await mockLearningContent({ areas: records }); const expectedAreaIds = ['recArea0', 'recArea2']; const frameworkId = 'framework1'; diff --git a/api/tests/shared/integration/infrastructure/datasources/learning-content/challenge-datasource_test.js b/api/tests/shared/integration/infrastructure/datasources/learning-content/challenge-datasource_test.js index d10c7303b92..9030916a5fe 100644 --- a/api/tests/shared/integration/infrastructure/datasources/learning-content/challenge-datasource_test.js +++ b/api/tests/shared/integration/infrastructure/datasources/learning-content/challenge-datasource_test.js @@ -39,7 +39,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen delta: -3.56, }; challenge_competence1_en = { - id: 'challenge-competence1', + id: 'challenge-competence1-en', competenceId: competence1.id, skillId: web1.id, status: 'validé', @@ -130,8 +130,8 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen }); describe('#listBylocale', function () { - beforeEach(function () { - mockLearningContent({ + beforeEach(async function () { + await mockLearningContent({ challenges: [challenge_web1, challenge_web1_notValidated, challenge_web2_en, challenge_web3], }); }); @@ -153,8 +153,8 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen }); describe('#getManyByLocale', function () { - beforeEach(function () { - mockLearningContent({ + beforeEach(async function () { + await mockLearningContent({ challenges: [challenge_web1, challenge_web1_notValidated, challenge_web2_en, challenge_web3], }); }); @@ -177,8 +177,8 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen }); describe('#findOperativeBySkillIds', function () { - beforeEach(function () { - mockLearningContent({ + beforeEach(async function () { + await mockLearningContent({ challenges: [challenge_web1, challenge_web1_notValidated, challenge_web2_en, challenge_web3], }); }); @@ -201,7 +201,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen beforeEach(async function () { // given - mockLearningContent({ + await mockLearningContent({ challenges: [ challenge_competence1, challenge_competence1_en, @@ -225,7 +225,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen it('should retrieve the operative Challenges of given locale only', async function () { // given const locale = 'fr-fr'; - mockLearningContent({ + await mockLearningContent({ challenges: [challenge_web1, challenge_web1_notValidated, challenge_web2_en, challenge_web3_archived], }); @@ -238,8 +238,8 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen }); describe('#findValidated', function () { - beforeEach(function () { - mockLearningContent({ + beforeEach(async function () { + await mockLearningContent({ challenges: [challenge_web1, challenge_web1_notValidated, challenge_web2_en, challenge_web3_archived], }); }); @@ -254,8 +254,8 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen }); describe('#findFlashCompatible', function () { - beforeEach(function () { - mockLearningContent({ + beforeEach(async function () { + await mockLearningContent({ challenges: [ challenge_competence1, challenge_competence1_notValidated, @@ -305,8 +305,8 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen }); describe('#findFlashCompatibleWithoutLocale', function () { - beforeEach(function () { - mockLearningContent({ + beforeEach(async function () { + await mockLearningContent({ challenges: [ challenge_competence1, challenge_competence1_notValidated, @@ -357,8 +357,8 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen }); describe('#findActiveFlashCompatible', function () { - beforeEach(function () { - mockLearningContent({ + beforeEach(async function () { + await mockLearningContent({ challenges: [ challenge_competence1, challenge_competence1_noSkills, @@ -389,8 +389,8 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen }); describe('#findValidatedBySkillId', function () { - beforeEach(function () { - mockLearningContent({ + beforeEach(async function () { + await mockLearningContent({ challenges: [challenge_web1, challenge_web1_notValidated, challenge_web1_archived, challenge_competence2], }); }); @@ -414,21 +414,21 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen beforeEach(function () { validated_challenge_pix1d = { - id: 'challenge-competence1', + id: 'challenge-pix1d1', competenceId: competence1.id, locales: ['fr'], skillId, status: 'validé', }; proposed_challenge_pix1d = { - id: 'challenge-competence2', + id: 'challenge-pix1d2', competenceId: competence1.id, locales: ['fr'], status: 'proposé', skillId, }; obsolete_challenge_pix1d = { - id: 'challenge-competence3', + id: 'challenge-pix1d3', competenceId: competence1.id, locales: ['fr'], status: 'périmé', @@ -439,7 +439,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen context('when there are several challenges for the skillId', function () { it('should return an array of validated or proposed challenges', async function () { // when - mockLearningContent({ + await mockLearningContent({ challenges: [ challenge_web1, challenge_competence2, @@ -458,7 +458,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen context('when there is only one challenge for the skillId', function () { it('should return a challenge from learning content', async function () { // when - mockLearningContent({ + await mockLearningContent({ challenges: [challenge_web1, challenge_competence2, validated_challenge_pix1d], }); const result = await challengeDatasource.getBySkillId(skillId, locale); @@ -470,7 +470,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Challen it('should return an error if there is no challenge for the given skillId', async function () { // when - mockLearningContent({ + await mockLearningContent({ challenges: [challenge_web1, challenge_competence2, validated_challenge_pix1d, proposed_challenge_pix1d], }); const error = await catchErr(challengeDatasource.getBySkillId, locale)('falseId'); diff --git a/api/tests/shared/integration/infrastructure/datasources/learning-content/competence-datasource_test.js b/api/tests/shared/integration/infrastructure/datasources/learning-content/competence-datasource_test.js index 6605162503f..49b4c307089 100644 --- a/api/tests/shared/integration/infrastructure/datasources/learning-content/competence-datasource_test.js +++ b/api/tests/shared/integration/infrastructure/datasources/learning-content/competence-datasource_test.js @@ -11,7 +11,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Compete const rawCompetence4 = { id: 'RECORD_ID_RAW_COMPETENCE_4' }; const records = [rawCompetence1, rawCompetence2, rawCompetence3, rawCompetence4]; - mockLearningContent({ competences: records }); + await mockLearningContent({ competences: records }); const expectedCompetenceIds = [rawCompetence1.id, rawCompetence2.id, rawCompetence4.id]; // when @@ -25,7 +25,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Compete const rawCompetence1 = { id: 'RECORD_ID_RAW_COMPETENCE_1' }; const records = [rawCompetence1]; - mockLearningContent({ competences: records }); + await mockLearningContent({ competences: records }); // when const foundCompetences = await competenceDatasource.findByRecordIds(['some_other_id']); diff --git a/api/tests/shared/integration/infrastructure/datasources/learning-content/skill-datasource_test.js b/api/tests/shared/integration/infrastructure/datasources/learning-content/skill-datasource_test.js index 067d926330a..818e56b31dd 100644 --- a/api/tests/shared/integration/infrastructure/datasources/learning-content/skill-datasource_test.js +++ b/api/tests/shared/integration/infrastructure/datasources/learning-content/skill-datasource_test.js @@ -13,7 +13,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat const rawSkill4 = { id: 'recSkill4', status: 'périmé' }; const records = [rawSkill1, rawSkill2, rawSkill3, rawSkill4]; - mockLearningContent({ skills: records }); + await mockLearningContent({ skills: records }); // when const foundSkills = await skillDatasource.findOperativeByRecordIds([rawSkill1.id, rawSkill2.id, rawSkill4.id]); @@ -33,7 +33,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat const rawSkill4 = { id: 'recSkill4', status: 'périmé' }; const records = [rawSkill1, rawSkill2, rawSkill3, rawSkill4]; - mockLearningContent({ skills: records }); + await mockLearningContent({ skills: records }); // when const foundSkills = await skillDatasource.findByRecordIds([rawSkill1.id, rawSkill2.id, rawSkill4.id]); @@ -52,7 +52,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat const rawSkill3 = { id: 'recSkill3', name: '@rechercher_entrainement1', status: 'en construction' }; const rawSkill4 = { id: 'recSkill4', name: '@rechercher_didacticiel2', status: 'actif' }; const rawSkill5 = { id: 'recSkill5', name: '@rechercher_didacticiel12', status: 'en construction' }; - mockLearningContent({ skills: [rawSkill1, rawSkill2, rawSkill3, rawSkill4, rawSkill5] }); + await mockLearningContent({ skills: [rawSkill1, rawSkill2, rawSkill3, rawSkill4, rawSkill5] }); // when const result = await skillDatasource.findAllSkillsByNameForPix1d('@rechercher_didacticiel1'); @@ -66,7 +66,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat const rawSkill1 = { id: 'recSkill1', name: '@rechercher_didacticiel1', status: 'actif' }; const rawSkill2 = { id: 'recSkill2', name: '@rechercher_didacticiel1', status: 'en construction' }; const rawSkill3 = { id: 'recSkill3', name: '@rechercher_didacticiel1', status: 'archivé' }; - mockLearningContent({ skills: [rawSkill1, rawSkill2, rawSkill3] }); + await mockLearningContent({ skills: [rawSkill1, rawSkill2, rawSkill3] }); // when const result = await skillDatasource.findAllSkillsByNameForPix1d('@rechercher_didacticiel1'); @@ -78,7 +78,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat context('when there is no skill found', function () { it('should return an empty array', async function () { // given - mockLearningContent({ skills: [] }); + await mockLearningContent({ skills: [] }); // when const result = await skillDatasource.findAllSkillsByNameForPix1d('@rechercher_validation'); @@ -94,7 +94,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat // given const rawSkill1 = { id: 'recSkill1', status: 'actif' }, rawSkill2 = { id: 'recSkill2', status: 'actif' }; - mockLearningContent({ skills: [rawSkill1, rawSkill2] }); + await mockLearningContent({ skills: [rawSkill1, rawSkill2] }); // when const foundSkills = await skillDatasource.findActive(); @@ -108,7 +108,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat const rawSkill1 = { id: 'recSkill1', status: 'actif' }, rawSkill2 = { id: 'recSkill2', status: 'actif' }, rawSkill3 = { id: 'recSkill3', status: 'périmé' }; - mockLearningContent({ skills: [rawSkill1, rawSkill2, rawSkill3] }); + await mockLearningContent({ skills: [rawSkill1, rawSkill2, rawSkill3] }); // when const foundSkills = await skillDatasource.findActive(); @@ -123,7 +123,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat // given const rawSkill1 = { id: 'recSkill1', status: 'actif' }, rawSkill2 = { id: 'recSkill2', status: 'actif' }; - mockLearningContent({ skills: [rawSkill1, rawSkill2] }); + await mockLearningContent({ skills: [rawSkill1, rawSkill2] }); // when const foundSkills = await skillDatasource.findOperative(); @@ -137,7 +137,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat const rawSkill1 = { id: 'recSkill1', status: 'actif' }, rawSkill2 = { id: 'recSkill2', status: 'archivé' }, rawSkill3 = { id: 'recSkill3', status: 'périmé' }; - mockLearningContent({ skills: [rawSkill1, rawSkill2, rawSkill3] }); + await mockLearningContent({ skills: [rawSkill1, rawSkill2, rawSkill3] }); // when const foundSkills = await skillDatasource.findOperative(); @@ -148,12 +148,12 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat }); describe('#findActiveByCompetenceId', function () { - beforeEach(function () { + beforeEach(async function () { const skill1 = { id: 'recSkill1', status: 'actif', competenceId: 'recCompetence' }; const skill2 = { id: 'recSkill2', status: 'actif', competenceId: 'recCompetence' }; const skill3 = { id: 'recSkill3', status: 'périmé', competenceId: 'recCompetence' }; const skill4 = { id: 'recSkill4', status: 'actif', competenceId: 'recOtherCompetence' }; - mockLearningContent({ skills: [skill1, skill2, skill3, skill4] }); + await mockLearningContent({ skills: [skill1, skill2, skill3, skill4] }); }); it('should retrieve all skills from learning content for one competence', async function () { @@ -166,12 +166,12 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat }); describe('#findActiveByTubeId', function () { - beforeEach(function () { + beforeEach(async function () { const skill1 = { id: 'recSkill1', status: 'actif', competenceId: 'recCompetence', tubeId: 'recTube' }; const skill2 = { id: 'recSkill2', status: 'actif', competenceId: 'recCompetence', tubeId: 'recTube' }; const skill3 = { id: 'recSkill3', status: 'périmé', competenceId: 'recCompetence', tubeId: 'recTube' }; const skill4 = { id: 'recSkill4', status: 'actif', competenceId: 'recOtherCompetence', tubeId: 'recOtherTube' }; - mockLearningContent({ skills: [skill1, skill2, skill3, skill4] }); + await mockLearningContent({ skills: [skill1, skill2, skill3, skill4] }); }); it('should retrieve all skills from learning content for one competence', async function () { @@ -184,7 +184,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat }); describe('#findByTubeIdFor1d', function () { - beforeEach(function () { + beforeEach(async function () { const skillActive = { id: 'recSkillActive', status: 'actif', competenceId: 'recCompetence', tubeId: 'recTube' }; const skillInBuild = { id: 'recSkillInBuild', @@ -204,7 +204,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat competenceId: 'recOtherCompetence', tubeId: 'recOtherTube', }; - mockLearningContent({ skills: [skillActive, skillInBuild, skillExpired, skillOtherTube] }); + await mockLearningContent({ skills: [skillActive, skillInBuild, skillExpired, skillOtherTube] }); }); it('should retrieve all skills from learning content for one competence', async function () { @@ -217,12 +217,12 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat }); describe('#findOperativeByCompetenceId', function () { - beforeEach(function () { + beforeEach(async function () { const skill1 = { id: 'recSkill1', status: 'actif', competenceId: 'recCompetence' }; const skill2 = { id: 'recSkill2', status: 'archivé', competenceId: 'recCompetence' }; const skill3 = { id: 'recSkill3', status: 'périmé', competenceId: 'recCompetence' }; const skill4 = { id: 'recSkill4', status: 'actif', competenceId: 'recOtherCompetence' }; - mockLearningContent({ skills: [skill1, skill2, skill3, skill4] }); + await mockLearningContent({ skills: [skill1, skill2, skill3, skill4] }); }); it('should retrieve all skills from learning content for one competence', async function () { @@ -235,7 +235,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat }); describe('#findOperativeByCompetenceIds', function () { - beforeEach(function () { + beforeEach(async function () { const skill1 = { id: 'recSkill1', status: 'actif', competenceId: 'recCompetence1' }; const skill2 = { id: 'recSkill2', status: 'archivé', competenceId: 'recCompetence1' }; const skill3 = { id: 'recSkill3', status: 'périmé', competenceId: 'recCompetence1' }; @@ -243,7 +243,7 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat const skill5 = { id: 'recSkill5', status: 'actif', competenceId: 'recCompetence2' }; const skill6 = { id: 'recSkill6', status: 'archivé', competenceId: 'recCompetence2' }; const skill7 = { id: 'recSkill7', status: 'périmé', competenceId: 'recCompetence2' }; - mockLearningContent({ skills: [skill1, skill2, skill3, skill4, skill5, skill6, skill7] }); + await mockLearningContent({ skills: [skill1, skill2, skill3, skill4, skill5, skill6, skill7] }); }); it('should retrieve all skills from learning content for competences', async function () { @@ -256,12 +256,12 @@ describe('Integration | Infrastructure | Datasource | LearningContent | SkillDat }); describe('#findOperativeByTubeId', function () { - beforeEach(function () { + beforeEach(async function () { const skill1 = { id: 'recSkill1', status: 'actif', tubeId: 'recTube' }; const skill2 = { id: 'recSkill2', status: 'archivé', tubeId: 'recTube' }; const skill3 = { id: 'recSkill3', status: 'périmé', tubeId: 'recTube' }; const skill4 = { id: 'recSkill4', status: 'actif', tubeId: 'recOtherTube' }; - mockLearningContent({ skills: [skill1, skill2, skill3, skill4] }); + await mockLearningContent({ skills: [skill1, skill2, skill3, skill4] }); }); it('should retrieve all operative skills from learning content for one tube', async function () { diff --git a/api/tests/shared/integration/infrastructure/datasources/learning-content/thematic-datasource_test.js b/api/tests/shared/integration/infrastructure/datasources/learning-content/thematic-datasource_test.js index 06ee9864bfb..932367b11b2 100644 --- a/api/tests/shared/integration/infrastructure/datasources/learning-content/thematic-datasource_test.js +++ b/api/tests/shared/integration/infrastructure/datasources/learning-content/thematic-datasource_test.js @@ -11,7 +11,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Themati { id: 'recThematic3', competenceId: 'competence3' }, { id: 'recThematic2', competenceId: 'competence1' }, ]; - mockLearningContent({ thematics: records }); + await mockLearningContent({ thematics: records }); const expectedThematicIds = ['recThematic0', 'recThematic1', 'recThematic2']; const competenceIds = ['competence1', 'competence2']; @@ -26,7 +26,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | Themati it('should return an array of matching learning content thematics data objects by ids', async function () { // given const records = [{ id: 'recThematic0' }, { id: 'recThematic1' }, { id: 'recThematic3' }, { id: 'recThematic2' }]; - mockLearningContent({ thematics: records }); + await mockLearningContent({ thematics: records }); // when const foundThematics = await thematicDatasource.findByRecordIds(['recThematic1', 'recThematic3']); diff --git a/api/tests/shared/integration/infrastructure/datasources/learning-content/tube-datasource_test.js b/api/tests/shared/integration/infrastructure/datasources/learning-content/tube-datasource_test.js index 49d7116eb12..58a47364920 100644 --- a/api/tests/shared/integration/infrastructure/datasources/learning-content/tube-datasource_test.js +++ b/api/tests/shared/integration/infrastructure/datasources/learning-content/tube-datasource_test.js @@ -13,7 +13,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | TubeDat const rawTube4 = { id: 'rectTube4', name: 'FAKE_NAME_RAW_TUBE_4' }; const records = [rawTube1, rawTube2, rawTube3, rawTube4]; - mockLearningContent({ tubes: records }); + await mockLearningContent({ tubes: records }); // when const foundTubes = await tubeDatasource.findByNames([rawTube1.name, rawTube2.name, rawTube4.name]); @@ -33,7 +33,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | TubeDat const rawTube4 = { id: 'RECORD_ID_RAW_TUBE_4' }; const records = [rawTube1, rawTube2, rawTube3, rawTube4]; - mockLearningContent({ tubes: records }); + await mockLearningContent({ tubes: records }); const expectedTubeIds = [rawTube1.id, rawTube2.id, rawTube4.id]; // when @@ -47,7 +47,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | TubeDat const rawTube1 = { id: 'RECORD_ID_RAW_TUBE_1' }; const records = [rawTube1]; - mockLearningContent({ tubes: records }); + await mockLearningContent({ tubes: records }); // when const foundTubes = await tubeDatasource.findByRecordIds(['some_other_id']); @@ -66,7 +66,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | TubeDat const rawTube4 = { id: 'RECORD_ID_RAW_TUBE_4', thematicId: 'thematicId1' }; const records = [rawTube1, rawTube2, rawTube3, rawTube4]; - mockLearningContent({ tubes: records }); + await mockLearningContent({ tubes: records }); const expectedTubeIds = [rawTube1.id, rawTube2.id, rawTube4.id]; // when @@ -80,7 +80,7 @@ describe('Integration | Infrastructure | Datasource | Learning Content | TubeDat const rawTube1 = { id: 'RECORD_ID_RAW_TUBE_1', thematicId: 'thematicId2' }; const records = [rawTube1]; - mockLearningContent({ tubes: records }); + await mockLearningContent({ tubes: records }); // when const foundTubes = await tubeDatasource.findByThematicId('thematicId1'); diff --git a/api/tests/shared/integration/infrastructure/lcms-client_test.js b/api/tests/shared/integration/infrastructure/lcms-client_test.js index ca27266eaa6..54824feca76 100644 --- a/api/tests/shared/integration/infrastructure/lcms-client_test.js +++ b/api/tests/shared/integration/infrastructure/lcms-client_test.js @@ -6,7 +6,7 @@ describe('Integration | Infrastructure | LCMS Client', function () { it('calls LCMS API to get learning content latest release', async function () { // given const learningContent = { models: [{ id: 'recId' }] }; - const lcmsCall = mockLearningContent(learningContent); + const lcmsCall = await mockLearningContent(learningContent); // when const response = await lcmsClient.getLatestRelease(); diff --git a/api/tests/shared/integration/infrastructure/repositories/challenge-repository_test.js b/api/tests/shared/integration/infrastructure/repositories/challenge-repository_test.js index 3cdd864ba6c..9c9d08b3d38 100644 --- a/api/tests/shared/integration/infrastructure/repositories/challenge-repository_test.js +++ b/api/tests/shared/integration/infrastructure/repositories/challenge-repository_test.js @@ -21,7 +21,7 @@ describe('Integration | Repository | challenge-repository', function () { challenges: [{ ...challenge, skillId: 'recSkill1', alpha: 1, delta: 0 }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const expectedChallenge = domainBuilder.buildChallenge({ ...challenge, @@ -46,11 +46,9 @@ describe('Integration | Repository | challenge-repository', function () { const learningContent = { skills: [{ ...skill, status: 'actif' }], - challenges: [ - { ...challenge, skillId: 'recSkill1', t1Status: 'Activé', t2Status: 'Activé', t3Status: 'Désactivé' }, - ], + challenges: [{ ...challenge, skillId: 'recSkill1', t1Status: true, t2Status: true, t3Status: false }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualChallenge = await challengeRepository.get(challenge.id); @@ -83,7 +81,7 @@ describe('Integration | Repository | challenge-repository', function () { challenges: [{ ...challenge, skillId: 'recSkill1', alpha: 1, delta: 0 }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); const expectedChallenge = domainBuilder.buildChallengeWithWebComponent({ ...challenge, @@ -129,7 +127,7 @@ describe('Integration | Repository | challenge-repository', function () { ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const error = await catchErr(challengeRepository.get)(challengeId); @@ -167,7 +165,7 @@ describe('Integration | Repository | challenge-repository', function () { { ...challenge4, skillId: 'recSkill4' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualChallenges = await challengeRepository.getMany(['recChal1', 'recChal2', 'recChal4'], 'fr'); @@ -199,7 +197,7 @@ describe('Integration | Repository | challenge-repository', function () { { ...challenge3, skillId: 'recSkill3' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const error = await catchErr(challengeRepository.getMany)(['someChallengeId'], 'fr'); @@ -234,7 +232,7 @@ describe('Integration | Repository | challenge-repository', function () { { ...challenge4, locales: ['fr-fr'], skillId: 'recSkill4' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualChallenges = await challengeRepository.list('fr'); @@ -254,8 +252,8 @@ describe('Integration | Repository | challenge-repository', function () { it('should return only validated challenges with skills', async function () { // given const skill = domainBuilder.buildSkill({ id: 'recSkill1' }); - const validatedChallenge = domainBuilder.buildChallenge({ skill, status: 'validé' }); - const nonValidatedChallenge = domainBuilder.buildChallenge({ skill, status: 'PAS validé' }); + const validatedChallenge = domainBuilder.buildChallenge({ id: 'recChallenge1', skill, status: 'validé' }); + const nonValidatedChallenge = domainBuilder.buildChallenge({ id: 'recChallenge2', skill, status: 'PAS validé' }); const learningContent = { skills: [{ ...skill, status: 'actif', level: skill.difficulty }], challenges: [ @@ -263,7 +261,7 @@ describe('Integration | Repository | challenge-repository', function () { { ...nonValidatedChallenge, skillId: 'recSkill1' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualChallenges = await challengeRepository.findValidated('fr'); @@ -288,13 +286,13 @@ describe('Integration | Repository | challenge-repository', function () { { ...validatedChallenge, skillId: 'recSkill1', - t1Status: 'Activé', - t2Status: 'Activé', - t3Status: 'Désactivé', + t1Status: true, + t2Status: true, + t3Status: false, }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const [actualChallenge] = await challengeRepository.findValidated('fr'); @@ -314,8 +312,8 @@ describe('Integration | Repository | challenge-repository', function () { it('should return only french france operative challenges with skills', async function () { // given const skill = domainBuilder.buildSkill({ id: 'recSkill1' }); - const frfrOperativeChallenge = domainBuilder.buildChallenge({ skill, locales: ['fr-fr'] }); - const nonFrfrOperativeChallenge = domainBuilder.buildChallenge({ skill, locales: ['en'] }); + const frfrOperativeChallenge = domainBuilder.buildChallenge({ id: 'recChallenge1', skill, locales: ['fr-fr'] }); + const nonFrfrOperativeChallenge = domainBuilder.buildChallenge({ id: 'recChallenge2', skill, locales: ['en'] }); const locale = 'fr-fr'; const learningContent = { skills: [{ ...skill, status: 'actif', level: skill.difficulty }], @@ -324,7 +322,7 @@ describe('Integration | Repository | challenge-repository', function () { { ...nonFrfrOperativeChallenge, skillId: 'recSkill1' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualChallenges = await challengeRepository.findOperative(locale); @@ -341,13 +339,23 @@ describe('Integration | Repository | challenge-repository', function () { // given const skill = domainBuilder.buildSkill({ id: 'recSkill1' }); const competenceId = 'recCompetenceId'; - const validatedChallenge = domainBuilder.buildChallenge({ skill, status: 'validé', competenceId }); + const validatedChallenge = domainBuilder.buildChallenge({ + id: 'recChallenge1', + skill, + status: 'validé', + competenceId, + }); const nonValidatedChallenge = domainBuilder.buildChallenge({ + id: 'recChallenge2', skill, status: 'PAS validé', competenceId, }); - const notInCompetenceValidatedChallenge = domainBuilder.buildChallenge({ skills: [skill], status: 'validé' }); + const notInCompetenceValidatedChallenge = domainBuilder.buildChallenge({ + id: 'recChallenge3', + skills: [skill], + status: 'validé', + }); const learningContent = { skills: [{ ...skill, status: 'actif', level: skill.difficulty }], challenges: [ @@ -356,7 +364,7 @@ describe('Integration | Repository | challenge-repository', function () { { ...notInCompetenceValidatedChallenge, skillId: 'recSkill1' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualChallenges = await challengeRepository.findValidatedByCompetenceId(competenceId, 'fr'); @@ -381,13 +389,13 @@ describe('Integration | Repository | challenge-repository', function () { { ...validatedChallenge, skillId: 'recSkill1', - t1Status: 'Activé', - t2Status: 'Activé', - t3Status: 'Désactivé', + t1Status: true, + t2Status: true, + t3Status: false, }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const [actualChallenge] = await challengeRepository.findValidatedByCompetenceId( validatedChallenge.competenceId, @@ -410,9 +418,17 @@ describe('Integration | Repository | challenge-repository', function () { // given const skill = domainBuilder.buildSkill({ id: 'recSkill1' }); const anotherSkill = domainBuilder.buildSkill({ id: 'recAnotherSkill' }); - const operativeInSkillChallenge = domainBuilder.buildChallenge({ skill, status: 'archivé' }); - const nonOperativeInSkillChallenge = domainBuilder.buildChallenge({ skill, status: 'PAS opérative' }); - const operativeNotInSkillChallenge = domainBuilder.buildChallenge({ skill: anotherSkill, status: 'validé' }); + const operativeInSkillChallenge = domainBuilder.buildChallenge({ id: 'recChallenge1', skill, status: 'archivé' }); + const nonOperativeInSkillChallenge = domainBuilder.buildChallenge({ + id: 'recChallenge2', + skill, + status: 'PAS opérative', + }); + const operativeNotInSkillChallenge = domainBuilder.buildChallenge({ + id: 'recChallenge3', + skill: anotherSkill, + status: 'validé', + }); const locale = 'fr'; const learningContent = { skills: [ @@ -425,7 +441,7 @@ describe('Integration | Repository | challenge-repository', function () { { ...operativeNotInSkillChallenge, skillId: 'recAnotherSkill' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const actualChallenges = await challengeRepository.findOperativeBySkills([skill], locale); @@ -451,13 +467,13 @@ describe('Integration | Repository | challenge-repository', function () { { ...operativeChallenge, skillId: 'recSkill1', - t1Status: 'Activé', - t2Status: 'Activé', - t3Status: 'Désactivé', + t1Status: true, + t2Status: true, + t3Status: false, }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const [actualChallenge] = await challengeRepository.findOperativeBySkills([skill], locale); @@ -474,7 +490,7 @@ describe('Integration | Repository | challenge-repository', function () { }); describe('#findFlashCompatibleWithoutLocale', function () { - beforeEach(function () { + beforeEach(async function () { // given const skill = domainBuilder.buildSkill({ id: 'recSkill1' }); @@ -504,7 +520,7 @@ describe('Integration | Repository | challenge-repository', function () { { ...outdatedChallenge, skillId: 'recSkill1', alpha: 4.1, delta: -2.08 }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); context('without requesting obsolete challenges', function () { @@ -548,7 +564,7 @@ describe('Integration | Repository | challenge-repository', function () { }); describe('#findActiveFlashCompatible', function () { - beforeEach(function () { + beforeEach(async function () { // given const skill = domainBuilder.buildSkill({ id: 'recSkill1' }); const locales = ['fr-fr']; @@ -578,7 +594,7 @@ describe('Integration | Repository | challenge-repository', function () { { ...outdatedChallenge, skillId: 'recSkill1' }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should return only flash compatible challenges with skills', async function () { @@ -634,7 +650,7 @@ describe('Integration | Repository | challenge-repository', function () { const challenge2 = _buildChallenge({ id: 'recChallenge2', skill, status: 'archivé' }); const challenge3 = _buildChallenge({ id: 'recChallenge3', skill, status: 'périmé' }); - mockLearningContent({ + await mockLearningContent({ skills: [skill], challenges: [challenge1, challenge2, challenge3], }); @@ -666,7 +682,7 @@ describe('Integration | Repository | challenge-repository', function () { const challenge2 = _buildChallenge({ id: 'recChallenge2', skill, locales: ['fr-fr'], type: 'QCU' }); const challenge3 = _buildChallenge({ id: 'recChallenge3', skill, locales: ['en'], type: 'QROCM-dep' }); - mockLearningContent({ + await mockLearningContent({ skills: [skill], challenges: [challenge1, challenge2, challenge3], }); @@ -721,7 +737,7 @@ function _buildChallenge({ alternativeInstruction: 'Des instructions alternatives', proposals: 'Une proposition', status, - timer: '', + timer: undefined, focusable: true, type, locales: ['fr'], diff --git a/api/tests/shared/integration/infrastructure/repositories/competence-repository_test.js b/api/tests/shared/integration/infrastructure/repositories/competence-repository_test.js index fb14e883226..1825cc99605 100644 --- a/api/tests/shared/integration/infrastructure/repositories/competence-repository_test.js +++ b/api/tests/shared/integration/infrastructure/repositories/competence-repository_test.js @@ -19,7 +19,7 @@ describe('Integration | Repository | competence-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const competence = await competenceRepository.get({ id: expectedCompetence.id }); @@ -45,7 +45,7 @@ describe('Integration | Repository | competence-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const competence = await competenceRepository.get({ id: expectedCompetence.id, locale }); @@ -73,7 +73,7 @@ describe('Integration | Repository | competence-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const competenceName = await competenceRepository.getCompetenceName({ id: expectedCompetence.id, locale }); @@ -86,8 +86,8 @@ describe('Integration | Repository | competence-repository', function () { describe('#list', function () { it('should return the competences', async function () { // given - const competence1 = domainBuilder.buildCompetence(); - const competence2 = domainBuilder.buildCompetence(); + const competence1 = domainBuilder.buildCompetence({ id: 'competence1' }); + const competence2 = domainBuilder.buildCompetence({ id: 'competence2' }); const learningContent = { competences: [ { @@ -110,7 +110,7 @@ describe('Integration | Repository | competence-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const competences = await competenceRepository.list(); @@ -136,7 +136,7 @@ describe('Integration | Repository | competence-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const competences = await competenceRepository.list({ locale }); @@ -149,8 +149,8 @@ describe('Integration | Repository | competence-repository', function () { describe('#listPixCompetencesOnly', function () { it('should return the competences with only Pix as origin', async function () { // given - const pixCompetence = domainBuilder.buildCompetence({ origin: 'Pix' }); - const nonPixCompetence = domainBuilder.buildCompetence({ origin: 'Continuum Espace temps' }); + const pixCompetence = domainBuilder.buildCompetence({ id: 'competence1', origin: 'Pix' }); + const nonPixCompetence = domainBuilder.buildCompetence({ id: 'competence2', origin: 'Continuum Espace temps' }); const learningContent = { competences: [ { @@ -173,7 +173,7 @@ describe('Integration | Repository | competence-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const competences = await competenceRepository.listPixCompetencesOnly(); @@ -199,7 +199,7 @@ describe('Integration | Repository | competence-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const competences = await competenceRepository.listPixCompetencesOnly({ locale }); @@ -210,7 +210,7 @@ describe('Integration | Repository | competence-repository', function () { }); describe('#findByRecordIds', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = { competences: [ { @@ -245,7 +245,7 @@ describe('Integration | Repository | competence-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should return competences given by id with default locale', async function () { @@ -311,7 +311,7 @@ describe('Integration | Repository | competence-repository', function () { }); describe('#findByAreaIds', function () { - beforeEach(function () { + beforeEach(async function () { const learningContent = { competences: [ { @@ -346,7 +346,7 @@ describe('Integration | Repository | competence-repository', function () { }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should return competences given by areaId with default locale', async function () { diff --git a/api/tests/shared/integration/infrastructure/repositories/course-repository_test.js b/api/tests/shared/integration/infrastructure/repositories/course-repository_test.js index e7b25265765..c4599d040fb 100644 --- a/api/tests/shared/integration/infrastructure/repositories/course-repository_test.js +++ b/api/tests/shared/integration/infrastructure/repositories/course-repository_test.js @@ -9,7 +9,7 @@ describe('Integration | Repository | course-repository', function () { it('should return the course', async function () { // given const expectedCourse = domainBuilder.buildCourse(); - mockLearningContent({ courses: [{ ...expectedCourse }] }); + await mockLearningContent({ courses: [{ ...expectedCourse }] }); // when const actualCourse = await courseRepository.get(expectedCourse.id); @@ -36,7 +36,7 @@ describe('Integration | Repository | course-repository', function () { it('should return the course name', async function () { // given const expectedCourse = domainBuilder.buildCourse(); - mockLearningContent({ courses: [{ ...expectedCourse }] }); + await mockLearningContent({ courses: [{ ...expectedCourse }] }); // when const actualCourseName = await courseRepository.getCourseName(expectedCourse.id); diff --git a/api/tests/shared/integration/infrastructure/repositories/skill-repository_test.js b/api/tests/shared/integration/infrastructure/repositories/skill-repository_test.js index e463d2b7a03..bf0b316c942 100644 --- a/api/tests/shared/integration/infrastructure/repositories/skill-repository_test.js +++ b/api/tests/shared/integration/infrastructure/repositories/skill-repository_test.js @@ -8,9 +8,12 @@ describe('Integration | Repository | skill-repository', function () { it('should resolve all skills', async function () { // given const competenceId = 'recCompetenceId'; - const activeSkill = domainBuilder.buildSkill({ competenceId }); - const archivedSkill = domainBuilder.buildSkill({ competenceId }); - const activeSkill_otherCompetence = domainBuilder.buildSkill({ competenceId: 'recAnotherCompetence' }); + const activeSkill = domainBuilder.buildSkill({ id: 'activeSkill', competenceId }); + const archivedSkill = domainBuilder.buildSkill({ id: 'archivedSkill', competenceId }); + const activeSkill_otherCompetence = domainBuilder.buildSkill({ + id: 'activeSkill_otherCompetence', + competenceId: 'recAnotherCompetence', + }); const learningContent = { skills: [ { ...activeSkill, status: 'actif', level: activeSkill.difficulty }, @@ -18,7 +21,7 @@ describe('Integration | Repository | skill-repository', function () { { ...activeSkill_otherCompetence, status: 'actif', level: activeSkill_otherCompetence.difficulty }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const skills = await skillRepository.list(); @@ -31,9 +34,12 @@ describe('Integration | Repository | skill-repository', function () { it('should return all skills in the given competence', async function () { // given const competenceId = 'recCompetenceId'; - const activeSkill = domainBuilder.buildSkill({ competenceId }); - const nonActiveSkill = domainBuilder.buildSkill({ competenceId }); - const activeSkill_otherCompetence = domainBuilder.buildSkill({ competenceId: 'recAnotherCompetence' }); + const activeSkill = domainBuilder.buildSkill({ id: 'activeSkill', competenceId }); + const nonActiveSkill = domainBuilder.buildSkill({ id: 'nonActiveSkill', competenceId }); + const activeSkill_otherCompetence = domainBuilder.buildSkill({ + id: 'activeSkill_otherCompetence', + competenceId: 'recAnotherCompetence', + }); const learningContent = { skills: [ { ...activeSkill, status: 'actif', level: activeSkill.difficulty }, @@ -41,7 +47,7 @@ describe('Integration | Repository | skill-repository', function () { { ...activeSkill_otherCompetence, status: 'actif', level: activeSkill_otherCompetence.difficulty }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const skills = await skillRepository.findActiveByCompetenceId(competenceId); @@ -56,10 +62,13 @@ describe('Integration | Repository | skill-repository', function () { it('should resolve all skills for one competence', async function () { // given const competenceId = 'recCompetenceId'; - const activeSkill = domainBuilder.buildSkill({ competenceId }); - const archivedSkill = domainBuilder.buildSkill({ competenceId }); - const nonOperativeSkill = domainBuilder.buildSkill({ competenceId }); - const activeSkill_otherCompetence = domainBuilder.buildSkill({ competenceId: 'recAnotherCompetence' }); + const activeSkill = domainBuilder.buildSkill({ id: 'activeSkill', competenceId }); + const archivedSkill = domainBuilder.buildSkill({ id: 'archivedSkill', competenceId }); + const nonOperativeSkill = domainBuilder.buildSkill({ id: 'nonOperativeSkill', competenceId }); + const activeSkill_otherCompetence = domainBuilder.buildSkill({ + id: 'activeSkill_otherCompetence', + competenceId: 'recAnotherCompetence', + }); const learningContent = { skills: [ { ...activeSkill, status: 'actif', level: activeSkill.difficulty }, @@ -68,7 +77,7 @@ describe('Integration | Repository | skill-repository', function () { { ...activeSkill_otherCompetence, status: 'actif', level: activeSkill_otherCompetence.difficulty }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const skills = await skillRepository.findOperativeByCompetenceId(competenceId); @@ -85,11 +94,14 @@ describe('Integration | Repository | skill-repository', function () { // given const competenceId1 = 'recCompetenceId'; const competenceId2 = 'recCompetenceId'; - const activeSkill1 = domainBuilder.buildSkill({ competenceId: competenceId1 }); - const activeSkill2 = domainBuilder.buildSkill({ competenceId: competenceId2 }); - const archivedSkill = domainBuilder.buildSkill({ competenceId: competenceId1 }); - const nonOperativeSkill = domainBuilder.buildSkill({ competenceId: competenceId1 }); - const activeSkill_otherCompetence = domainBuilder.buildSkill({ competenceId: 'recAnotherCompetence' }); + const activeSkill1 = domainBuilder.buildSkill({ id: 'activeSkill1', competenceId: competenceId1 }); + const activeSkill2 = domainBuilder.buildSkill({ id: 'activeSkill2', competenceId: competenceId2 }); + const archivedSkill = domainBuilder.buildSkill({ id: 'archivedSkill', competenceId: competenceId1 }); + const nonOperativeSkill = domainBuilder.buildSkill({ id: 'nonOperativeSkill', competenceId: competenceId1 }); + const activeSkill_otherCompetence = domainBuilder.buildSkill({ + id: 'activeSkill_otherCompetence', + competenceId: 'recAnotherCompetence', + }); const learningContent = { skills: [ { ...activeSkill1, status: 'actif', level: activeSkill1.difficulty }, @@ -99,7 +111,7 @@ describe('Integration | Repository | skill-repository', function () { { ...activeSkill_otherCompetence, status: 'actif', level: activeSkill_otherCompetence.difficulty }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const skills = await skillRepository.findOperativeByCompetenceIds([competenceId1, competenceId2]); @@ -115,9 +127,9 @@ describe('Integration | Repository | skill-repository', function () { it('should return all active skills in the given tube', async function () { // given const tubeId = 'recTubeId'; - const activeSkill = domainBuilder.buildSkill({ tubeId }); - const nonActiveSkill = domainBuilder.buildSkill({ tubeId }); - const activeSkill_otherTube = domainBuilder.buildSkill({ tubeId: 'recAnotherTube' }); + const activeSkill = domainBuilder.buildSkill({ id: 'activeSkill', tubeId }); + const nonActiveSkill = domainBuilder.buildSkill({ id: 'nonActiveSkill', tubeId }); + const activeSkill_otherTube = domainBuilder.buildSkill({ id: 'activeSkill_otherTube', tubeId: 'recAnotherTube' }); const learningContent = { skills: [ { ...activeSkill, status: 'actif', level: activeSkill.difficulty }, @@ -125,7 +137,7 @@ describe('Integration | Repository | skill-repository', function () { { ...activeSkill_otherTube, status: 'actif', level: activeSkill_otherTube.difficulty }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const skills = await skillRepository.findActiveByTubeId(tubeId); @@ -141,10 +153,10 @@ describe('Integration | Repository | skill-repository', function () { it('should resolve all operative skills for one tube', async function () { // given const tubeId = 'recTubeId'; - const activeSkill = domainBuilder.buildSkill({ tubeId }); - const archivedSkill = domainBuilder.buildSkill({ tubeId }); - const nonOperativeSkill = domainBuilder.buildSkill({ tubeId }); - const activeSkill_otherTube = domainBuilder.buildSkill({ tubeId: 'recAnotherTube' }); + const activeSkill = domainBuilder.buildSkill({ id: 'activeSkill', tubeId }); + const archivedSkill = domainBuilder.buildSkill({ id: 'archivedSkill', tubeId }); + const nonOperativeSkill = domainBuilder.buildSkill({ id: 'nonOperativeSkill', tubeId }); + const activeSkill_otherTube = domainBuilder.buildSkill({ id: 'activeSkill_otherTube', tubeId: 'recAnotherTube' }); const learningContent = { skills: [ { ...activeSkill, status: 'actif', level: activeSkill.difficulty }, @@ -153,7 +165,7 @@ describe('Integration | Repository | skill-repository', function () { { ...activeSkill_otherTube, status: 'actif', level: activeSkill_otherTube.difficulty }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const skills = await skillRepository.findOperativeByTubeId(tubeId); @@ -169,9 +181,9 @@ describe('Integration | Repository | skill-repository', function () { it('should resolve operative skills passed by ids', async function () { // given const competenceId = 'recCompetenceId'; - const activeSkill = domainBuilder.buildSkill({ competenceId }); - const archivedSkill = domainBuilder.buildSkill({ competenceId }); - const nonOperativeSkill = domainBuilder.buildSkill({ competenceId }); + const activeSkill = domainBuilder.buildSkill({ id: 'activeSkill', competenceId }); + const archivedSkill = domainBuilder.buildSkill({ id: 'archivedSkill', competenceId }); + const nonOperativeSkill = domainBuilder.buildSkill({ id: 'nonOperativeSkill', competenceId }); const learningContent = { skills: [ { ...activeSkill, status: 'actif', level: activeSkill.difficulty }, @@ -179,7 +191,7 @@ describe('Integration | Repository | skill-repository', function () { { ...nonOperativeSkill, status: 'BLABLA', level: nonOperativeSkill.difficulty }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const skills = await skillRepository.findOperativeByIds([activeSkill.id, archivedSkill.id, nonOperativeSkill.id]); @@ -193,12 +205,12 @@ describe('Integration | Repository | skill-repository', function () { describe('#get', function () { let skill; - beforeEach(function () { + beforeEach(async function () { skill = domainBuilder.buildSkill(); const learningContent = { skills: [{ ...skill, level: skill.difficulty }], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); }); it('should return a skill by id', async function () { @@ -224,9 +236,9 @@ describe('Integration | Repository | skill-repository', function () { it('should resolve active skills passed by ids', async function () { // given const competenceId = 'recCompetenceId'; - const activeSkill = domainBuilder.buildSkill({ competenceId }); - const archivedSkill = domainBuilder.buildSkill({ competenceId }); - const nonOperativeSkill = domainBuilder.buildSkill({ competenceId }); + const activeSkill = domainBuilder.buildSkill({ id: 'activeSkill', competenceId }); + const archivedSkill = domainBuilder.buildSkill({ id: 'archivedSkill', competenceId }); + const nonOperativeSkill = domainBuilder.buildSkill({ id: 'nonOperativeSkill', competenceId }); const learningContent = { skills: [ { ...activeSkill, status: 'actif', level: activeSkill.difficulty }, @@ -234,7 +246,7 @@ describe('Integration | Repository | skill-repository', function () { { ...nonOperativeSkill, status: 'BLABLA', level: nonOperativeSkill.difficulty }, ], }; - mockLearningContent(learningContent); + await mockLearningContent(learningContent); // when const skills = await skillRepository.findActiveByRecordIds([ activeSkill.id, diff --git a/api/tests/test-helper.js b/api/tests/test-helper.js index 238a110ccda..ca2ea1b43f4 100644 --- a/api/tests/test-helper.js +++ b/api/tests/test-helper.js @@ -254,11 +254,10 @@ chaiUse(function () { }); }); -function mockLearningContent(learningContent) { - return nock('https://lcms-test.pix.fr/api') - .get('/releases/latest') - .matchHeader('Authorization', 'Bearer test-api-key') - .reply(200, { content: learningContent }); +async function mockLearningContent(learningContent) { + const scope = databaseBuilder.factory.learningContent.build(learningContent); + await databaseBuilder.commit(); + return scope; } // Inspired by what is done within chai project itself to test assertions diff --git a/api/tests/tooling/domain-builder/factory/build-certifications-results-for-livret-scolaire.js b/api/tests/tooling/domain-builder/factory/build-certifications-results-for-livret-scolaire.js index 9e017bee0dd..1d9e8e2eb97 100644 --- a/api/tests/tooling/domain-builder/factory/build-certifications-results-for-livret-scolaire.js +++ b/api/tests/tooling/domain-builder/factory/build-certifications-results-for-livret-scolaire.js @@ -1,6 +1,6 @@ import { Assessment } from '../../../../src/shared/domain/models/Assessment.js'; import { status } from '../../../../src/shared/domain/models/AssessmentResult.js'; -import { databaseBuilder, learningContentBuilder, mockLearningContent } from '../../../test-helper.js'; +import { databaseBuilder, learningContentBuilder } from '../../../test-helper.js'; const assessmentCreatedDate = new Date('2020-04-19'); const assessmentBeforeCreatedDate = new Date('2020-04-18'); @@ -359,7 +359,7 @@ function mockLearningContentCompetences() { ]; const learningContentObjects = learningContentBuilder.fromAreas(learningContent); - mockLearningContent(learningContentObjects); + databaseBuilder.factory.learningContent.build(learningContentObjects); } export { diff --git a/api/tests/tooling/learning-content-builder/build-learning-content_test.js b/api/tests/tooling/learning-content-builder/build-learning-content_test.js deleted file mode 100644 index 71983d9de7a..00000000000 --- a/api/tests/tooling/learning-content-builder/build-learning-content_test.js +++ /dev/null @@ -1,449 +0,0 @@ -import { - areaDatasource, - challengeDatasource, - competenceDatasource, - courseDatasource, - frameworkDatasource, - skillDatasource, - thematicDatasource, - tubeDatasource, -} from '../../../src/shared/infrastructure/datasources/learning-content/index.js'; -import { expect, learningContentBuilder, mockLearningContent } from '../../test-helper.js'; - -describe('Integration | buildLearningContent', function () { - it('builds areas and frameworks', async function () { - // given - const learningContent = [ - { - id: 'recFramework1', - name: 'monFramework 1', - areas: [ - { - id: 'recArea1', - title_i18n: { - fr: 'domaine1_Titre', - en: 'area1_Title', - }, - competences: [], - }, - ], - }, - { - id: 'recFramework2', - name: 'monFramework 2', - areas: [ - { - id: 'recArea2', - title_i18n: { - fr: 'domaine2_Titre', - en: 'area2_Title', - }, - competences: [], - frameworkId: 'test', - }, - ], - }, - ]; - - // when - const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); - - // then - const areas = await areaDatasource.list(); - const frameworks = await frameworkDatasource.list(); - expect(areas[0].id).to.equal('recArea1'); - expect(areas[0].title_i18n.fr).to.equal('domaine1_Titre'); - expect(areas[0].title_i18n.en).to.equal('area1_Title'); - expect(areas[1].id).to.equal('recArea2'); - expect(areas[1].title_i18n.fr).to.equal('domaine2_Titre'); - expect(areas[1].title_i18n.en).to.equal('area2_Title'); - expect(frameworks).to.have.lengthOf(2); - expect(frameworks[0].id).to.deep.equal('recFramework1'); - expect(frameworks[0].name).to.deep.equal('monFramework 1'); - expect(frameworks[1].id).to.deep.equal('recFramework2'); - expect(frameworks[1].name).to.deep.equal('monFramework 2'); - }); - - it('builds competences', async function () { - // given - const learningContent = [ - { - id: 'recFramework1', - name: 'monFramework 1', - areas: [ - { - id: 'recArea1', - competences: [ - { - id: 'recArea1_Competence1', - name_i18n: { fr: 'competence1_nomFr', en: 'competence1_nameEn' }, - description_i18n: { fr: 'competence1_descriptionFr', en: 'competence1_descriptionEn' }, - tubes: [], - }, - { - id: 'recArea1_Competence2', - name_i18n: { fr: 'competence2_nomFr', en: 'competence2_nameEn' }, - description_i18n: { fr: 'competence2_descriptionFr', en: 'competence2_descriptionEn' }, - tubes: [], - }, - ], - }, - { - id: 'recArea2', - competences: [ - { - id: 'recArea2_Competence1', - name_i18n: { fr: 'domaine2_competence1_nomFr', en: 'area2_competence1_nameEn' }, - description_i18n: { fr: 'domaine2_competence1_descriptionFr', en: 'area2_competence1_descriptionEn' }, - tubes: [], - origin: 'Pix+', - }, - { - id: 'recArea2_Competence2', - name_i18n: { fr: 'domaine2_competence2_nomFr', en: 'area2_competence2_nameEn' }, - description_i18n: { fr: 'domaine2_competence2_descriptionFr', en: 'area2_competence2_descriptionEn' }, - tubes: [], - origin: 'Pix+', - }, - ], - }, - ], - }, - ]; - - // when - const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); - - // then - const areas = await areaDatasource.list(); - const competences = await competenceDatasource.list(); - expect(areas[0].competenceIds).to.deep.equal(['recArea1_Competence1', 'recArea1_Competence2']); - expect(areas[1].competenceIds).to.deep.equal(['recArea2_Competence1', 'recArea2_Competence2']); - expect(competences[0].id).to.deep.equal('recArea1_Competence1'); - expect(competences[0].areaId).to.deep.equal('recArea1'); - expect(competences[0].name_i18n.fr).to.deep.equal('competence1_nomFr'); - expect(competences[0].name_i18n.en).to.deep.equal('competence1_nameEn'); - expect(competences[0].description_i18n.fr).to.deep.equal('competence1_descriptionFr'); - expect(competences[0].description_i18n.en).to.deep.equal('competence1_descriptionEn'); - expect(competences[0].origin).to.deep.equal('Pix'); - expect(competences[1].id).to.deep.equal('recArea1_Competence2'); - expect(competences[1].areaId).to.deep.equal('recArea1'); - expect(competences[1].name_i18n.fr).to.deep.equal('competence2_nomFr'); - expect(competences[1].name_i18n.en).to.deep.equal('competence2_nameEn'); - expect(competences[1].description_i18n.fr).to.deep.equal('competence2_descriptionFr'); - expect(competences[1].description_i18n.en).to.deep.equal('competence2_descriptionEn'); - expect(competences[1].origin).to.deep.equal('Pix'); - expect(competences[2].id).to.deep.equal('recArea2_Competence1'); - expect(competences[2].areaId).to.deep.equal('recArea2'); - expect(competences[2].name_i18n.fr).to.deep.equal('domaine2_competence1_nomFr'); - expect(competences[2].name_i18n.en).to.deep.equal('area2_competence1_nameEn'); - expect(competences[2].description_i18n.fr).to.deep.equal('domaine2_competence1_descriptionFr'); - expect(competences[2].description_i18n.en).to.deep.equal('area2_competence1_descriptionEn'); - expect(competences[2].origin).to.deep.equal('Pix+'); - expect(competences[3].id).to.deep.equal('recArea2_Competence2'); - expect(competences[3].areaId).to.deep.equal('recArea2'); - expect(competences[3].name_i18n.fr).to.deep.equal('domaine2_competence2_nomFr'); - expect(competences[3].name_i18n.en).to.deep.equal('area2_competence2_nameEn'); - expect(competences[3].description_i18n.fr).to.deep.equal('domaine2_competence2_descriptionFr'); - expect(competences[3].description_i18n.en).to.deep.equal('area2_competence2_descriptionEn'); - expect(competences[3].origin).to.deep.equal('Pix+'); - }); - - it('builds thematics', async function () { - // given - const learningContent = [ - { - id: 'recFramework1', - name: 'monFramework 1', - areas: [ - { - id: 'recArea1', - competences: [ - { - id: 'recArea1_Competence1', - thematics: [ - { - id: 'recThematic1', - name_i18n: { fr: 'thematique1_nomFr', en: 'thematic1_nameEn' }, - }, - ], - }, - { - id: 'recArea1_Competence2', - thematics: [ - { - id: 'recThematic2', - name_i18n: { fr: 'thematique2_nomFr', en: 'thematic2_nameEn' }, - }, - ], - }, - ], - }, - { - id: 'recArea2', - competences: [ - { - id: 'recArea2_Competence1', - thematics: [ - { - id: 'recArea2_Thematic1', - name_i18n: { fr: 'domaine2_thematique1_nomFr', en: 'area2_thematic1_nameEn' }, - }, - ], - origin: 'Pix+', - }, - { - id: 'recArea2_Competence2', - thematics: [ - { - id: 'recArea2_Thematic2', - name_i18n: { fr: 'domaine2_thematique2_nomFr', en: 'area2_thematic2_nameEn' }, - }, - ], - origin: 'Pix+', - }, - ], - }, - ], - }, - ]; - - // when - const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); - - // then - const areas = await areaDatasource.list(); - const competences = await competenceDatasource.list(); - const thematics = await thematicDatasource.list(); - expect(areas[0].competenceIds).to.deep.equal(['recArea1_Competence1', 'recArea1_Competence2']); - expect(areas[1].competenceIds).to.deep.equal(['recArea2_Competence1', 'recArea2_Competence2']); - expect(competences[0].id).to.deep.equal('recArea1_Competence1'); - expect(competences[1].id).to.deep.equal('recArea1_Competence2'); - expect(competences[2].id).to.deep.equal('recArea2_Competence1'); - expect(competences[3].id).to.deep.equal('recArea2_Competence2'); - expect(thematics[0].id).to.deep.equal('recThematic1'); - expect(thematics[0].name_i18n.fr).to.deep.equal('thematique1_nomFr'); - expect(thematics[0].name_i18n.en).to.deep.equal('thematic1_nameEn'); - expect(thematics[1].id).to.deep.equal('recThematic2'); - expect(thematics[1].name_i18n.fr).to.deep.equal('thematique2_nomFr'); - expect(thematics[1].name_i18n.en).to.deep.equal('thematic2_nameEn'); - expect(thematics[2].id).to.deep.equal('recArea2_Thematic1'); - expect(thematics[2].name_i18n.fr).to.deep.equal('domaine2_thematique1_nomFr'); - expect(thematics[2].name_i18n.en).to.deep.equal('area2_thematic1_nameEn'); - expect(thematics[3].id).to.deep.equal('recArea2_Thematic2'); - expect(thematics[3].name_i18n.fr).to.deep.equal('domaine2_thematique2_nomFr'); - expect(thematics[3].name_i18n.en).to.deep.equal('area2_thematic2_nameEn'); - }); - - it('builds tubes', async function () { - // given - const learningContent = [ - { - id: 'recFramework1', - name: 'monFramework 1', - areas: [ - { - id: 'recArea1', - competences: [ - { - id: 'recArea1_Competence1', - tubes: [ - { - id: 'recArea1_Competence1_Tube1', - practicalTitle_i18n: { fr: 'titrePratique1_fr', en: 'practicalTitle1_en' }, - practicalDescription_i18n: { fr: 'descriptionPratique1_fr', en: 'practicalDescription1_en' }, - skills: [], - }, - { - id: 'recArea1_Competence1_Tube2', - practicalTitle_i18n: { fr: 'titrePratique2_fr', en: 'practicalTitle2_en' }, - practicalDescription_i18n: { fr: 'descriptionPratique2_fr', en: 'practicalDescription2_en' }, - skills: [], - }, - ], - }, - ], - }, - ], - }, - ]; - - // when - const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); - - // then - const competences = await competenceDatasource.list(); - const tubes = await tubeDatasource.list(); - expect(competences[0].id).to.deep.equal('recArea1_Competence1'); - expect(tubes[0].id).to.deep.equal('recArea1_Competence1_Tube1'); - expect(tubes[0].competenceId).to.deep.equal('recArea1_Competence1'); - expect(tubes[0].practicalTitle_i18n.fr).to.deep.equal('titrePratique1_fr'); - expect(tubes[0].practicalTitle_i18n.en).to.deep.equal('practicalTitle1_en'); - expect(tubes[0].practicalDescription_i18n.fr).to.deep.equal('descriptionPratique1_fr'); - expect(tubes[0].practicalDescription_i18n.en).to.deep.equal('practicalDescription1_en'); - expect(tubes[1].id).to.deep.equal('recArea1_Competence1_Tube2'); - expect(tubes[1].competenceId).to.deep.equal('recArea1_Competence1'); - expect(tubes[1].practicalTitle_i18n.fr).to.deep.equal('titrePratique2_fr'); - expect(tubes[1].practicalTitle_i18n.en).to.deep.equal('practicalTitle2_en'); - expect(tubes[1].practicalDescription_i18n.fr).to.deep.equal('descriptionPratique2_fr'); - expect(tubes[1].practicalDescription_i18n.en).to.deep.equal('practicalDescription2_en'); - }); - - it('builds skills', async function () { - // given - const learningContent = [ - { - id: 'recFramework1', - name: 'monFramework 1', - areas: [ - { - id: 'recArea1', - competences: [ - { - id: 'recArea1_Competence1', - tubes: [ - { - id: 'recArea1_Competence1_Tube1', - skills: [ - { - id: 'recArea1_Competence1_Tube1_Skill1', - nom: '@accesDonnées1', - status: 'actif', - challenges: [], - }, - { - id: 'recArea1_Competence1_Tube1_Skill2', - nom: '@accesDonnées2', - status: 'archivé', - challenges: [], - }, - ], - }, - ], - }, - ], - }, - ], - }, - ]; - - // when - const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); - - // then - const competences = await competenceDatasource.list(); - const skills = await skillDatasource.list(); - expect(competences[0].skillIds).to.deep.equal([ - 'recArea1_Competence1_Tube1_Skill1', - 'recArea1_Competence1_Tube1_Skill2', - ]); - expect(skills[0].id).to.deep.equal('recArea1_Competence1_Tube1_Skill1'); - expect(skills[0].competenceId).to.deep.equal('recArea1_Competence1'); - expect(skills[0].tubeId).to.deep.equal('recArea1_Competence1_Tube1'); - expect(skills[0].status).to.deep.equal('actif'); - expect(skills[0].name).to.deep.equal('@accesDonnées1'); - - expect(skills[1].id).to.deep.equal('recArea1_Competence1_Tube1_Skill2'); - expect(skills[1].competenceId).to.deep.equal('recArea1_Competence1'); - expect(skills[1].tubeId).to.deep.equal('recArea1_Competence1_Tube1'); - expect(skills[1].status).to.deep.equal('archivé'); - expect(skills[1].name).to.deep.equal('@accesDonnées2'); - }); - - it('builds challenges', async function () { - // given - const learningContent = [ - { - id: 'recFramework1', - name: 'monFramework 1', - areas: [ - { - id: 'recArea1', - competences: [ - { - id: 'recArea1_Competence1', - tubes: [ - { - id: 'recArea1_Competence1_Tube1', - skills: [ - { - id: 'recArea1_Competence1_Tube1_Skill1', - status: 'actif', - challenges: [ - { - id: 'recArea1_Competence1_Tube1_Skill1_Challenge1', - statut: 'validé', - }, - { - id: 'recArea1_Competence1_Tube1_Skill1_Challenge2', - statut: 'archivé', - langues: ['Francophone', 'Franco Français'], - }, - ], - }, - ], - }, - ], - }, - ], - }, - ], - }, - ]; - - // when - const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); - - // then - const challenges = await challengeDatasource.list(); - expect(challenges[0].id).to.equal('recArea1_Competence1_Tube1_Skill1_Challenge1'); - expect(challenges[0].skillId).to.deep.equal('recArea1_Competence1_Tube1_Skill1'); - expect(challenges[0].status).to.deep.equal('validé'); - expect(challenges[1].id).to.equal('recArea1_Competence1_Tube1_Skill1_Challenge2'); - expect(challenges[1].skillId).to.deep.equal('recArea1_Competence1_Tube1_Skill1'); - expect(challenges[1].status).to.deep.equal('archivé'); - expect(challenges[1].locales).to.deep.equal(['fr', 'fr-fr']); - }); - - it('builds courses', async function () { - // given - const learningContent = [ - { - id: 'recFramework1', - name: 'monFramework 1', - areas: [ - { - competences: [], - courses: [ - { - id: 'recCourse0', - name: 'Test de démo 0', - challengeIds: ['second_challenge', 'first_challenge'], - }, - { - id: 'recCourse1', - name: 'Test de démo 1', - challengeIds: ['first_challenge'], - }, - ], - }, - ], - }, - ]; - - // when - const learningContentObjects = learningContentBuilder(learningContent); - mockLearningContent(learningContentObjects); - - // then - const courses = await courseDatasource.list(); - expect(courses[0].id).to.equal('recCourse0'); - expect(courses[1].id).to.equal('recCourse1'); - }); -}); diff --git a/api/tests/unit/tooling/database-builder/database-builder_test.js b/api/tests/unit/tooling/database-builder/database-builder_test.js index 2f314f943fb..5467527a3a9 100644 --- a/api/tests/unit/tooling/database-builder/database-builder_test.js +++ b/api/tests/unit/tooling/database-builder/database-builder_test.js @@ -146,7 +146,8 @@ describe('Unit | Tooling | DatabaseBuilder | database-builder', function () { rows: [{ table_name: 'table2' }, { table_name: 'knex_migrations' }, { table_name: 'table1' }], }); knex.raw.onCall(1).resolves({ rows: [] }); - knex.raw.onCall(2).resolves(); + knex.raw.onCall(2).resolves({ rows: [] }); + knex.raw.onCall(3).resolves(); databaseBuilder.knex = knex; databaseBuilder.isFirstCommit = true;