@@ -2781,28 +2781,17 @@ describe('Config Tests', () => {
27812781 } ) ;
27822782
27832783 it ( 'updates onboard config' , ( ) => {
2784- const config = Config ( ) ;
2785- config . updateOnboardConfig ( { lastProfile : 'paid' } ) ;
2786- expect ( config . getOnboardConfig ( ) ) . to . deep . equal ( { lastProfile : 'paid' } ) ;
2787- } ) ;
2788-
2789- it ( 'merges lastStartTime into existing onboard config' , ( ) => {
27902784 const startTime = Date . now ( ) ;
2791- const config = Config ( { onboardConfig : { lastProfile : 'paid' } } ) ;
2792- config . updateOnboardConfig ( { lastStartTime : startTime } ) ;
2785+ const config = Config ( ) ;
2786+ config . updateOnboardConfig ( { lastProfile : 'paid' , lastStartTime : startTime } ) ;
27932787 expect ( config . getOnboardConfig ( ) ) . to . deep . equal ( { lastProfile : 'paid' , lastStartTime : startTime } ) ;
27942788 } ) ;
27952789
2796- it ( 'merges into existing onboard config' , ( ) => {
2797- const config = Config ( { onboardConfig : { lastProfile : 'demo' } } ) ;
2798- config . updateOnboardConfig ( { lastProfile : 'paid' } ) ;
2799- expect ( config . getOnboardConfig ( ) ) . to . deep . equal ( { lastProfile : 'paid' } ) ;
2800- } ) ;
2801-
2802- it ( 'stores only lastStartTime when lastProfile is absent' , ( ) => {
2790+ it ( 'overwrites existing onboard config' , ( ) => {
28032791 const startTime = Date . now ( ) ;
2804- const config = Config ( { onboardConfig : { lastStartTime : startTime } } ) ;
2805- expect ( config . getOnboardConfig ( ) ) . to . deep . equal ( { lastStartTime : startTime } ) ;
2792+ const config = Config ( { onboardConfig : { lastProfile : 'demo' , lastStartTime : 1000 } } ) ;
2793+ config . updateOnboardConfig ( { lastProfile : 'paid' , lastStartTime : startTime } ) ;
2794+ expect ( config . getOnboardConfig ( ) ) . to . deep . equal ( { lastProfile : 'paid' , lastStartTime : startTime } ) ;
28062795 } ) ;
28072796
28082797 it ( 'includes onboardConfig in toDynamoItem' , ( ) => {
@@ -2819,6 +2808,82 @@ describe('Config Tests', () => {
28192808 } ) ;
28202809 } ) ;
28212810
2811+ describe ( 'Commerce LLMO Config' , ( ) => {
2812+ it ( 'creates a Config with commerceLlmoConfig property' , ( ) => {
2813+ const data = {
2814+ commerceLlmoConfig : {
2815+ store1 : {
2816+ environmentId : 'env-123' ,
2817+ websiteCode : 'base' ,
2818+ storeCode : 'main_store' ,
2819+ storeViewCode : 'default' ,
2820+ hostName : 'example.com' ,
2821+ magentoEndpoint : 'https://magento.example.com/graphql' ,
2822+ magentoAPIKey : 'api-key-123' ,
2823+ } ,
2824+ } ,
2825+ } ;
2826+ const config = Config ( data ) ;
2827+ expect ( config . getCommerceLlmoConfig ( ) ) . to . deep . equal ( data . commerceLlmoConfig ) ;
2828+ } ) ;
2829+
2830+ it ( 'has undefined commerceLlmoConfig in default config' , ( ) => {
2831+ const config = Config ( ) ;
2832+ expect ( config . getCommerceLlmoConfig ( ) ) . to . be . undefined ;
2833+ } ) ;
2834+
2835+ it ( 'should return undefined for commerceLlmoConfig if not provided' , ( ) => {
2836+ const config = Config ( { } ) ;
2837+ expect ( config . getCommerceLlmoConfig ( ) ) . to . be . undefined ;
2838+ } ) ;
2839+
2840+ it ( 'should be able to update commerceLlmoConfig' , ( ) => {
2841+ const data = {
2842+ commerceLlmoConfig : {
2843+ store1 : {
2844+ environmentId : 'env-456' ,
2845+ websiteCode : 'base' ,
2846+ } ,
2847+ } ,
2848+ } ;
2849+ const config = Config ( { } ) ;
2850+ config . updateCommerceLlmoConfig ( data . commerceLlmoConfig ) ;
2851+ expect ( config . getCommerceLlmoConfig ( ) ) . to . deep . equal ( data . commerceLlmoConfig ) ;
2852+ } ) ;
2853+
2854+ it ( 'should be able to update commerceLlmoConfig with different values' , ( ) => {
2855+ const config = Config ( {
2856+ commerceLlmoConfig : {
2857+ store1 : {
2858+ environmentId : 'env-123' ,
2859+ } ,
2860+ } ,
2861+ } ) ;
2862+
2863+ const newConfig = {
2864+ store2 : {
2865+ environmentId : 'env-789' ,
2866+ hostName : 'new.example.com' ,
2867+ } ,
2868+ } ;
2869+ config . updateCommerceLlmoConfig ( newConfig ) ;
2870+ expect ( config . getCommerceLlmoConfig ( ) ) . to . deep . equal ( newConfig ) ;
2871+ } ) ;
2872+
2873+ it ( 'includes commerceLlmoConfig in toDynamoItem conversion' , ( ) => {
2874+ const data = Config ( {
2875+ commerceLlmoConfig : {
2876+ store1 : {
2877+ environmentId : 'env-123' ,
2878+ magentoEndpoint : 'https://magento.example.com/graphql' ,
2879+ } ,
2880+ } ,
2881+ } ) ;
2882+ const dynamoItem = Config . toDynamoItem ( data ) ;
2883+ expect ( dynamoItem . commerceLlmoConfig ) . to . deep . equal ( data . getCommerceLlmoConfig ( ) ) ;
2884+ } ) ;
2885+ } ) ;
2886+
28222887 describe ( 'LLMO Well Known Tags' , ( ) => {
28232888 const { extractWellKnownTags } = Config ( ) ;
28242889
0 commit comments