@@ -19,6 +19,8 @@ describe('UPDATE project type', () => {
1919 question : 'question 1' ,
2020 info : 'info 1' ,
2121 aliases : [ 'key-1' , 'key_1' ] ,
22+ disabled : false ,
23+ hidden : false ,
2224 createdBy : 1 ,
2325 updatedBy : 1 ,
2426 } ;
@@ -38,6 +40,8 @@ describe('UPDATE project type', () => {
3840 question : 'question 1 - update' ,
3941 info : 'info 1 - update' ,
4042 aliases : [ 'key-1-updated' , 'key_1_updated' ] ,
43+ disabled : true ,
44+ hidden : true ,
4145 } ,
4246 } ;
4347
@@ -107,6 +111,8 @@ describe('UPDATE project type', () => {
107111 delete partialBody . param . info ;
108112 delete partialBody . param . question ;
109113 delete partialBody . param . aliases ;
114+ delete partialBody . param . disabled ;
115+ delete partialBody . param . hidden ;
110116 request ( server )
111117 . patch ( `/v4/projectTypes/${ key } ` )
112118 . set ( {
@@ -122,6 +128,8 @@ describe('UPDATE project type', () => {
122128 resJson . info . should . be . eql ( type . info ) ;
123129 resJson . question . should . be . eql ( type . question ) ;
124130 resJson . aliases . should . be . eql ( type . aliases ) ;
131+ resJson . disabled . should . be . eql ( type . disabled ) ;
132+ resJson . hidden . should . be . eql ( type . hidden ) ;
125133 resJson . createdBy . should . be . eql ( type . createdBy ) ;
126134 resJson . createdBy . should . be . eql ( type . createdBy ) ; // should not update createdAt
127135 resJson . updatedBy . should . be . eql ( 40051333 ) ; // admin
@@ -139,6 +147,8 @@ describe('UPDATE project type', () => {
139147 delete partialBody . param . displayName ;
140148 delete partialBody . param . question ;
141149 delete partialBody . param . aliases ;
150+ delete partialBody . param . disabled ;
151+ delete partialBody . param . hidden ;
142152 request ( server )
143153 . patch ( `/v4/projectTypes/${ key } ` )
144154 . set ( {
@@ -154,6 +164,8 @@ describe('UPDATE project type', () => {
154164 resJson . info . should . be . eql ( type . info ) ;
155165 resJson . question . should . be . eql ( type . question ) ;
156166 resJson . aliases . should . be . eql ( type . aliases ) ;
167+ resJson . disabled . should . be . eql ( type . disabled ) ;
168+ resJson . hidden . should . be . eql ( type . hidden ) ;
157169 resJson . createdBy . should . be . eql ( type . createdBy ) ;
158170 resJson . createdBy . should . be . eql ( type . createdBy ) ; // should not update createdAt
159171 resJson . updatedBy . should . be . eql ( 40051333 ) ; // admin
@@ -171,6 +183,8 @@ describe('UPDATE project type', () => {
171183 delete partialBody . param . displayName ;
172184 delete partialBody . param . question ;
173185 delete partialBody . param . aliases ;
186+ delete partialBody . param . disabled ;
187+ delete partialBody . param . hidden ;
174188 request ( server )
175189 . patch ( `/v4/projectTypes/${ key } ` )
176190 . set ( {
@@ -186,6 +200,8 @@ describe('UPDATE project type', () => {
186200 resJson . info . should . be . eql ( partialBody . param . info ) ;
187201 resJson . question . should . be . eql ( type . question ) ;
188202 resJson . aliases . should . be . eql ( type . aliases ) ;
203+ resJson . disabled . should . be . eql ( type . disabled ) ;
204+ resJson . hidden . should . be . eql ( type . hidden ) ;
189205 resJson . createdBy . should . be . eql ( type . createdBy ) ;
190206 resJson . createdBy . should . be . eql ( type . createdBy ) ; // should not update createdAt
191207 resJson . updatedBy . should . be . eql ( 40051333 ) ; // admin
@@ -203,6 +219,8 @@ describe('UPDATE project type', () => {
203219 delete partialBody . param . info ;
204220 delete partialBody . param . displayName ;
205221 delete partialBody . param . aliases ;
222+ delete partialBody . param . disabled ;
223+ delete partialBody . param . hidden ;
206224 request ( server )
207225 . patch ( `/v4/projectTypes/${ key } ` )
208226 . set ( {
@@ -218,6 +236,8 @@ describe('UPDATE project type', () => {
218236 resJson . info . should . be . eql ( type . info ) ;
219237 resJson . question . should . be . eql ( partialBody . param . question ) ;
220238 resJson . aliases . should . be . eql ( type . aliases ) ;
239+ resJson . disabled . should . be . eql ( type . disabled ) ;
240+ resJson . hidden . should . be . eql ( type . hidden ) ;
221241 resJson . createdBy . should . be . eql ( type . createdBy ) ;
222242 resJson . createdBy . should . be . eql ( type . createdBy ) ; // should not update createdAt
223243 resJson . updatedBy . should . be . eql ( 40051333 ) ; // admin
@@ -235,6 +255,8 @@ describe('UPDATE project type', () => {
235255 delete partialBody . param . info ;
236256 delete partialBody . param . question ;
237257 delete partialBody . param . displayName ;
258+ delete partialBody . param . disabled ;
259+ delete partialBody . param . hidden ;
238260 request ( server )
239261 . patch ( `/v4/projectTypes/${ key } ` )
240262 . set ( {
@@ -250,6 +272,8 @@ describe('UPDATE project type', () => {
250272 resJson . info . should . be . eql ( type . info ) ;
251273 resJson . question . should . be . eql ( type . question ) ;
252274 resJson . aliases . should . be . eql ( partialBody . param . aliases ) ;
275+ resJson . disabled . should . be . eql ( type . disabled ) ;
276+ resJson . hidden . should . be . eql ( type . hidden ) ;
253277 resJson . createdBy . should . be . eql ( type . createdBy ) ;
254278 resJson . createdBy . should . be . eql ( type . createdBy ) ; // should not update createdAt
255279 resJson . updatedBy . should . be . eql ( 40051333 ) ; // admin
@@ -261,6 +285,77 @@ describe('UPDATE project type', () => {
261285 } ) ;
262286 } ) ;
263287
288+ it ( 'should return 200 for admin disabled updated' , ( done ) => {
289+ const partialBody = _ . cloneDeep ( body ) ;
290+ delete partialBody . param . icon ;
291+ delete partialBody . param . info ;
292+ delete partialBody . param . question ;
293+ delete partialBody . param . displayName ;
294+ delete partialBody . param . aliases ;
295+ delete partialBody . param . hidden ;
296+ request ( server )
297+ . patch ( `/v4/projectTypes/${ key } ` )
298+ . set ( {
299+ Authorization : `Bearer ${ testUtil . jwts . admin } ` ,
300+ } )
301+ . send ( partialBody )
302+ . expect ( 200 )
303+ . end ( ( err , res ) => {
304+ const resJson = res . body . result . content ;
305+ resJson . key . should . be . eql ( key ) ;
306+ resJson . displayName . should . be . eql ( type . displayName ) ;
307+ resJson . icon . should . be . eql ( type . icon ) ;
308+ resJson . info . should . be . eql ( type . info ) ;
309+ resJson . question . should . be . eql ( type . question ) ;
310+ resJson . aliases . should . be . eql ( type . aliases ) ;
311+ resJson . disabled . should . be . eql ( partialBody . param . disabled ) ;
312+ resJson . hidden . should . be . eql ( type . hidden ) ;
313+ resJson . createdBy . should . be . eql ( type . createdBy ) ;
314+ resJson . createdBy . should . be . eql ( type . createdBy ) ; // should not update createdAt
315+ resJson . updatedBy . should . be . eql ( 40051333 ) ; // admin
316+ should . exist ( resJson . updatedAt ) ;
317+ should . not . exist ( resJson . deletedBy ) ;
318+ should . not . exist ( resJson . deletedAt ) ;
319+
320+ done ( ) ;
321+ } ) ;
322+ } ) ;
323+
324+ it ( 'should return 200 for admin hidden updated' , ( done ) => {
325+ const partialBody = _ . cloneDeep ( body ) ;
326+ delete partialBody . param . icon ;
327+ delete partialBody . param . info ;
328+ delete partialBody . param . question ;
329+ delete partialBody . param . displayName ;
330+ delete partialBody . param . disabled ;
331+ delete partialBody . param . aliases ;
332+ request ( server )
333+ . patch ( `/v4/projectTypes/${ key } ` )
334+ . set ( {
335+ Authorization : `Bearer ${ testUtil . jwts . admin } ` ,
336+ } )
337+ . send ( partialBody )
338+ . expect ( 200 )
339+ . end ( ( err , res ) => {
340+ const resJson = res . body . result . content ;
341+ resJson . key . should . be . eql ( key ) ;
342+ resJson . displayName . should . be . eql ( type . displayName ) ;
343+ resJson . icon . should . be . eql ( type . icon ) ;
344+ resJson . info . should . be . eql ( type . info ) ;
345+ resJson . question . should . be . eql ( type . question ) ;
346+ resJson . aliases . should . be . eql ( type . aliases ) ;
347+ resJson . disabled . should . be . eql ( type . disabled ) ;
348+ resJson . hidden . should . be . eql ( partialBody . param . hidden ) ;
349+ resJson . createdBy . should . be . eql ( type . createdBy ) ; // should not update createdAt
350+ resJson . updatedBy . should . be . eql ( 40051333 ) ; // admin
351+ should . exist ( resJson . updatedAt ) ;
352+ should . not . exist ( resJson . deletedBy ) ;
353+ should . not . exist ( resJson . deletedAt ) ;
354+
355+ done ( ) ;
356+ } ) ;
357+ } ) ;
358+
264359 it ( 'should return 200 for admin all fields updated' , ( done ) => {
265360 request ( server )
266361 . patch ( `/v4/projectTypes/${ key } ` )
@@ -277,7 +372,8 @@ describe('UPDATE project type', () => {
277372 resJson . info . should . be . eql ( body . param . info ) ;
278373 resJson . question . should . be . eql ( body . param . question ) ;
279374 resJson . aliases . should . be . eql ( body . param . aliases ) ;
280- resJson . createdBy . should . be . eql ( type . createdBy ) ;
375+ resJson . disabled . should . be . eql ( body . param . disabled ) ;
376+ resJson . hidden . should . be . eql ( body . param . hidden ) ;
281377 resJson . createdBy . should . be . eql ( type . createdBy ) ; // should not update createdAt
282378 resJson . updatedBy . should . be . eql ( 40051333 ) ; // admin
283379 should . exist ( resJson . updatedAt ) ;
@@ -304,6 +400,8 @@ describe('UPDATE project type', () => {
304400 resJson . info . should . be . eql ( body . param . info ) ;
305401 resJson . question . should . be . eql ( body . param . question ) ;
306402 resJson . aliases . should . be . eql ( body . param . aliases ) ;
403+ resJson . disabled . should . be . eql ( body . param . disabled ) ;
404+ resJson . hidden . should . be . eql ( body . param . hidden ) ;
307405 resJson . createdBy . should . be . eql ( type . createdBy ) ; // should not update createdAt
308406 resJson . updatedBy . should . be . eql ( 40051336 ) ; // connect admin
309407 done ( ) ;
0 commit comments