@@ -14,6 +14,7 @@ describe('Review Object Controller Integration Tests', () => {
1414 let autoApproveReviewUUID
1515 let autoRejectReviewUUID
1616 let adminRetrievalTestReviewUUID
17+ let modifyApproveTestReviewUUID
1718
1819 context ( 'Positive Tests' , ( ) => {
1920 it ( 'Creates an organization to use for review object tests' , async ( ) => {
@@ -240,6 +241,58 @@ describe('Review Object Controller Integration Tests', () => {
240241 expect ( res . body ) . to . have . property ( 'status' , 'approved' )
241242 } )
242243
244+ it ( 'Nonsecretariat user can update an organization, creates review object for modify-on-approve test' , async ( ) => {
245+ const updateData = { }
246+ updateData . short_name = constants . existingOrg . short_name
247+ updateData . long_name = 'Original Pending Organization'
248+ updateData . authority = [ 'CNA' ]
249+ updateData . hard_quota = 1000
250+ const res = await chai
251+ . request ( app )
252+ . put ( `/api/registry/org/${ constants . existingOrg . short_name } ` )
253+ . set ( { ...constants . nonSecretariatUserHeaders2 } )
254+ . send ( updateData )
255+ expect ( res ) . to . have . status ( 200 )
256+
257+ const reviewRes = await chai
258+ . request ( app )
259+ . get ( `/api/review/org/${ constants . existingOrg . short_name } ` )
260+ . set ( { ...constants . headers } )
261+ expect ( reviewRes ) . to . have . status ( 200 )
262+ expect ( reviewRes . body ) . to . have . property ( 'uuid' )
263+ expect ( reviewRes . body . status ) . to . equal ( 'pending' )
264+ expect ( reviewRes . body ) . to . have . nested . property ( 'new_review_data.long_name' , 'Original Pending Organization' )
265+ modifyApproveTestReviewUUID = reviewRes . body . uuid
266+ } )
267+
268+ it ( 'Approves a review object with modifications and updates the organization and review object history' , async ( ) => {
269+ const modifiedData = {
270+ short_name : constants . existingOrg . short_name ,
271+ long_name : 'Modified Approved Organization' ,
272+ authority : [ 'CNA' ] ,
273+ hard_quota : 2000
274+ }
275+ const res = await chai
276+ . request ( app )
277+ . put ( `/api/review/${ modifyApproveTestReviewUUID } /approve` )
278+ . set ( { ...constants . headers } )
279+ . send ( modifiedData )
280+ expect ( res ) . to . have . status ( 200 )
281+ expect ( res . body ) . to . have . property ( 'long_name' , 'Modified Approved Organization' )
282+ expect ( res . body ) . to . have . property ( 'hard_quota' , 2000 )
283+ } )
284+
285+ it ( 'Verifies the review object status is now approved and new_review_data reflects the modifications' , async ( ) => {
286+ const res = await chai
287+ . request ( app )
288+ . get ( `/api/review/byUUID/${ modifyApproveTestReviewUUID } ` )
289+ . set ( { ...constants . headers } )
290+ expect ( res ) . to . have . status ( 200 )
291+ expect ( res . body ) . to . have . property ( 'status' , 'approved' )
292+ expect ( res . body ) . to . have . nested . property ( 'new_review_data.long_name' , 'Modified Approved Organization' )
293+ expect ( res . body ) . to . have . nested . property ( 'new_review_data.hard_quota' , 2000 )
294+ } )
295+
243296 it ( 'Create new review object for rejection testing' , async ( ) => {
244297 const updateData = { }
245298 updateData . short_name = constants . existingOrg . short_name
0 commit comments