@@ -62,11 +62,13 @@ describe('partial-build-extension', () => {
62
62
it ( 'should register listener if only refname key is set' , ( ) => {
63
63
ext . register . call ( generatorContext , { config : { refname : 'main' } } )
64
64
expect ( generatorContext . playbookBuilt ) . to . be . instanceOf ( Function )
65
+ expect ( generatorContext . contentAggregated ) . to . be . instanceOf ( Function )
65
66
} )
66
67
67
68
it ( 'should not register listener if refname key is not set' , ( ) => {
68
69
ext . register . call ( generatorContext , { } )
69
70
expect ( generatorContext . playbookBuilt ) . to . be . undefined ( )
71
+ expect ( generatorContext . contentAggregated ) . to . be . undefined ( )
70
72
} )
71
73
} )
72
74
@@ -215,6 +217,82 @@ describe('partial-build-extension', () => {
215
217
} )
216
218
} )
217
219
220
+ it ( 'should not rewrite content sources when multiple sources' , async ( ) => {
221
+ playbook . dir = WORK_DIR
222
+ playbook . asciidoc . attributes = { 'primary-site-manifest-url' : ospath . join ( FIXTURES_DIR , 'site-manifest.json' ) }
223
+ playbook . content . sources = [
224
+ {
225
+ url : '.' ,
226
+ branches : [ 'main' ] ,
227
+ startPaths : [ 'new-start-path' ] ,
228
+ } ,
229
+ {
230
+ url : '.' ,
231
+ branches : [ '1.0.x' ] ,
232
+ startPaths : [ 'old-start-path' ] ,
233
+ } ,
234
+ ]
235
+ ext . register . call ( generatorContext , { config : { refname : 'HEAD' , version : '7.0.0-SNAPSHOT' } } )
236
+ generatorContext . updateVariables ( { playbook } )
237
+ await generatorContext . playbookBuilt ( generatorContext . variables )
238
+ expect ( playbook . content . sources ) . to . eql ( [
239
+ {
240
+ url : '.' ,
241
+ branches : [ 'main' ] ,
242
+ startPaths : [ 'new-start-path' ] ,
243
+ } ,
244
+ {
245
+ url : '.' ,
246
+ branches : [ '1.0.x' ] ,
247
+ startPaths : [ 'old-start-path' ] ,
248
+ } ,
249
+ ] )
250
+ } )
251
+
252
+ it ( 'should disable contentAggregated when full build' , async ( ) => {
253
+ playbook . dir = WORK_DIR
254
+ await fsp . writeFile ( ospath . join ( playbook . dir , '.full-build' ) , '' )
255
+ ext . register . call ( generatorContext , { config : { refname : 'main' , version : '7.0.0-SNAPSHOT' } } )
256
+ generatorContext . updateVariables ( { playbook } )
257
+ const contentAggregate = [
258
+ {
259
+ origins : [ { branch : 'main' } ] ,
260
+ } ,
261
+ {
262
+ origins : [ { branch : '1.0.x' } ] ,
263
+ } ,
264
+ ]
265
+ await generatorContext . contentAggregated ( { playbook, contentAggregate } )
266
+ expect ( contentAggregate . length ) . to . eql ( 2 )
267
+ } )
268
+
269
+ it ( 'contentAggregated should remove when activated' , async ( ) => {
270
+ playbook . dir = WORK_DIR
271
+ ext . register . call ( generatorContext , { config : { refname : '1.0.x' , version : '1.0.0-SNAPSHOT' } } )
272
+ generatorContext . updateVariables ( { playbook } )
273
+ const contentAggregate = [
274
+ {
275
+ origins : [ { branch : 'main' } ] ,
276
+ } ,
277
+ {
278
+ origins : [ { branch : '1.0.x' } ] ,
279
+ } ,
280
+ {
281
+ origins : [ { branch : '2.0.x' } ] ,
282
+ } ,
283
+ ]
284
+ await generatorContext . contentAggregated ( { playbook, contentAggregate } )
285
+ expect ( contentAggregate . length ) . to . eql ( 1 )
286
+ expect ( contentAggregate [ 0 ] . origins [ 0 ] . branch ) . to . eql ( '1.0.x' )
287
+ } )
288
+
289
+ it ( 'contentAggregated should not remove when refname not specified' , async ( ) => {
290
+ playbook . dir = WORK_DIR
291
+ ext . register . call ( generatorContext , { config : { version : '1.0.0-SNAPSHOT' } } )
292
+ generatorContext . updateVariables ( { playbook } )
293
+ expect ( generatorContext . contentAggregated ) . undefined ( )
294
+ } )
295
+
218
296
it ( 'should error if refname is HEAD and version undefined' , async ( ) => {
219
297
expect ( await trapAsyncError ( ( ) => runScenario ( { refname : 'HEAD' } ) ) ) . to . throw (
220
298
'When using author mode version is required. Specify config.version or env BUILD_VERSION'
0 commit comments