1
1
import { stubQuery } from "../../../../utils/graphql" ;
2
2
import certificationBPBoucher from "./fixtures/certification-bp-boucher.json" ;
3
3
4
- function interceptCertification ( ) {
4
+ function interceptCertification ( {
5
+ withPrerequisites,
6
+ } : {
7
+ withPrerequisites ?: boolean ;
8
+ } ) {
5
9
cy . intercept ( "POST" , "/api/graphql" , ( req ) => {
6
10
stubQuery (
7
11
req ,
@@ -21,6 +25,18 @@ function interceptCertification() {
21
25
data : {
22
26
getCertification : {
23
27
...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
+ : [ ] ,
24
40
} ,
25
41
} ,
26
42
} ,
@@ -30,7 +46,7 @@ function interceptCertification() {
30
46
31
47
context ( "when i access the update certification page " , ( ) => {
32
48
it ( "display the page with a correct title" , function ( ) {
33
- interceptCertification ( ) ;
49
+ interceptCertification ( { } ) ;
34
50
35
51
cy . admin (
36
52
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b" ,
@@ -51,7 +67,7 @@ context("when i access the update certification page ", () => {
51
67
52
68
context ( "Competence blocs summary card" , ( ) => {
53
69
it ( "display the correct number of competence blocs and competences" , function ( ) {
54
- interceptCertification ( ) ;
70
+ interceptCertification ( { } ) ;
55
71
56
72
cy . admin (
57
73
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b" ,
@@ -80,7 +96,7 @@ context("when i access the update certification page ", () => {
80
96
} ) ;
81
97
82
98
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 ( { } ) ;
84
100
85
101
cy . admin (
86
102
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b" ,
@@ -103,7 +119,7 @@ context("when i access the update certification page ", () => {
103
119
} ) ;
104
120
105
121
it ( "let me click on the 'add competence bloc' button and leads me to the create competence bloc page " , function ( ) {
106
- interceptCertification ( ) ;
122
+ interceptCertification ( { } ) ;
107
123
108
124
cy . admin (
109
125
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b" ,
@@ -125,8 +141,8 @@ context("when i access the update certification page ", () => {
125
141
} ) ;
126
142
} ) ;
127
143
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 ( { } ) ;
130
146
131
147
cy . admin (
132
148
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b" ,
@@ -142,5 +158,22 @@ context("when i access the update certification page ", () => {
142
158
'[data-test="prerequisites-summary-card"] [data-test="no-prerequisite-message"]' ,
143
159
) . should ( "exist" ) ;
144
160
} ) ;
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
+ } ) ;
145
178
} ) ;
146
179
} ) ;
0 commit comments