@@ -961,4 +961,82 @@ describe('merge configs', () => {
961961 expect ( mergeConfigs ( registryConfigWithWildcardRoutes , overrideConfig ) ) . to . be . eql ( mergedConfig ) ;
962962 } ) ;
963963 } ) ;
964+
965+ describe ( 'should apply domain props to LDE-only apps' , ( ) => {
966+ const domainProps = { appProps : { brandId : 'namecheap' } , cdnUrl : 'https://cdn.namecheap.com' } ;
967+ const domainSsrProps = { secretKey : 'server-secret' } ;
968+
969+ const registryConfigWithDomainProps : TransformedRegistryConfig = {
970+ ...registryConfig ,
971+ domainProps,
972+ domainSsrProps,
973+ } ;
974+
975+ it ( 'should merge domain props into a new LDE-only app' , ( ) => {
976+ const overrideConfig = {
977+ apps : {
978+ '@portal/new-lde-app' : {
979+ spaBundle : 'https://localhost:3000/app.js' ,
980+ ssr : { src : 'https://localhost:3000/ssr' } ,
981+ props : { appConfig : { lde : true } } ,
982+ } ,
983+ } ,
984+ } ;
985+
986+ const result = mergeConfigs ( registryConfigWithDomainProps , overrideConfig ) ;
987+
988+ expect ( result . apps [ '@portal/new-lde-app' ] . props ) . to . deep . equal ( {
989+ ...domainProps ,
990+ appConfig : { lde : true } ,
991+ } ) ;
992+ expect ( result . apps [ '@portal/new-lde-app' ] . ssrProps ) . to . deep . equal ( domainSsrProps ) ;
993+ } ) ;
994+
995+ it ( 'should let LDE app props override domain props for the same key' , ( ) => {
996+ const overrideConfig = {
997+ apps : {
998+ '@portal/new-lde-app' : {
999+ spaBundle : 'https://localhost:3000/app.js' ,
1000+ props : { appProps : { brandId : 'override-brand' } } ,
1001+ } ,
1002+ } ,
1003+ } ;
1004+
1005+ const result = mergeConfigs ( registryConfigWithDomainProps , overrideConfig ) ;
1006+
1007+ expect ( result . apps [ '@portal/new-lde-app' ] . props ) . to . deep . equal ( {
1008+ ...domainProps ,
1009+ appProps : { brandId : 'override-brand' } ,
1010+ } ) ;
1011+ } ) ;
1012+
1013+ it ( 'should not apply domain props to apps already in the registry' , ( ) => {
1014+ const overrideConfig = {
1015+ apps : {
1016+ '@portal/will-change' : {
1017+ spaBundle : 'https://localhost:3000/will-change.js' ,
1018+ } ,
1019+ } ,
1020+ } ;
1021+
1022+ const result = mergeConfigs ( registryConfigWithDomainProps , overrideConfig ) ;
1023+
1024+ expect ( result . apps [ '@portal/will-change' ] . props ) . to . deep . equal ( apps [ '@portal/will-change' ] . props ) ;
1025+ } ) ;
1026+
1027+ it ( 'should not apply domain props when registry config has no domainProps' , ( ) => {
1028+ const overrideConfig = {
1029+ apps : {
1030+ '@portal/new-lde-app' : {
1031+ spaBundle : 'https://localhost:3000/app.js' ,
1032+ props : { foo : 'bar' } ,
1033+ } ,
1034+ } ,
1035+ } ;
1036+
1037+ const result = mergeConfigs ( registryConfig , overrideConfig ) ;
1038+
1039+ expect ( result . apps [ '@portal/new-lde-app' ] . props ) . to . deep . equal ( { foo : 'bar' } ) ;
1040+ } ) ;
1041+ } ) ;
9641042} ) ;
0 commit comments