Skip to content

Commit

Permalink
🐛 api: use getAllWithSameTargetProfile to verify subscriptions
Browse files Browse the repository at this point in the history
Co-authored-by: P-Jeremy < [email protected]>
  • Loading branch information
Steph0 and P-Jeremy committed Oct 8, 2024
1 parent 2d36574 commit ec36e85
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
3 changes: 3 additions & 0 deletions api/src/certification/enrolment/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as attendanceSheetPdfUtils from '../../../enrolment/infrastructure/util
import * as certificationBadgesService from '../../../shared/domain/services/certification-badges-service.js';
import * as certificationCpfService from '../../../shared/domain/services/certification-cpf-service.js';
import * as sessionValidator from '../../../shared/domain/validators/session-validator.js';
import * as complementaryCertificationBadgesRepository from '../../../shared/infrastructure/repositories/complementary-certification-badge-repository.js';
import { enrolmentRepositories } from '../../infrastructure/repositories/index.js';
import * as certificationCandidatesOdsService from '../services/certification-candidates-ods-service.js';
import * as sessionCodeService from '../services/session-code-service.js';
Expand Down Expand Up @@ -68,6 +69,7 @@ import * as temporarySessionsStorageForMassImportService from '../services/tempo
* @typedef {CertificationCandidatesOdsService} CertificationCandidatesOdsService
* @typedef {PlacementProfileService} PlacementProfileService
* @typedef {LanguageService} LanguageService
* @typedef {complementaryCertificationBadgesRepository} ComplementaryCertificationBadgesRepository
**/
const dependencies = {
certificationBadgesService,
Expand All @@ -81,6 +83,7 @@ const dependencies = {
certificationCandidatesOdsService,
placementProfileService,
languageService,
complementaryCertificationBadgesRepository,
};

const path = dirname(fileURLToPath(import.meta.url));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* @typedef {import ('./index.js').SessionRepository} SessionRepository
* @typedef {import ('./index.js').PixCertificationRepository} PixCertificationRepository
* @typedef {import ('./index.js').ComplementaryCertificationBadgeWithOffsetVersionRepository} ComplementaryCertificationBadgeWithOffsetVersionRepository
* @typedef {import ('./index.js').ComplementaryCertificationBadgesRepository} ComplementaryCertificationBadgesRepository
* @typedef {import ('./index.js').CertificationBadgesService} CertificationBadgesService
* @typedef {import ('./index.js').PlacementProfileService} PlacementProfileService
* @typedef {import ('../../../../shared/domain/models/index.js').CertifiableBadgeAcquisition} CertifiableBadgeAcquisition
*/
import _ from 'lodash';

Expand All @@ -16,7 +17,7 @@ import { CertificationCandidateEligibilityError } from '../errors.js';
* @param {Object} params
* @param {SessionRepository} params.sessionRepository
* @param {PixCertificationRepository} params.pixCertificationRepository
* @param {ComplementaryCertificationBadgeWithOffsetVersionRepository} params.complementaryCertificationBadgeWithOffsetVersionRepository
* @param {ComplementaryCertificationBadgesRepository} params.complementaryCertificationBadgesRepository
* @param {PlacementProfileService} params.placementProfileService
* @param {CertificationBadgesService} params.certificationBadgesService
*
Expand All @@ -29,7 +30,7 @@ export async function verifyCandidateSubscriptions({
sessionId,
sessionRepository,
pixCertificationRepository,
complementaryCertificationBadgeWithOffsetVersionRepository,
complementaryCertificationBadgesRepository,
placementProfileService,
certificationBadgesService,
}) {
Expand Down Expand Up @@ -71,10 +72,10 @@ export async function verifyCandidateSubscriptions({
throw new CertificationCandidateEligibilityError();
}

// PB CE NE SONT PAS DES BADGES QUI CORRESPONDENT A LA BDD (PAS DE DETACHEDAT, NI CE COMPLE_CERT_ID) ET ON S'EN FOUT DU OFFSET ET CURRENT ICI
// LE MODELE RENVOYE NE CORRESPOND PAS AU BESOIN
// LE REPO UTILISE ICI NE FAIT PAS VRAIMENT CE QUI EST ATTENDU DE BASE MAIS PAS BLOQUANT POUR CETTE PR
const complementaryCertificationBadges = await complementaryCertificationBadgeWithOffsetVersionRepository.findAll();
const complementaryCertificationBadges =
await complementaryCertificationBadgesRepository.getAllWithSameTargetProfile(
subscribedHighestBadgeAcquisition.complementaryCertificationBadgeId,
);

const userComplementaryCertificationBadgesSortedByLevel =
_getSubscribedComplementaryCertificationBadgesSortedByLevel(complementaryCertificationBadges, candidate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ describe('Certification | Enrolment | Unit | Domain | UseCase | verify-candidate
dependencies.placementProfileService = {
getPlacementProfile: sinon.stub().resolves({ isCertifiable: sinon.stub().returns(true) }),
};
dependencies.complementaryCertificationBadgeWithOffsetVersionRepository = {
findAll: sinon.stub(),
dependencies.complementaryCertificationBadgesRepository = {
getAllWithSameTargetProfile: sinon.stub(),
};
});

Expand Down Expand Up @@ -310,7 +310,7 @@ describe('Certification | Enrolment | Unit | Domain | UseCase | verify-candidate
}),
]);

dependencies.complementaryCertificationBadgeWithOffsetVersionRepository.findAll.resolves([
dependencies.complementaryCertificationBadgesRepository.getAllWithSameTargetProfile.resolves([
...complementaryCertificationBadges,
domainBuilder.certification.complementary.buildComplementaryCertificationBadge({
id: 9865,
Expand Down Expand Up @@ -376,7 +376,7 @@ describe('Certification | Enrolment | Unit | Domain | UseCase | verify-candidate
}),
]);

dependencies.complementaryCertificationBadgeWithOffsetVersionRepository.findAll.resolves([
dependencies.complementaryCertificationBadgesRepository.getAllWithSameTargetProfile.resolves([
...complementaryCertificationBadges,
domainBuilder.certification.complementary.buildComplementaryCertificationBadge({
id: 9865,
Expand Down Expand Up @@ -443,7 +443,7 @@ describe('Certification | Enrolment | Unit | Domain | UseCase | verify-candidate
}),
]);

dependencies.complementaryCertificationBadgeWithOffsetVersionRepository.findAll.resolves([
dependencies.complementaryCertificationBadgesRepository.getAllWithSameTargetProfile.resolves([
...complementaryCertificationBadges,
domainBuilder.certification.complementary.buildComplementaryCertificationBadge({
id: 9865,
Expand Down Expand Up @@ -510,7 +510,7 @@ describe('Certification | Enrolment | Unit | Domain | UseCase | verify-candidate
}),
]);

dependencies.complementaryCertificationBadgeWithOffsetVersionRepository.findAll.resolves([
dependencies.complementaryCertificationBadgesRepository.getAllWithSameTargetProfile.resolves([
...complementaryCertificationBadges,
domainBuilder.certification.complementary.buildComplementaryCertificationBadge({
id: 9865,
Expand Down

0 comments on commit ec36e85

Please sign in to comment.