@@ -350,6 +350,42 @@ describe('Migration to version 9', () => {
350350 expect ( config . configurations . de . i18nLocale ) . toBeUndefined ( ) ;
351351 } ) ;
352352
353+ it ( 'should remove baseHref option when used with i18n options and no main base href' , async ( ) => {
354+ let config = getWorkspaceTargets ( tree ) ;
355+ config . build . configurations . fr = { ...getI18NConfig ( 'fr' ) , baseHref : '/fr/' } ;
356+ config . build . configurations . de = { ...getI18NConfig ( 'de' ) , baseHref : '/abc/' } ;
357+ updateWorkspaceTargets ( tree , config ) ;
358+
359+ const tree2 = await schematicRunner . runSchematicAsync ( 'workspace-version-9' , { } , tree . branch ( ) ) . toPromise ( ) ;
360+ config = getWorkspaceTargets ( tree2 ) . build ;
361+ expect ( config . configurations . fr . baseHref ) . toBeUndefined ( ) ;
362+ expect ( config . configurations . de . baseHref ) . toBeUndefined ( ) ;
363+ } ) ;
364+
365+ it ( 'should keep baseHref option when not used with i18n options' , async ( ) => {
366+ let config = getWorkspaceTargets ( tree ) ;
367+ config . build . options = getI18NConfig ( 'fr' ) ;
368+ config . build . configurations . de = getI18NConfig ( 'de' ) ;
369+ config . build . configurations . staging = { baseHref : '/de/' } ;
370+ updateWorkspaceTargets ( tree , config ) ;
371+
372+ const tree2 = await schematicRunner . runSchematicAsync ( 'workspace-version-9' , { } , tree . branch ( ) ) . toPromise ( ) ;
373+ config = getWorkspaceTargets ( tree2 ) . build ;
374+ expect ( config . configurations . staging . baseHref ) . toBe ( '/de/' ) ;
375+ } ) ;
376+
377+ it ( 'should keep baseHref options when used with i18n options and main baseHref option' , async ( ) => {
378+ let config = getWorkspaceTargets ( tree ) ;
379+ config . build . options = { baseHref : '/my-app/' } ;
380+ config . build . configurations . de = { ...getI18NConfig ( 'de' ) , baseHref : '/de/' } ;
381+ updateWorkspaceTargets ( tree , config ) ;
382+
383+ const tree2 = await schematicRunner . runSchematicAsync ( 'workspace-version-9' , { } , tree . branch ( ) ) . toPromise ( ) ;
384+ config = getWorkspaceTargets ( tree2 ) . build ;
385+ expect ( config . options . baseHref ) . toBe ( '/my-app/' ) ;
386+ expect ( config . configurations . de . baseHref ) . toBe ( '/de/' ) ;
387+ } ) ;
388+
353389 it ( 'should remove deprecated extract-i18n options' , async ( ) => {
354390 let config = getWorkspaceTargets ( tree ) ;
355391 config [ 'extract-i18n' ] . options . i18nFormat = 'xmb' ;
@@ -379,19 +415,49 @@ describe('Migration to version 9', () => {
379415
380416 it ( `should add i18n 'locales' project config` , async ( ) => {
381417 const config = getWorkspaceTargets ( tree ) ;
382- config . build . options . aot = false ;
383- config . build . options = getI18NConfig ( 'fr' ) ;
418+ config . build . configurations . fr = getI18NConfig ( 'fr' ) ;
384419 config . build . configurations . de = getI18NConfig ( 'de' ) ;
385420 updateWorkspaceTargets ( tree , config ) ;
386421
387422 const tree2 = await schematicRunner . runSchematicAsync ( 'workspace-version-9' , { } , tree . branch ( ) ) . toPromise ( ) ;
388423 const projectConfig = JSON . parse ( tree2 . readContent ( workspacePath ) ) . projects [ 'migration-test' ] ;
389424 expect ( projectConfig . i18n . sourceLocale ) . toBeUndefined ( ) ;
390425 expect ( projectConfig . i18n . locales ) . toEqual ( {
391- de : 'src/locale/messages.de.xlf' ,
426+ de : { translation : 'src/locale/messages.de.xlf' , baseHref : '' } ,
427+ fr : { translation : 'src/locale/messages.fr.xlf' , baseHref : '' } ,
428+ } ) ;
429+ } ) ;
430+
431+ it ( `should add i18n 'locales' project config when using baseHref options` , async ( ) => {
432+ const config = getWorkspaceTargets ( tree ) ;
433+ config . build . configurations . fr = { ...getI18NConfig ( 'fr' ) , baseHref : '/fr/' } ;
434+ config . build . configurations . de = { ...getI18NConfig ( 'de' ) , baseHref : '/abc/' } ;
435+ updateWorkspaceTargets ( tree , config ) ;
436+
437+ const tree2 = await schematicRunner . runSchematicAsync ( 'workspace-version-9' , { } , tree . branch ( ) ) . toPromise ( ) ;
438+ const projectConfig = JSON . parse ( tree2 . readContent ( workspacePath ) ) . projects [ 'migration-test' ] ;
439+ expect ( projectConfig . i18n . sourceLocale ) . toBeUndefined ( ) ;
440+ expect ( projectConfig . i18n . locales ) . toEqual ( {
441+ de : { translation : 'src/locale/messages.de.xlf' , baseHref : '/abc/' } ,
392442 fr : 'src/locale/messages.fr.xlf' ,
393443 } ) ;
394444 } ) ;
445+
446+ it ( `should add i18n 'locales' project config when using baseHref options and main base href` , async ( ) => {
447+ const config = getWorkspaceTargets ( tree ) ;
448+ config . build . options = { baseHref : '/my-app/' } ;
449+ config . build . configurations . fr = { ...getI18NConfig ( 'fr' ) , baseHref : '/fr/' } ;
450+ config . build . configurations . de = { ...getI18NConfig ( 'de' ) , baseHref : '/abc/' } ;
451+ updateWorkspaceTargets ( tree , config ) ;
452+
453+ const tree2 = await schematicRunner . runSchematicAsync ( 'workspace-version-9' , { } , tree . branch ( ) ) . toPromise ( ) ;
454+ const projectConfig = JSON . parse ( tree2 . readContent ( workspacePath ) ) . projects [ 'migration-test' ] ;
455+ expect ( projectConfig . i18n . sourceLocale ) . toBeUndefined ( ) ;
456+ expect ( projectConfig . i18n . locales ) . toEqual ( {
457+ de : { translation : 'src/locale/messages.de.xlf' , baseHref : '' } ,
458+ fr : { translation : 'src/locale/messages.fr.xlf' , baseHref : '' } ,
459+ } ) ;
460+ } ) ;
395461 } ) ;
396462
397463 describe ( 'when i18n builder options are not set' , ( ) => {
0 commit comments