@@ -329,6 +329,61 @@ describe('Project create', () => {
329329 } ) ;
330330 } ) ;
331331
332+ it ( 'should return 201 if valid user and data (without template id: backward compatibility)' , ( done ) => {
333+ const validBody = _ . cloneDeep ( body ) ;
334+ const mockHttpClient = _ . merge ( testUtil . mockHttpClient , {
335+ post : ( ) => Promise . resolve ( {
336+ status : 200 ,
337+ data : {
338+ id : 'requesterId' ,
339+ version : 'v3' ,
340+ result : {
341+ success : true ,
342+ status : 200 ,
343+ content : {
344+ projectId : 128 ,
345+ } ,
346+ } ,
347+ } ,
348+ } ) ,
349+ } ) ;
350+ sandbox . stub ( util , 'getHttpClient' , ( ) => mockHttpClient ) ;
351+ request ( server )
352+ . post ( '/v4/projects' )
353+ . set ( {
354+ Authorization : `Bearer ${ testUtil . jwts . member } ` ,
355+ } )
356+ . send ( validBody )
357+ . expect ( 'Content-Type' , / j s o n / )
358+ . expect ( 201 )
359+ . end ( ( err , res ) => {
360+ if ( err ) {
361+ done ( err ) ;
362+ } else {
363+ const resJson = res . body . result . content ;
364+ should . exist ( resJson ) ;
365+ should . exist ( resJson . billingAccountId ) ;
366+ should . exist ( resJson . name ) ;
367+ resJson . directProjectId . should . be . eql ( 128 ) ;
368+ resJson . status . should . be . eql ( 'draft' ) ;
369+ resJson . type . should . be . eql ( body . param . type ) ;
370+ resJson . version . should . be . eql ( 'v3' ) ;
371+ resJson . members . should . have . lengthOf ( 1 ) ;
372+ resJson . members [ 0 ] . role . should . be . eql ( 'customer' ) ;
373+ resJson . members [ 0 ] . userId . should . be . eql ( 40051331 ) ;
374+ resJson . members [ 0 ] . projectId . should . be . eql ( resJson . id ) ;
375+ resJson . members [ 0 ] . isPrimary . should . be . truthy ;
376+ resJson . bookmarks . should . have . lengthOf ( 1 ) ;
377+ resJson . bookmarks [ 0 ] . title . should . be . eql ( 'title1' ) ;
378+ resJson . bookmarks [ 0 ] . address . should . be . eql ( 'http://www.address.com' ) ;
379+ server . services . pubsub . publish . calledWith ( 'project.draft-created' ) . should . be . true ;
380+ // should not create phases without a template id
381+ resJson . phases . should . have . lengthOf ( 0 ) ;
382+ done ( ) ;
383+ }
384+ } ) ;
385+ } ) ;
386+
332387 it ( 'should return 201 if valid user and data (with templateId)' , ( done ) => {
333388 const mockHttpClient = _ . merge ( testUtil . mockHttpClient , {
334389 post : ( ) => Promise . resolve ( {
0 commit comments