Skip to content

Commit

Permalink
[BUGFIX] Permettre d'inscrire un candidat à Pix Santé via l'ODS (PIX-…
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored May 30, 2024
2 parents 1acf7df + c3269ad commit f5b0655
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,65 +94,27 @@ function getTransformationStructsForPixCertifCandidatesImport({ i18n, complement
}

function _includeComplementaryCertificationColumns({ complementaryCertifications, transformationStruct, translate }) {
const containsClea = complementaryCertifications.some(
(complementaryCertification) => complementaryCertification.key === ComplementaryCertificationKeys.CLEA,
);
const containsPixPlusDroit = complementaryCertifications.some(
(complementaryCertification) => complementaryCertification.key === ComplementaryCertificationKeys.PIX_PLUS_DROIT,
);
const containsPixPlusEdu1erDegre = complementaryCertifications.some(
(complementaryCertification) =>
complementaryCertification.key === ComplementaryCertificationKeys.PIX_PLUS_EDU_1ER_DEGRE,
);
const containsPixPlusEdu2ndDegre = complementaryCertifications.some(
(complementaryCertification) =>
complementaryCertification.key === ComplementaryCertificationKeys.PIX_PLUS_EDU_2ND_DEGRE,
);

const containsPixPlusProSante = complementaryCertifications.some(
(complementaryCertification) =>
complementaryCertification.key === ComplementaryCertificationKeys.PIX_PLUS_PRO_SANTE,
);

if (containsClea) {
transformationStruct.push({
header: `CléA Numérique${translate('candidate-list-template.yes-or-empty')}`,
[
{
key: ComplementaryCertificationKeys.CLEA,
property: 'hasCleaNumerique',
transformFn: (val) => _toBooleanIfValueEqualsOuiOrNull({ val, translate }),
});
}

if (containsPixPlusDroit) {
transformationStruct.push({
header: `Pix+ Droit${translate('candidate-list-template.yes-or-empty')}`,
property: 'hasPixPlusDroit',
transformFn: (val) => _toBooleanIfValueEqualsOuiOrNull({ val, translate }),
});
}

if (containsPixPlusEdu1erDegre) {
transformationStruct.push({
header: `Pix+ Édu 1er degré${translate('candidate-list-template.yes-or-empty')}`,
property: 'hasPixPlusEdu1erDegre',
transformFn: (val) => _toBooleanIfValueEqualsOuiOrNull({ val, translate }),
});
}

if (containsPixPlusEdu2ndDegre) {
transformationStruct.push({
header: `Pix+ Édu 2nd degré${translate('candidate-list-template.yes-or-empty')}`,
property: 'hasPixPlusEdu2ndDegre',
transformFn: (val) => _toBooleanIfValueEqualsOuiOrNull({ val, translate }),
});
}

if (containsPixPlusProSante) {
transformationStruct.push({
header: `Pix+ Pro Santé${translate('candidate-list-template.yes-or-empty')}`,
property: 'hasPixPlusProSante',
transformFn: (val) => _toBooleanIfValueEqualsOuiOrNull({ val, translate }),
});
}
},
{ key: ComplementaryCertificationKeys.PIX_PLUS_DROIT, property: 'hasPixPlusDroit' },
{ key: ComplementaryCertificationKeys.PIX_PLUS_EDU_1ER_DEGRE, property: 'hasPixPlusEdu1erDegre' },
{ key: ComplementaryCertificationKeys.PIX_PLUS_EDU_2ND_DEGRE, property: 'hasPixPlusEdu2ndDegre' },
{ key: ComplementaryCertificationKeys.PIX_PLUS_PRO_SANTE, property: 'hasPixPlusProSante' },
].forEach(({ key, property }) => {
const complementaryCertification = complementaryCertifications.find(
(complementaryCertification) => complementaryCertification.key === key,
);
if (complementaryCertification) {
transformationStruct.push({
header: `${complementaryCertification.label}${translate('candidate-list-template.yes-or-empty')}`,
property,
transformFn: (val) => _toBooleanIfValueEqualsOuiOrNull({ val, translate }),
});
}
});
}

function _includeBillingColumns({ transformationStruct, translate }) {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ describe('Acceptance | Controller | session-controller-import-certification-cand
beforeEach(async function () {
// given
user = databaseBuilder.factory.buildUser();
const certificationCenterId = databaseBuilder.factory.buildCertificationCenter().id;
databaseBuilder.factory.buildCertificationCenterMembership({ userId: user.id, certificationCenterId });
databaseBuilder.factory.buildCertificationCenter({ id: 22 });
databaseBuilder.factory.buildCertificationCenterMembership({ userId: user.id, certificationCenterId: 22 });

const otherUserId = databaseBuilder.factory.buildUser().id;
const otherCertificationCenterId = databaseBuilder.factory.buildCertificationCenter().id;
Expand All @@ -44,7 +44,7 @@ describe('Acceptance | Controller | session-controller-import-certification-cand
certificationCenterId: otherCertificationCenterId,
});

sessionIdAllowed = databaseBuilder.factory.buildSession({ certificationCenterId }).id;
sessionIdAllowed = databaseBuilder.factory.buildSession({ certificationCenterId: 22 }).id;

databaseBuilder.factory.buildCertificationCpfCountry({
code: '99100',
Expand Down Expand Up @@ -85,6 +85,35 @@ describe('Acceptance | Controller | session-controller-import-certification-cand
// then
expect(response.statusCode).to.equal(204);
});

context('when there is one candidate registered for a complementary certification', function () {
it('should return an 204 status after success in importing the ods file', async function () {
// given
databaseBuilder.factory.buildComplementaryCertification({
id: 99,
key: 'PRO_SANTE',
label: 'Label de bonne santé',
});

databaseBuilder.factory.buildComplementaryCertificationHabilitation({
complementaryCertificationId: 99,
certificationCenterId: 22,
});

await databaseBuilder.commit();

const odsFileName =
'files/1.5/import-certification-candidates-reports-categorization-test-complementary-ok.ods';
const odsFilePath = `${__dirname}/${odsFileName}`;
const options = generateOptions({ odsFilePath, userId: user.id, sessionId: sessionIdAllowed });

// when
const response = await server.inject(options);

// then
expect(response.statusCode).to.equal(204);
});
});
});

context("The ODS file contains birthdate with special format ( 'DD/MM/YYYY )", function () {
Expand Down

0 comments on commit f5b0655

Please sign in to comment.