@@ -3,7 +3,7 @@ import sinon from "sinon";
3
3
import generateFlexChangesBundle from "../../../../lib/tasks/bundlers/generateFlexChangesBundle.js" ;
4
4
5
5
6
- function createDummyResource ( content ) {
6
+ function createPlaceholderResource ( content ) {
7
7
return {
8
8
name : "file" ,
9
9
getBuffer : async ( ) => JSON . stringify ( content ) ,
@@ -12,14 +12,14 @@ function createDummyResource(content) {
12
12
} ;
13
13
}
14
14
15
- function createDummyWorkspace ( changes , manifest , flexBundle ) {
15
+ function createPlaceholderWorkspace ( changes , manifest , flexBundle ) {
16
16
return {
17
- byGlob : async ( path ) => changes . map ( createDummyResource ) ,
17
+ byGlob : async ( path ) => changes . map ( createPlaceholderResource ) ,
18
18
byPath : async ( path ) => {
19
19
if ( path . includes ( "manifest.json" ) ) {
20
- return createDummyResource ( manifest ) ;
20
+ return createPlaceholderResource ( manifest ) ;
21
21
} else if ( path . includes ( "flexibility-bundle.json" ) ) {
22
- return createDummyResource ( flexBundle ) ;
22
+ return createPlaceholderResource ( flexBundle ) ;
23
23
}
24
24
} ,
25
25
write : ( ) => {
@@ -28,123 +28,207 @@ function createDummyWorkspace(changes, manifest, flexBundle) {
28
28
} ;
29
29
}
30
30
31
- test . serial ( "execute flexChangeBundler" , async ( t ) => {
32
- const changeList = [
33
- {
34
- "fileName" : "id_1504764957625_7_rename1" ,
35
- "fileType" : "change" ,
36
- "changeType" : "rename" ,
37
- "reference" : "rta.performance.Component" ,
38
- "packageName" : "$TMP" ,
39
- "content" : {
40
- "originalControlType" : "sap.m.Label"
41
- } ,
42
- "selector" : {
43
- "id" : "initialLabel" ,
44
- "idIsLocal" : false
45
- } ,
46
- "layer" : "CUSTOMER" ,
47
- "texts" : {
48
- "newText" : {
49
- "value" : "rename_0" ,
50
- "type" : "XFLD"
31
+ [ "1.120.0" , [ "1.120.0" , "2.0.0" ] ] . forEach ( ( minVersion ) => {
32
+ test . serial ( `execute flexChangeBundler with the minVersion: ${ minVersion } ` , async ( t ) => {
33
+ const changeList = [
34
+ {
35
+ "fileName" : "id_1504764957625_7_rename1" ,
36
+ "fileType" : "change" ,
37
+ "changeType" : "rename" ,
38
+ "reference" : "rta.performance.Component" ,
39
+ "packageName" : "$TMP" ,
40
+ "content" : {
41
+ "originalControlType" : "sap.m.Label"
42
+ } ,
43
+ "selector" : {
44
+ "id" : "initialLabel" ,
45
+ "idIsLocal" : false
46
+ } ,
47
+ "layer" : "CUSTOMER" ,
48
+ "texts" : {
49
+ "newText" : {
50
+ "value" : "rename_0" ,
51
+ "type" : "XFLD"
52
+ }
53
+ } ,
54
+ "namespace" : "apps/MyComponent/changes/" ,
55
+ "creation" : "2017-10-06T11:54:55.238Z" ,
56
+ "originalLanguage" : "EN" ,
57
+ "conditions" : { } ,
58
+ "context" : "" ,
59
+ "support" : {
60
+ "generator" : "Change.createInitialFileContent" ,
61
+ "service" : "" ,
62
+ "user" : "" ,
63
+ "sapui5Version" : "1.51.0-SNAPSHOT"
64
+ } ,
65
+ "dependentSelector" : { } ,
66
+ "validAppVersions" : {
67
+ "creation" : "1.0.0" ,
68
+ "from" : "1.0.0" ,
69
+ "to" : "1.0.0"
51
70
}
52
- } ,
53
- "namespace" : "apps/MyComponent/changes/" ,
54
- "creation" : "2017-10-06T11:54:55.238Z" ,
55
- "originalLanguage" : "EN" ,
56
- "conditions" : { } ,
57
- "context" : "" ,
58
- "support" : {
59
- "generator" : "Change.createInitialFileContent" ,
60
- "service" : "" ,
61
- "user" : "" ,
62
- "sapui5Version" : "1.51.0-SNAPSHOT"
63
- } ,
64
- "dependentSelector" : { } ,
65
- "validAppVersions" : {
66
- "creation" : "1.0.0" ,
67
- "from" : "1.0.0" ,
68
- "to" : "1.0.0"
69
71
}
70
- }
71
- ] ;
72
- const existingChangeList = [
73
- {
74
- "fileName" : "id_1504764957630_7_rename2" ,
75
- "fileType" : "change" ,
76
- "changeType" : "rename" ,
77
- "reference" : "rta.performance.Component" ,
78
- "packageName" : "$TMP" ,
79
- "content" : {
80
- "originalControlType" : "sap.m.Label"
81
- } ,
82
- "selector" : {
83
- "id" : "initialLabel" ,
84
- "idIsLocal" : false
85
- } ,
86
- "layer" : "USER" ,
87
- "texts" : {
88
- "newText" : {
89
- "value" : "rename_5" ,
90
- "type" : "XFLD"
72
+ ] ;
73
+ const existingChangeList = [
74
+ {
75
+ "fileName" : "id_1504764957630_7_rename2" ,
76
+ "fileType" : "change" ,
77
+ "changeType" : "rename" ,
78
+ "reference" : "rta.performance.Component" ,
79
+ "packageName" : "$TMP" ,
80
+ "content" : {
81
+ "originalControlType" : "sap.m.Label"
82
+ } ,
83
+ "selector" : {
84
+ "id" : "initialLabel" ,
85
+ "idIsLocal" : false
86
+ } ,
87
+ "layer" : "USER" ,
88
+ "texts" : {
89
+ "newText" : {
90
+ "value" : "rename_5" ,
91
+ "type" : "XFLD"
92
+ }
93
+ } ,
94
+ "namespace" : "apps/MyComponent/changes/" ,
95
+ "creation" : "2017-09-01T11:54:55.238Z" ,
96
+ "originalLanguage" : "EN" ,
97
+ "conditions" : { } ,
98
+ "context" : "" ,
99
+ "support" : {
100
+ "generator" : "Change.createInitialFileContent" ,
101
+ "service" : "" ,
102
+ "user" : "" ,
103
+ "sapui5Version" : "1.51.0-SNAPSHOT"
104
+ } ,
105
+ "dependentSelector" : { } ,
106
+ "validAppVersions" : {
107
+ "creation" : "1.0.0" ,
108
+ "from" : "1.0.0" ,
109
+ "to" : "1.0.0"
91
110
}
92
- } ,
93
- "namespace" : "apps/MyComponent/changes/" ,
94
- "creation" : "2017-09-01T11:54:55.238Z" ,
95
- "originalLanguage" : "EN" ,
96
- "conditions" : { } ,
97
- "context" : "" ,
98
- "support" : {
99
- "generator" : "Change.createInitialFileContent" ,
100
- "service" : "" ,
101
- "user" : "" ,
102
- "sapui5Version" : "1.51.0-SNAPSHOT"
103
- } ,
104
- "dependentSelector" : { } ,
105
- "validAppVersions" : {
106
- "creation" : "1.0.0" ,
107
- "from" : "1.0.0" ,
108
- "to" : "1.0.0"
109
111
}
110
- }
111
- ] ;
112
- const manifest = {
113
- "sap.ui5" : {
114
- dependencies : {
115
- minUI5Version : "1.120.0"
112
+ ] ;
113
+ const manifest = {
114
+ "sap.ui5" : {
115
+ dependencies : {
116
+ minUI5Version : minVersion
117
+ }
116
118
}
117
- }
118
- } ;
119
+ } ;
119
120
120
- const flexBundle = {
121
- "changes" : existingChangeList ,
122
- "compVariants" : [ ] ,
123
- "variantChanges" : [ ] ,
124
- "variantDependentControlChanges" : [ ] ,
125
- "variantManagementChanges" : [ ] ,
126
- "variants" : [ ]
127
- } ;
121
+ const flexBundle = {
122
+ "changes" : existingChangeList ,
123
+ "compVariants" : [ ] ,
124
+ "variantChanges" : [ ] ,
125
+ "variantDependentControlChanges" : [ ] ,
126
+ "variantManagementChanges" : [ ] ,
127
+ "variants" : [ ]
128
+ } ;
128
129
129
- const flexBundleMerge = {
130
- "changes" : existingChangeList . concat ( changeList ) ,
131
- "compVariants" : [ ] ,
132
- "variantChanges" : [ ] ,
133
- "variantDependentControlChanges" : [ ] ,
134
- "variantManagementChanges" : [ ] ,
135
- "variants" : [ ]
136
- } ;
130
+ const flexBundleMerge = {
131
+ "changes" : existingChangeList . concat ( changeList ) ,
132
+ "compVariants" : [ ] ,
133
+ "variantChanges" : [ ] ,
134
+ "variantDependentControlChanges" : [ ] ,
135
+ "variantManagementChanges" : [ ] ,
136
+ "variants" : [ ]
137
+ } ;
137
138
138
- const dummyWorkspace = createDummyWorkspace ( changeList , manifest , flexBundle ) ;
139
- const stub = sinon . stub ( dummyWorkspace , "write" ) . returnsArg ( 0 ) ;
140
- await generateFlexChangesBundle ( {
141
- workspace : dummyWorkspace ,
142
- taskUtil : false ,
143
- options : {
144
- namespace : "/mypath"
145
- }
139
+ const placeholderWorkspace = createPlaceholderWorkspace ( changeList , manifest , flexBundle ) ;
140
+ const stub = sinon . stub ( placeholderWorkspace , "write" ) . returnsArg ( 0 ) ;
141
+ await generateFlexChangesBundle ( {
142
+ workspace : placeholderWorkspace ,
143
+ taskUtil : false ,
144
+ options : {
145
+ namespace : "/mypath"
146
+ }
147
+ } ) ;
148
+
149
+ const content = JSON . parse ( await stub . getCall ( 0 ) . args [ 0 ] . getString ( ) ) ;
150
+ t . deepEqual ( content , flexBundleMerge , "Result must contain the same content" ) ;
151
+
152
+ const path = await stub . getCall ( 0 ) . args [ 0 ] . getPath ( ) ;
153
+ t . is ( path , "/resources/mypath/changes/flexibility-bundle.json" ) ;
146
154
} ) ;
155
+ } ) ;
147
156
148
- const content = JSON . parse ( await stub . getCall ( 0 ) . args [ 0 ] . getString ( ) ) ;
149
- t . deepEqual ( content , flexBundleMerge , "Result must contain the same content" ) ;
157
+ [ "1.70.0" , [ "1.70.0" , "2.0.0" ] ] . forEach ( ( minVersion ) => {
158
+ test . serial ( `execute flexChangeBundler with the minVersion < 1.73: ${ minVersion } ` , async ( t ) => {
159
+ const manifest = {
160
+ "sap.ui5" : {
161
+ dependencies : {
162
+ minUI5Version : minVersion
163
+ }
164
+ }
165
+ } ;
166
+
167
+ const changeList = [
168
+ {
169
+ "fileName" : "id_1504764957625_7_rename1" ,
170
+ "fileType" : "change" ,
171
+ "changeType" : "rename" ,
172
+ "reference" : "rta.performance.Component" ,
173
+ "packageName" : "$TMP" ,
174
+ "content" : {
175
+ "originalControlType" : "sap.m.Label"
176
+ } ,
177
+ "selector" : {
178
+ "id" : "initialLabel" ,
179
+ "idIsLocal" : false
180
+ } ,
181
+ "layer" : "CUSTOMER" ,
182
+ "texts" : {
183
+ "newText" : {
184
+ "value" : "rename_0" ,
185
+ "type" : "XFLD"
186
+ }
187
+ } ,
188
+ "namespace" : "apps/MyComponent/changes/" ,
189
+ "creation" : "2017-10-06T11:54:55.238Z" ,
190
+ "originalLanguage" : "EN" ,
191
+ "conditions" : { } ,
192
+ "context" : "" ,
193
+ "support" : {
194
+ "generator" : "Change.createInitialFileContent" ,
195
+ "service" : "" ,
196
+ "user" : "" ,
197
+ "sapui5Version" : "1.51.0-SNAPSHOT"
198
+ } ,
199
+ "dependentSelector" : { } ,
200
+ "validAppVersions" : {
201
+ "creation" : "1.0.0" ,
202
+ "from" : "1.0.0" ,
203
+ "to" : "1.0.0"
204
+ }
205
+ }
206
+ ] ;
207
+
208
+ const flexBundle = {
209
+ "changes" : [ ] ,
210
+ "compVariants" : [ ] ,
211
+ "variantChanges" : [ ] ,
212
+ "variantDependentControlChanges" : [ ] ,
213
+ "variantManagementChanges" : [ ] ,
214
+ "variants" : [ ]
215
+ } ;
216
+
217
+ const placeholderWorkspace = createPlaceholderWorkspace ( changeList , manifest , flexBundle ) ;
218
+ const stub = sinon . stub ( placeholderWorkspace , "write" ) . returnsArg ( 0 ) ;
219
+
220
+ await generateFlexChangesBundle ( {
221
+ workspace : placeholderWorkspace ,
222
+ taskUtil : false ,
223
+ options : {
224
+ namespace : "/mypath"
225
+ }
226
+ } ) ;
227
+
228
+ const content = JSON . parse ( await stub . getCall ( 0 ) . args [ 0 ] . getString ( ) ) ;
229
+ t . deepEqual ( content , changeList , "Result must contain the same content" ) ;
230
+
231
+ const path = await stub . getCall ( 0 ) . args [ 0 ] . getPath ( ) ;
232
+ t . is ( path , "/resources/mypath/changes/changes-bundle.json" ) ;
233
+ } ) ;
150
234
} ) ;
0 commit comments