From 5baf9c804c3a2204fc3b4d1fb3050da2b1a03b22 Mon Sep 17 00:00:00 2001 From: Manon Palin Date: Thu, 19 Nov 2026 17:16:10 +0100 Subject: [PATCH] COM-4334 - allow completionCertificate generation when some activityHistories has no duration --- src/helpers/courses.js | 2 +- tests/unit/helpers/courses.test.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/helpers/courses.js b/src/helpers/courses.js index f3d297e805..60247e224a 100644 --- a/src/helpers/courses.js +++ b/src/helpers/courses.js @@ -1414,7 +1414,7 @@ exports.getELearningDuration = (steps, traineeId, { startDate, endDate } = {}) = exports.getRealELearningDuration = (activityHistories) => { const eLearningDuration = activityHistories - .map(ah => ah.duration) + .map(ah => ah.duration || PT0S) .reduce((acc, val) => acc.add(CompaniDuration(val)), CompaniDuration()); return eLearningDuration; diff --git a/tests/unit/helpers/courses.test.js b/tests/unit/helpers/courses.test.js index 50827cb716..31202089a2 100644 --- a/tests/unit/helpers/courses.test.js +++ b/tests/unit/helpers/courses.test.js @@ -8377,7 +8377,10 @@ describe('generateCompletionCertificates', () => { }, { _id: new ObjectId(), - activityHistories: [{ _id: new ObjectId(), user: traineesIds[0], duration: 'PT100S' }], + activityHistories: [ + { _id: new ObjectId(), user: traineesIds[0], duration: 'PT100S' }, + { _id: new ObjectId(), user: traineesIds[0] }, + ], }, ], },