-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Sélection des acquis accessibles pour proposer un test amén…
- Loading branch information
Showing
19 changed files
with
436 additions
and
51 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...et-next-challenge-for-v2-certification.js → ...et-next-challenge-for-v2-certification.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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { dirname, join } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
import { pickChallengeService } from '../../../../evaluation/domain/services/pick-challenge-service.js'; | ||
import { injectDependencies } from '../../../../shared/infrastructure/utils/dependency-injection.js'; | ||
import { importNamedExportsFromDirectory } from '../../../../shared/infrastructure/utils/import-named-exports-from-directory.js'; | ||
import * as flashAlgorithmService from '../../../flash-certification/domain/services/algorithm-methods/flash.js'; | ||
import { | ||
answerRepository, | ||
assessmentRepository, | ||
assessmentResultRepository, | ||
certificationChallengeRepository, | ||
challengeRepository, | ||
competenceMarkRepository, | ||
cpfExportRepository, | ||
flashAlgorithmConfigurationRepository, | ||
sessionRepositories, | ||
sharedCompetenceMarkRepository, | ||
} from '../../../session-management/infrastructure/repositories/index.js'; | ||
import * as certificationCandidateRepository from '../../infrastructure/repositories/certification-candidate-repository.js'; | ||
|
||
const dependencies = { | ||
...sessionRepositories, | ||
certificationCandidateRepository, | ||
assessmentRepository, | ||
assessmentResultRepository, | ||
answerRepository, | ||
sharedCompetenceMarkRepository, | ||
challengeRepository, | ||
competenceMarkRepository, | ||
cpfExportRepository, | ||
certificationChallengeRepository, | ||
flashAlgorithmConfigurationRepository, | ||
flashAlgorithmService, | ||
pickChallengeService, | ||
}; | ||
|
||
const path = dirname(fileURLToPath(import.meta.url)); | ||
|
||
/** | ||
* Note : current ignoredFileNames are injected in * {@link file://./../../../shared/domain/usecases/index.js} | ||
* This is in progress, because they should be injected in this file and not by shared sub-domain | ||
* The only remaining file ignored should be index.js | ||
*/ | ||
const usecasesWithoutInjectedDependencies = { | ||
...(await importNamedExportsFromDirectory({ | ||
path: join(path, './'), | ||
ignoredFileNames: ['index.js'], | ||
})), | ||
}; | ||
|
||
const usecases = injectDependencies(usecasesWithoutInjectedDependencies, dependencies); | ||
|
||
export { usecases }; |
20 changes: 20 additions & 0 deletions
20
...ertification/evaluation/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,20 @@ | ||
import { knex } from '../../../../../db/knex-database-connection.js'; | ||
import { CertificationCandidateNotFoundError } from '../../../../shared/domain/errors.js'; | ||
import { Candidate } from '../../../enrolment/domain/models/Candidate.js'; | ||
|
||
const findByAssessmentId = async function ({ assessmentId }) { | ||
const result = await knex('certification-candidates') | ||
.select('certification-candidates.*') | ||
.join('certification-courses', 'certification-courses.userId', 'certification-candidates.userId') | ||
.join('assessments', 'assessments.certificationCourseId', 'certification-courses.id') | ||
.where('assessments.id', assessmentId) | ||
.first(); | ||
|
||
if (!result) { | ||
throw new CertificationCandidateNotFoundError(); | ||
} | ||
|
||
return new Candidate(result); | ||
}; | ||
|
||
export { findByAssessmentId }; |
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
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
81 changes: 81 additions & 0 deletions
81
...uation/integration/infrastructure/repositories/certification-candidate-repository_test.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,81 @@ | ||
import * as certificationCandidateRepository from '../../../../../../src/certification/evaluation/infrastructure/repositories/certification-candidate-repository.js'; | ||
import { CertificationCandidateNotFoundError } from '../../../../../../src/shared/domain/errors.js'; | ||
import { Assessment } from '../../../../../../src/shared/domain/models/Assessment.js'; | ||
import { catchErr, databaseBuilder, domainBuilder, expect } from '../../../../../test-helper.js'; | ||
|
||
describe('Integration | Repository | certification candidate', function () { | ||
describe('#findByAssessmentId', function () { | ||
describe('when certification candidate is found', function () { | ||
it('should return the certification candidate', async function () { | ||
// given | ||
const session = databaseBuilder.factory.buildSession(); | ||
const user = databaseBuilder.factory.buildUser(); | ||
const candidate = databaseBuilder.factory.buildCertificationCandidate({ | ||
lastName: 'Joplin', | ||
firstName: 'Janis', | ||
sessionId: session.id, | ||
userId: user.id, | ||
authorizedToStart: false, | ||
}); | ||
const certificationCourse = databaseBuilder.factory.buildCertificationCourse({ | ||
userId: user.id, | ||
sessionId: session.id, | ||
createdAt: new Date('2022-10-01T14:00:00Z'), | ||
}); | ||
const assessmentId = databaseBuilder.factory.buildAssessment({ | ||
certificationCourseId: certificationCourse.id, | ||
state: Assessment.states.STARTED, | ||
}).id; | ||
|
||
await databaseBuilder.commit(); | ||
|
||
// when | ||
const result = await certificationCandidateRepository.findByAssessmentId({ | ||
assessmentId, | ||
}); | ||
|
||
// then | ||
expect(result).to.deep.equal( | ||
domainBuilder.certification.enrolment.buildCandidate({ | ||
...candidate, | ||
subscriptions: [], | ||
}), | ||
); | ||
}); | ||
}); | ||
|
||
describe('when certification candidate is not found', function () { | ||
it('should throw a certification candidate not found error', async function () { | ||
// given | ||
const session = databaseBuilder.factory.buildSession(); | ||
const user = databaseBuilder.factory.buildUser(); | ||
databaseBuilder.factory.buildCertificationCandidate({ | ||
lastName: 'Joplin', | ||
firstName: 'Janis', | ||
sessionId: session.id, | ||
userId: user.id, | ||
authorizedToStart: false, | ||
}); | ||
const certificationCourse = databaseBuilder.factory.buildCertificationCourse({ | ||
userId: user.id, | ||
sessionId: session.id, | ||
createdAt: new Date('2022-10-01T14:00:00Z'), | ||
}); | ||
databaseBuilder.factory.buildAssessment({ | ||
certificationCourseId: certificationCourse.id, | ||
state: Assessment.states.STARTED, | ||
}); | ||
|
||
await databaseBuilder.commit(); | ||
|
||
// when | ||
const error = await catchErr(certificationCandidateRepository.findByAssessmentId)({ | ||
assessmentId: 4659, | ||
}); | ||
|
||
// then | ||
expect(error).to.be.an.instanceOf(CertificationCandidateNotFoundError); | ||
}); | ||
}); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...xt-challenge-for-v2-certification_test.js → ...xt-challenge-for-v2-certification_test.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
Oops, something went wrong.