@@ -293,69 +293,70 @@ describe("Mutation.updateForm", () => {
293293 expect ( errors ) . toBeUndefined ( ) ;
294294 } ) ;
295295
296- it ( "should not be possible to update intermediaries when emitter has signed" , async ( ) => {
297- const emitter = await userWithCompanyFactory ( "ADMIN" ) ;
298- const destination = await userWithCompanyFactory ( "ADMIN" , {
299- companyTypes : [ CompanyType . WASTEPROCESSOR ] ,
300- wasteProcessorTypes : [ WasteProcessorType . DANGEROUS_WASTES_INCINERATION ]
301- } ) ;
302- const intermediary1 = await companyFactory ( ) ;
303- const intermediary2 = await companyFactory ( ) ;
304- const form = await formFactory ( {
305- ownerId : emitter . user . id ,
306- opt : {
307- status : "SIGNED_BY_PRODUCER" ,
308- emitterCompanySiret : emitter . company . siret ,
309- recipientCompanySiret : destination . company . siret ,
310- emittedAt : new Date ( ) ,
311- intermediaries : { create : toIntermediaryCompany ( intermediary1 ) }
312- }
313- } ) ;
314- const { mutate } = makeClient ( destination . user ) ;
296+ it ( "should not be possible to update intermediaries when form is RECEIVED" , async ( ) => {
297+ const emitter = await userWithCompanyFactory ( "ADMIN" ) ;
298+ const destination = await userWithCompanyFactory ( "ADMIN" , {
299+ companyTypes : [ CompanyType . WASTEPROCESSOR ] ,
300+ wasteProcessorTypes : [ WasteProcessorType . DANGEROUS_WASTES_INCINERATION ]
301+ } ) ;
302+ const intermediary1 = await companyFactory ( ) ;
303+ const intermediary2 = await companyFactory ( ) ;
304+ const form = await formFactory ( {
305+ ownerId : emitter . user . id ,
306+ opt : {
307+ status : "RECEIVED" ,
308+ emitterCompanySiret : emitter . company . siret ,
309+ recipientCompanySiret : destination . company . siret ,
310+ emittedAt : new Date ( ) ,
311+ receivedAt : new Date ( ) ,
312+ intermediaries : { create : toIntermediaryCompany ( intermediary1 ) }
313+ }
314+ } ) ;
315+ const { mutate } = makeClient ( destination . user ) ;
315316
316317 // Try changing the list of intermediaries
317- const { errors : errors1 } = await mutate <
318- Pick < Mutation , "updateForm" > ,
319- MutationUpdateFormArgs
320- > ( UPDATE_FORM , {
321- variables : {
322- updateFormInput : {
323- id : form . id ,
324- intermediaries : [ toIntermediaryCompany ( intermediary2 ) ]
325- }
318+ const { errors : errors1 } = await mutate <
319+ Pick < Mutation , "updateForm" > ,
320+ MutationUpdateFormArgs
321+ > ( UPDATE_FORM , {
322+ variables : {
323+ updateFormInput : {
324+ id : form . id ,
325+ intermediaries : [ toIntermediaryCompany ( intermediary2 ) ]
326326 }
327- } ) ;
327+ }
328+ } ) ;
328329
329- expect ( errors1 ) . toEqual ( [
330- expect . objectContaining ( {
331- message :
332- "Des champs ont été verrouillés via signature et ne peuvent plus être modifiés : intermediaries"
333- } )
334- ] ) ;
330+ expect ( errors1 ) . toEqual ( [
331+ expect . objectContaining ( {
332+ message :
333+ "Des champs ont été verrouillés via signature et ne peuvent plus être modifiés : intermediaries"
334+ } )
335+ ] ) ;
335336
336337 // Try changing one field on the same intermediary
337- const { errors : errors2 } = await mutate <
338- Pick < Mutation , "updateForm" > ,
339- MutationUpdateFormArgs
340- > ( UPDATE_FORM , {
341- variables : {
342- updateFormInput : {
343- id : form . id ,
344- intermediaries : [
345- { ...toIntermediaryCompany ( intermediary2 ) , name : "new name" }
346- ]
347- }
338+ const { errors : errors2 } = await mutate <
339+ Pick < Mutation , "updateForm" > ,
340+ MutationUpdateFormArgs
341+ > ( UPDATE_FORM , {
342+ variables : {
343+ updateFormInput : {
344+ id : form . id ,
345+ intermediaries : [
346+ { ...toIntermediaryCompany ( intermediary2 ) , name : "new name" }
347+ ]
348348 }
349- } ) ;
350-
351- expect ( errors2 ) . toEqual ( [
352- expect . objectContaining ( {
353- message :
354- "Des champs ont été verrouillés via signature et ne peuvent plus être modifiés : intermediaries"
355- } )
356- ] ) ;
349+ }
357350 } ) ;
358351
352+ expect ( errors2 ) . toEqual ( [
353+ expect . objectContaining ( {
354+ message :
355+ "Des champs ont été verrouillés via signature et ne peuvent plus être modifiés : intermediaries"
356+ } )
357+ ] ) ;
358+ } ) ;
359+
359360 it ( "should be possible to resend same intermediaries data when emitter has signed" , async ( ) => {
360361 const emitter = await userWithCompanyFactory ( "ADMIN" ) ;
361362 const destination = await userWithCompanyFactory ( "ADMIN" , {
0 commit comments