Skip to content

Commit

Permalink
Merge pull request #2390 from sophiemoustard/COM-3716
Browse files Browse the repository at this point in the history
Com 3716
  • Loading branch information
ulysseferreira committed May 27, 2024
2 parents 93e3311 + 9994e79 commit 7568dcf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/helpers/questionnaires.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@ const getFollowUpForReview = async (questionnaire, courseId) => {
const followUp = questionnaire.histories.map(h => pick(h, ['user', 'questionnaireAnswersList', 'timeline']));

const course = await Course.findOne({ _id: courseId })
.select('subProgram companies misc type holding')
.select('subProgram companies misc type holding trainees')
.populate({ path: 'subProgram', select: 'program', populate: [{ path: 'program', select: 'name' }] })
.populate({ path: 'companies', select: 'name' })
.populate({ path: 'holding', select: 'name' })
.populate({ path: 'trainees', select: 'identity' })
.lean();

return { followUp, course };
Expand Down
24 changes: 20 additions & 4 deletions tests/unit/helpers/questionnaires.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,10 @@ describe('getFollowUp', () => {
subProgram: { program: { name: 'test' } },
misc: 'infos',
type: INTRA,
trainees: [
{ identity: { firstname: 'tomTom', lastname: 'Nana' } },
{ identity: { firstname: 'eleve', lastname: 'Ducobu' } },
],
};
const cardsIds = [new ObjectId(), new ObjectId()];
const questionnaire = {
Expand Down Expand Up @@ -1406,6 +1410,10 @@ describe('getFollowUp', () => {
companies: [{ name: 'company' }],
holding: [{ name: 'société mère' }],
misc: 'infos',
trainees: [
{ identity: { firstname: 'tomTom', lastname: 'Nana' } },
{ identity: { firstname: 'eleve', lastname: 'Ducobu' } },
],
},
followUp: [
{
Expand Down Expand Up @@ -1492,14 +1500,14 @@ describe('getFollowUp', () => {
courseFindOne,
[
{ query: 'findOne', args: [{ _id: courseId }] },
{ query: 'select', args: ['subProgram companies misc type holding'] },
{ query: 'select', args: ['subProgram companies misc type holding trainees'] },
{
query: 'populate',
args: [{ path: 'subProgram', select: 'program', populate: [{ path: 'program', select: 'name' }] }],
},
{ query: 'populate', args: [{ path: 'companies', select: 'name' }] },
{ query: 'populate', args: [{ path: 'holding', select: 'name' }] },

{ query: 'populate', args: [{ path: 'trainees', select: 'identity' }] },
{ query: 'lean' },
]
);
Expand All @@ -1516,6 +1524,10 @@ describe('getFollowUp', () => {
subProgram: { program: { name: 'test' } },
misc: 'infos',
type: INTRA,
trainees: [
{ identity: { firstname: 'tomTom', lastname: 'Nana' } },
{ identity: { firstname: 'eleve', lastname: 'Ducobu' } },
],
};
const questionnaire = {
_id: questionnaireId,
Expand All @@ -1538,6 +1550,10 @@ describe('getFollowUp', () => {
companies: [{ name: 'company' }],
holding: [{ name: 'société mère' }],
misc: 'infos',
trainees: [
{ identity: { firstname: 'tomTom', lastname: 'Nana' } },
{ identity: { firstname: 'eleve', lastname: 'Ducobu' } },
],
},
followUp: [],
});
Expand Down Expand Up @@ -1571,14 +1587,14 @@ describe('getFollowUp', () => {
courseFindOne,
[
{ query: 'findOne', args: [{ _id: courseId }] },
{ query: 'select', args: ['subProgram companies misc type holding'] },
{ query: 'select', args: ['subProgram companies misc type holding trainees'] },
{
query: 'populate',
args: [{ path: 'subProgram', select: 'program', populate: [{ path: 'program', select: 'name' }] }],
},
{ query: 'populate', args: [{ path: 'companies', select: 'name' }] },
{ query: 'populate', args: [{ path: 'holding', select: 'name' }] },

{ query: 'populate', args: [{ path: 'trainees', select: 'identity' }] },
{ query: 'lean' },
]
);
Expand Down

0 comments on commit 7568dcf

Please sign in to comment.