@@ -55,7 +55,7 @@ const stylesExpectWithLazy = [
5555const workspacePath = '/angular.json' ;
5656
5757// tslint:disable:no-big-function
58- describe ( 'Migration to version 9' , ( ) => {
58+ fdescribe ( 'Migration to version 9' , ( ) => {
5959 describe ( 'Migrate workspace config' , ( ) => {
6060 const schematicRunner = new SchematicTestRunner (
6161 'migrations' ,
@@ -350,6 +350,41 @@ 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 uses locale value' , async ( ) => {
354+ let config = getWorkspaceTargets ( tree ) ;
355+ config . build . options = getI18NConfig ( 'fr' ) ;
356+ config . build . configurations . de = { ...getI18NConfig ( 'de' ) , baseHref : '/de/' } ;
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 . de . baseHref ) . toBeUndefined ( ) ;
362+ } ) ;
363+
364+ it ( 'should keep baseHref option when not used with i18n options' , async ( ) => {
365+ let config = getWorkspaceTargets ( tree ) ;
366+ config . build . options = getI18NConfig ( 'fr' ) ;
367+ config . build . configurations . de = getI18NConfig ( 'de' ) ;
368+ config . build . configurations . staging = { baseHref : '/de/' } ;
369+ updateWorkspaceTargets ( tree , config ) ;
370+
371+ const tree2 = await schematicRunner . runSchematicAsync ( 'workspace-version-9' , { } , tree . branch ( ) ) . toPromise ( ) ;
372+ config = getWorkspaceTargets ( tree2 ) . build ;
373+ expect ( config . configurations . staging . baseHref ) . toBe ( '/de/' ) ;
374+ } ) ;
375+
376+ it ( 'should keep main baseHref option when used with i18n options' , async ( ) => {
377+ let config = getWorkspaceTargets ( tree ) ;
378+ config . build . options = { baseHref : '/my-app/' } ;
379+ config . build . configurations . de = { ...getI18NConfig ( 'de' ) , baseHref : '/de/' } ;
380+ updateWorkspaceTargets ( tree , config ) ;
381+
382+ const tree2 = await schematicRunner . runSchematicAsync ( 'workspace-version-9' , { } , tree . branch ( ) ) . toPromise ( ) ;
383+ config = getWorkspaceTargets ( tree2 ) . build ;
384+ expect ( config . options . baseHref ) . toBe ( '/my-app/' ) ;
385+ expect ( config . configurations . de . baseHref ) . toBeUndefined ( ) ;
386+ } ) ;
387+
353388 it ( 'should remove deprecated extract-i18n options' , async ( ) => {
354389 let config = getWorkspaceTargets ( tree ) ;
355390 config [ 'extract-i18n' ] . options . i18nFormat = 'xmb' ;
@@ -392,6 +427,22 @@ describe('Migration to version 9', () => {
392427 fr : 'src/locale/messages.fr.xlf' ,
393428 } ) ;
394429 } ) ;
430+
431+ it ( `should add i18n 'locales' project config when using baseHref options` , async ( ) => {
432+ const config = getWorkspaceTargets ( tree ) ;
433+ config . build . options = { baseHref : '/my-app/' } ;
434+ config . build . configurations . fr = { ...getI18NConfig ( 'fr' ) , baseHref : '/fr/' } ;
435+ config . build . configurations . de = { ...getI18NConfig ( 'de' ) , baseHref : '/abc/' } ;
436+ updateWorkspaceTargets ( tree , config ) ;
437+
438+ const tree2 = await schematicRunner . runSchematicAsync ( 'workspace-version-9' , { } , tree . branch ( ) ) . toPromise ( ) ;
439+ const projectConfig = JSON . parse ( tree2 . readContent ( workspacePath ) ) . projects [ 'migration-test' ] ;
440+ expect ( projectConfig . i18n . sourceLocale ) . toBeUndefined ( ) ;
441+ expect ( projectConfig . i18n . locales ) . toEqual ( {
442+ de : { translation : 'src/locale/messages.de.xlf' , baseHref : '/abc/' } ,
443+ fr : 'src/locale/messages.fr.xlf' ,
444+ } ) ;
445+ } ) ;
395446 } ) ;
396447
397448 describe ( 'when i18n builder options are not set' , ( ) => {
0 commit comments