Skip to content

Commit 21c5c1c

Browse files
committed
feat(admin): certification registry manager update certification page prerequisites summary block now displays the prerequisites if the certification has them
1 parent 266b849 commit 21c5c1c

File tree

2 files changed

+47
-8
lines changed
  • packages/reva-admin-react

2 files changed

+47
-8
lines changed

packages/reva-admin-react/cypress/e2e/responsable-certifications/certifications/update-certification-page/update-certification-page.cy.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { stubQuery } from "../../../../utils/graphql";
22
import certificationBPBoucher from "./fixtures/certification-bp-boucher.json";
33

4-
function interceptCertification() {
4+
function interceptCertification({
5+
withPrerequisites,
6+
}: {
7+
withPrerequisites?: boolean;
8+
}) {
59
cy.intercept("POST", "/api/graphql", (req) => {
610
stubQuery(
711
req,
@@ -21,6 +25,18 @@ function interceptCertification() {
2125
data: {
2226
getCertification: {
2327
...certificationBPBoucher.data.getCertification,
28+
prerequisites: withPrerequisites
29+
? [
30+
{
31+
id: "71ba9727-eb22-47a1-8731-89263348bf63",
32+
label: "Prerequisite 1",
33+
},
34+
{
35+
id: "2a7f19b0-510f-44cc-b0f6-8648ea0f6cd1",
36+
label: "Prerequisite 2",
37+
},
38+
]
39+
: [],
2440
},
2541
},
2642
},
@@ -30,7 +46,7 @@ function interceptCertification() {
3046

3147
context("when i access the update certification page ", () => {
3248
it("display the page with a correct title", function () {
33-
interceptCertification();
49+
interceptCertification({});
3450

3551
cy.admin(
3652
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b",
@@ -51,7 +67,7 @@ context("when i access the update certification page ", () => {
5167

5268
context("Competence blocs summary card", () => {
5369
it("display the correct number of competence blocs and competences", function () {
54-
interceptCertification();
70+
interceptCertification({});
5571

5672
cy.admin(
5773
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b",
@@ -80,7 +96,7 @@ context("when i access the update certification page ", () => {
8096
});
8197

8298
it("let me click on the 'update competence bloc' button of the first competence bloc and leads me to its update page ", function () {
83-
interceptCertification();
99+
interceptCertification({});
84100

85101
cy.admin(
86102
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b",
@@ -103,7 +119,7 @@ context("when i access the update certification page ", () => {
103119
});
104120

105121
it("let me click on the 'add competence bloc' button and leads me to the create competence bloc page ", function () {
106-
interceptCertification();
122+
interceptCertification({});
107123

108124
cy.admin(
109125
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b",
@@ -125,8 +141,8 @@ context("when i access the update certification page ", () => {
125141
});
126142
});
127143
context("prerequisites summary card", () => {
128-
it("display the a default message when the certification has no prerequisite", function () {
129-
interceptCertification();
144+
it("display a default message when the certification has no prerequisite", function () {
145+
interceptCertification({});
130146

131147
cy.admin(
132148
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b",
@@ -142,5 +158,22 @@ context("when i access the update certification page ", () => {
142158
'[data-test="prerequisites-summary-card"] [data-test="no-prerequisite-message"]',
143159
).should("exist");
144160
});
161+
it("display a lost pf prerequisites if the certification has them", function () {
162+
interceptCertification({ withPrerequisites: true });
163+
164+
cy.admin(
165+
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b",
166+
);
167+
cy.wait("@activeFeaturesForConnectedUser");
168+
cy.wait("@getOrganismForAAPVisibilityCheck");
169+
cy.wait("@getMaisonMereCGUQuery");
170+
cy.wait(
171+
"@getCertificationForCertificationRegistryManagerUpdateCertificationPage",
172+
);
173+
174+
cy.get(
175+
'[data-test="prerequisites-summary-card"] [data-test="prerequisite-list"] > li',
176+
).should("have.length", 2);
177+
});
145178
});
146179
});

packages/reva-admin-react/src/app/responsable-certifications/certifications/[certificationId]/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ const PageContent = ({
6060
title="Prérequis obligatoires"
6161
titleIconClass="fr-icon-success-fill"
6262
>
63-
{certification.prerequisites.length ? null : (
63+
{certification.prerequisites.length ? (
64+
<ul className="ml-10" data-test="prerequisite-list">
65+
{certification.prerequisites.map((p) => (
66+
<li key={p.id}>{p.label}</li>
67+
))}
68+
</ul>
69+
) : (
6470
<p className="ml-10 mb-0" data-test="no-prerequisite-message">
6571
Aucun prérequis renseigné pour cette certification.
6672
</p>

0 commit comments

Comments
 (0)