Skip to content

Commit

Permalink
✅ api: Add tests for candidate import ods
Browse files Browse the repository at this point in the history
There were no test for the complementary certification columns

Co-authored-by: Steph0 <[email protected]>
  • Loading branch information
aceol and Steph0 authored May 30, 2024
1 parent 0c8ba8b commit c3269ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
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 c3269ad

Please sign in to comment.