-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Utiliser la date de réconciliation du candidat dans le serv…
- Loading branch information
Showing
19 changed files
with
330 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
api/src/certification/session-management/domain/models/CertificationCandidate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CertificationCandidate { | ||
/** | ||
* @param {Object} param | ||
* @param {number} param.userId | ||
* @param {Date} param.reconciledAt | ||
*/ | ||
constructor({ userId, reconciledAt } = {}) { | ||
this.userId = userId; | ||
this.reconciledAt = reconciledAt; | ||
} | ||
} | ||
|
||
export { CertificationCandidate }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...tion/session-management/infrastructure/repositories/certification-candidate-repository.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { DomainTransaction } from '../../../../shared/domain/DomainTransaction.js'; | ||
import { NotFoundError } from '../../../../shared/domain/errors.js'; | ||
import { CertificationCandidate } from '../../domain/models/CertificationCandidate.js'; | ||
|
||
export const getByCertificationCourseId = async ({ certificationCourseId }) => { | ||
const knexConn = DomainTransaction.getConnection(); | ||
const certificationCandidate = await knexConn('certification-courses') | ||
.select('certification-candidates.userId', 'certification-candidates.reconciledAt') | ||
.innerJoin('sessions', 'sessions.id', 'certification-courses.sessionId') | ||
.innerJoin('certification-candidates', 'sessions.id', 'certification-candidates.sessionId') | ||
.where('certification-courses.id', '=', certificationCourseId) | ||
.first(); | ||
|
||
if (!certificationCandidate) { | ||
throw new NotFoundError(); | ||
} | ||
|
||
return _toDomain(certificationCandidate); | ||
}; | ||
|
||
const _toDomain = (candidateData) => { | ||
return new CertificationCandidate({ userId: candidateData.userId, reconciledAt: candidateData.reconciledAt }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,12 +138,21 @@ describe('Integration | Repository | CertificationCandidate', function () { | |
describe('#getBySessionIdAndUserId', function () { | ||
let userId; | ||
let complementaryCertificationId; | ||
let certificationCandidateId; | ||
let createdAt, reconciledAt; | ||
|
||
beforeEach(function () { | ||
// given | ||
createdAt = new Date('2000-01-01'); | ||
reconciledAt = new Date('2020-01-02'); | ||
userId = databaseBuilder.factory.buildUser().id; | ||
complementaryCertificationId = databaseBuilder.factory.buildComplementaryCertification().id; | ||
const certificationCandidateId = databaseBuilder.factory.buildCertificationCandidate({ sessionId, userId }).id; | ||
certificationCandidateId = databaseBuilder.factory.buildCertificationCandidate({ | ||
sessionId, | ||
userId, | ||
createdAt, | ||
reconciledAt, | ||
}).id; | ||
databaseBuilder.factory.buildCoreSubscription({ certificationCandidateId }); | ||
databaseBuilder.factory.buildComplementaryCertificationSubscription({ | ||
complementaryCertificationId, | ||
|
@@ -156,13 +165,52 @@ describe('Integration | Repository | CertificationCandidate', function () { | |
context('when there is one certification candidate with the given session id and user id', function () { | ||
it('should fetch the candidate', async function () { | ||
// when | ||
const actualCandidates = await certificationCandidateRepository.getBySessionIdAndUserId({ sessionId, userId }); | ||
const actualCandidate = await certificationCandidateRepository.getBySessionIdAndUserId({ sessionId, userId }); | ||
|
||
// then | ||
expect(actualCandidates.sessionId).to.equal(sessionId); | ||
expect(actualCandidates.userId).to.equal(userId); | ||
expect(actualCandidates.complementaryCertification).not.to.be.null; | ||
expect(actualCandidates.complementaryCertification.id).to.equal(complementaryCertificationId); | ||
expect(actualCandidate).to.deep.equal({ | ||
accessibilityAdjustmentNeeded: false, | ||
authorizedToStart: false, | ||
billingMode: null, | ||
birthCity: 'PARIS 1', | ||
birthCountry: 'France', | ||
birthINSEECode: '75101', | ||
birthPostalCode: null, | ||
birthProvinceCode: null, | ||
birthdate: '2000-01-04', | ||
complementaryCertification: { | ||
id: complementaryCertificationId, | ||
key: 'DROIT', | ||
label: 'UneSuperCertifComplémentaire', | ||
}, | ||
createdAt, | ||
email: '[email protected]', | ||
externalId: 'externalId', | ||
extraTimePercentage: 0.3, | ||
firstName: 'first-name', | ||
hasSeenCertificationInstructions: false, | ||
id: certificationCandidateId, | ||
lastName: 'last-name', | ||
organizationLearnerId: null, | ||
prepaymentCode: null, | ||
reconciledAt, | ||
resultRecipientEmail: '[email protected]', | ||
sessionId, | ||
sex: 'M', | ||
subscriptions: [ | ||
{ | ||
certificationCandidateId: undefined, | ||
complementaryCertificationId: null, | ||
type: 'CORE', | ||
}, | ||
{ | ||
certificationCandidateId, | ||
complementaryCertificationId, | ||
type: 'COMPLEMENTARY', | ||
}, | ||
], | ||
userId: userId, | ||
}); | ||
}); | ||
}); | ||
|
||
|
Oops, something went wrong.