Skip to content

Commit 7bd3a31

Browse files
authored
feat(api): filter v3 attestations in downloadCertificationAttestationsForDivision
1 parent 00a0dc3 commit 7bd3a31

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

api/src/certification/results/application/certificate-controller.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ const downloadDivisionCertificates = async function (
140140
division,
141141
});
142142

143-
if (certificates.every((certificate) => certificate instanceof V3CertificationAttestation)) {
143+
if (certificates.some((certificate) => certificate instanceof V3CertificationAttestation)) {
144+
const v3Certificates = certificates.filter((certificate) => certificate instanceof V3CertificationAttestation);
145+
144146
const normalizedDivision = normalizeAndRemoveAccents(division);
145147

146148
const translatedFileName = i18n.__('certification-confirmation.file-name', {
@@ -150,7 +152,7 @@ const downloadDivisionCertificates = async function (
150152
return h
151153
.response(
152154
dependencies.v3CertificationAttestationPdf.generate({
153-
certificates,
155+
certificates: v3Certificates,
154156
i18n,
155157
}),
156158
)

api/tests/certification/results/unit/application/certificate-controller_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ describe('Certification | Results | Unit | Application | certificate-controller'
418418
clock.restore();
419419
});
420420

421-
describe('when attestations are for v3', function () {
422-
it('should return division attestations in PDF binary format', async function () {
421+
describe('when there are at least one v3 attestation', function () {
422+
it('should return only v3 division attestations in PDF binary format', async function () {
423423
// given
424424
const userId = 1;
425425
const i18n = getI18n();

0 commit comments

Comments
 (0)