@@ -20,6 +20,7 @@ import {
2020  Editor , 
2121  LocalRegistry , 
2222  numberOfImpactedOperationsMatcher , 
23+   operationChangesMatcher , 
2324}  from  './helpers' 
2425import  {  ANNOTATION_CHANGE_TYPE ,  BREAKING_CHANGE_TYPE ,  BUILD_TYPE ,  NON_BREAKING_CHANGE_TYPE  }  from  '../src' 
2526
@@ -45,7 +46,7 @@ describe('Changes test', () => {
4546    } ) 
4647  } ) 
4748
48-   test ( 'comparison  should have 1 breaking and 1 annotation changes' ,  async  ( )  =>  { 
49+   test ( 'Comparison  should have 1 breaking and 1 annotation changes' ,  async  ( )  =>  { 
4950    const  editor  =  await  Editor . openProject ( AFTER_PACKAGE_ID ,  afterPackage ) 
5051    const  result  =  await  editor . run ( { 
5152      version : AFTER_VERSION_ID , 
@@ -64,78 +65,130 @@ describe('Changes test', () => {
6465    } ) ) 
6566  } ) 
6667
67-   test ( 'compare parametrized operations' ,  async  ( )  =>  { 
68-     const  result  =  await  buildChangelogPackage ( 'changelog/compare-parametrized-operations' ) 
69-     expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 2  } ) ) 
70-     expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
71-   } ) 
68+   describe ( 'Added/removed/changed operations handling' ,  ( )  =>  { 
69+     test ( 'Add method' ,  async  ( )  =>  { 
70+       const  result  =  await  buildChangelogPackage ( 'changelog/add-method' ) 
71+       expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ NON_BREAKING_CHANGE_TYPE ] : 1  } ) ) 
72+       expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ NON_BREAKING_CHANGE_TYPE ] : 1  } ) ) 
73+     } ) 
7274
73-   test ( 'add  method' ,  async  ( )  =>  { 
74-     const  result  =  await  buildChangelogPackage ( 'changelog/add -method' ) 
75-     expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ NON_BREAKING_CHANGE_TYPE ] : 1  } ) ) 
76-     expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ NON_BREAKING_CHANGE_TYPE ] : 1  } ) ) 
77-   } ) 
75+      test ( 'Remove  method' ,  async  ( )  =>  { 
76+        const  result  =  await  buildChangelogPackage ( 'changelog/remove -method' ) 
77+        expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ BREAKING_CHANGE_TYPE ] : 1  } ) ) 
78+        expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ BREAKING_CHANGE_TYPE ] : 1  } ) ) 
79+      } ) 
7880
79-   test ( 'remove method' ,  async  ( )  =>  { 
80-     const  result  =  await  buildChangelogPackage ( 'changelog/remove-method' ) 
81-     expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ BREAKING_CHANGE_TYPE ] : 1  } ) ) 
82-     expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ BREAKING_CHANGE_TYPE ] : 1  } ) ) 
83-   } ) 
81+     test ( 'Change method content' ,  async  ( )  =>  { 
82+       const  result  =  await  buildChangelogPackage ( 'changelog/change-method' ) 
83+ 
84+       expect ( result ) . toEqual ( changesSummaryMatcher ( { 
85+         [ BREAKING_CHANGE_TYPE ] : 1 , 
86+         [ NON_BREAKING_CHANGE_TYPE ] : 1 , 
87+       } ) ) 
88+       expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( { 
89+         [ BREAKING_CHANGE_TYPE ] : 1 , 
90+         [ NON_BREAKING_CHANGE_TYPE ] : 1 , 
91+       } ) ) 
92+     } ) 
8493
85-   test ( 'change method content' ,  async  ( )  =>  { 
86-     const  result  =  await  buildChangelogPackage ( 'changelog/change-method' ) 
94+     test ( 'Should match moved operations' ,  async  ( )  =>  { 
95+       const  result  =  await  buildChangelogPackage ( 
96+         'changelog/documents-matching' , 
97+         [ {  fileId : 'before/spec1.yaml'  } ,  {  fileId : 'before/spec2.yaml'  } ] , 
98+         [ {  fileId : 'after/spec1.yaml'  } ,  {  fileId : 'after/spec2.yaml'  } ,  {  fileId : 'after/evicted.yaml'  } ] , 
99+       ) 
100+       expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 3  } ) ) 
101+       expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 3  } ) ) 
102+     } ) 
87103
88-     expect ( result ) . toEqual ( changesSummaryMatcher ( { 
89-       [ BREAKING_CHANGE_TYPE ] : 1 , 
90-       [ NON_BREAKING_CHANGE_TYPE ] : 1 , 
91-     } ) ) 
92-     expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( { 
93-       [ BREAKING_CHANGE_TYPE ] : 1 , 
94-       [ NON_BREAKING_CHANGE_TYPE ] : 1 , 
95-     } ) ) 
104+     test ( 'Compare parametrized operations' ,  async  ( )  =>  { 
105+       const  result  =  await  buildChangelogPackage ( 'changelog/compare-parametrized-operations' ) 
106+       expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 2  } ) ) 
107+       expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
108+     } ) 
96109  } ) 
97110
98-   test ( 'should match moved operations' ,  async  ( )  =>  { 
99-     const  result  =  await  buildChangelogPackage ( 
100-       'changelog/documents-matching' , 
101-       [ {  fileId : 'before/spec1.yaml'  } ,  {  fileId : 'before/spec2.yaml'  } ] , 
102-       [ {  fileId : 'after/spec1.yaml'  } ,  {  fileId : 'after/spec2.yaml'  } ,  {  fileId : 'after/evicted.yaml'  } ] , 
103-     ) 
104-     expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 3  } ) ) 
105-     expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 3  } ) ) 
106-   } ) 
111+   describe ( 'Diffs collecting in the root-level properties' ,  ( )  =>  { 
112+     test ( 'Add root servers' ,  async  ( )  =>  { 
113+       const  result  =  await  buildChangelogPackage ( 'changelog/add-root-servers' ) 
107114
108-   test ( 'add root servers' ,  async  ( )  =>  { 
109-     const  result  =  await  buildChangelogPackage ( 'changelog/add-root-servers' ) 
115+       expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
116+       expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
117+     } ) 
110118
111-     expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
112-     expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
113-   } ) 
119+     test ( 'Change root servers' ,  async  ( )  =>  { 
120+       const  result  =  await  buildChangelogPackage ( 'changelog/change-root-servers' ) 
114121
115-   test ( 'change root servers' ,  async  ( )  =>  { 
116-     const  result  =  await  buildChangelogPackage ( 'changelog/change-root-servers' ) 
122+       expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
123+       expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
124+     } ) 
117125
118-     expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
119-     expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ ANNOTATION_CHANGE_TYPE ] : 1  } ) ) 
120-   } ) 
126+     test ( 'Add security' ,  async  ( )  =>  { 
127+       const  result  =  await  buildChangelogPackage ( 'changelog/add-security' ) 
121128
122-   test ( 'add security' ,  async  ( )  =>  { 
123-     const  result  =  await  buildChangelogPackage ( 'changelog/add-security' ) 
129+       expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ BREAKING_CHANGE_TYPE ] : 2  } ) ) 
130+       expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ BREAKING_CHANGE_TYPE ] : 1  } ) ) 
131+     } ) 
124132
125-     expect ( result ) . toEqual ( changesSummaryMatcher ( {  [ BREAKING_CHANGE_TYPE ] : 2  } ) ) 
126-     expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( {  [ BREAKING_CHANGE_TYPE ] : 1  } ) ) 
133+     test ( 'Add securityScheme' ,  async  ( )  =>  { 
134+       const  result  =  await  buildChangelogPackage ( 'changelog/add-securityScheme' ) 
135+ 
136+       expect ( result ) . toEqual ( changesSummaryMatcher ( { 
137+         [ BREAKING_CHANGE_TYPE ] : 1 , 
138+         [ NON_BREAKING_CHANGE_TYPE ] : 1 , 
139+       } ) ) 
140+       expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( { 
141+         [ BREAKING_CHANGE_TYPE ] : 1 , 
142+         [ NON_BREAKING_CHANGE_TYPE ] : 1 , 
143+       } ) ) 
144+     } ) 
127145  } ) 
128146
129-   test ( 'add securityScheme' ,  async  ( )  =>  { 
130-     const  result  =  await  buildChangelogPackage ( 'changelog/add-securityScheme' ) 
147+   test ( 'Operation changes fields are correct (REST)' ,  async  ( )  =>  { 
148+     const  result  =  await  buildChangelogPackage ( 'changelog/operation-changes-fields-rest' ) 
149+ 
150+     expect ( result ) . toEqual ( operationChangesMatcher ( [ 
151+       expect . objectContaining ( { 
152+         previousOperationId : 'order-id-post' , 
153+         operationId : 'order-orderid-post' , 
154+         previousMetadata : { 
155+           'title' : 'create order 1' , 
156+           'tags' : [ 'tag1' ] , 
157+           'method' : 'post' , 
158+           'path' : '/order/*' , 
159+         } , 
160+         metadata : { 
161+           'title' : 'create order 2' , 
162+           'tags' : [ 'tag1' ,  'tag2' ] , 
163+           'method' : 'post' , 
164+           'path' : '/order/*' , 
165+         } , 
166+         // rest of the fields are covered by dedicated tests 
167+       } ) , 
168+     ] ) ) 
169+   } ) 
131170
132-     expect ( result ) . toEqual ( changesSummaryMatcher ( { 
133-       [ BREAKING_CHANGE_TYPE ] : 1 , 
134-       [ NON_BREAKING_CHANGE_TYPE ] : 1 , 
135-     } ) ) 
136-     expect ( result ) . toEqual ( numberOfImpactedOperationsMatcher ( { 
137-       [ BREAKING_CHANGE_TYPE ] : 1 , 
138-       [ NON_BREAKING_CHANGE_TYPE ] : 1 , 
139-     } ) ) 
171+   test ( 'Operation changes fields are correct (GQL)' ,  async  ( )  =>  { 
172+     const  result  =  await  buildChangelogPackage ( 'changelog/operation-changes-fields-gql' ,  [ {  fileId : 'before.graphql'  } ] ,  [ {  fileId : 'after.graphql'  } ] ) 
173+ 
174+     expect ( result ) . toEqual ( operationChangesMatcher ( [ 
175+       expect . objectContaining ( { 
176+         previousOperationId : 'query-fruits' , 
177+         operationId : 'query-fruits' , 
178+         previousMetadata : { 
179+           'title' : 'Fruits' , 
180+           'tags' : [ 'queries' ] , 
181+           'method' : 'fruits' , 
182+           'type' : 'query' , 
183+         } , 
184+         metadata : { 
185+           'title' : 'Fruits' , 
186+           'tags' : [ 'queries' ] , 
187+           'method' : 'fruits' , 
188+           'type' : 'query' , 
189+         } , 
190+         // rest of the fields are covered by dedicated tests 
191+       } ) , 
192+     ] ) ) 
140193  } ) 
141194} ) 
0 commit comments