@@ -75,30 +75,55 @@ describe('bearerAuthHandler', () => {
7575} )
7676
7777describe ( 'setRuntimeApiHostAndAuthHandler' , ( ) => {
78- const defaultDeployServiceUrl = 'https://deploy-service.app-builder.adp.adobe.io'
78+ const DEPLOY_SERVICE_ENDPOINTS = {
79+ prod : 'https://deploy-service.app-builder.adp.adobe.io' ,
80+ stage : 'https://deploy-service.stg.app-builder.corp.adp.adobe.io'
81+ }
7982
8083 beforeEach ( ( ) => {
8184 jest . clearAllMocks ( )
8285 delete process . env . AIO_DEPLOY_SERVICE_URL
8386 } )
8487
8588 test ( 'should set runtime.apihost and runtime.auth_handler when config has runtime' , ( ) => {
86- const config = { runtime : { } }
87- const result = setRuntimeApiHostAndAuthHandler ( config )
88-
89- expect ( result . runtime . apihost ) . toBe ( `${ defaultDeployServiceUrl } /runtime` )
90- expect ( result . runtime . auth_handler ) . toBe ( bearerAuthHandler )
89+ // test both envs
90+ {
91+ const mockEnv = 'prod'
92+ getCliEnv . mockReturnValue ( mockEnv )
93+
94+ const config = { runtime : { } }
95+ const result = setRuntimeApiHostAndAuthHandler ( config )
96+
97+ expect ( result . runtime . apihost ) . toBe ( `${ DEPLOY_SERVICE_ENDPOINTS [ mockEnv ] } /runtime` )
98+ expect ( result . runtime . auth_handler ) . toBe ( bearerAuthHandler )
99+ }
100+ {
101+ const mockEnv = 'stage'
102+ getCliEnv . mockReturnValue ( mockEnv )
103+
104+ const config = { runtime : { } }
105+ const result = setRuntimeApiHostAndAuthHandler ( config )
106+
107+ expect ( result . runtime . apihost ) . toBe ( `${ DEPLOY_SERVICE_ENDPOINTS [ mockEnv ] } /runtime` )
108+ expect ( result . runtime . auth_handler ) . toBe ( bearerAuthHandler )
109+ }
91110 } )
92111
93112 test ( 'should set ow.apihost and ow.auth_handler when config has ow' , ( ) => {
113+ const mockEnv = 'unknown-env-should-use-prod'
114+ getCliEnv . mockReturnValue ( mockEnv )
115+
94116 const config = { ow : { } }
95117 const result = setRuntimeApiHostAndAuthHandler ( config )
96118
97- expect ( result . ow . apihost ) . toBe ( `${ defaultDeployServiceUrl } /runtime` )
119+ expect ( result . ow . apihost ) . toBe ( `${ DEPLOY_SERVICE_ENDPOINTS . prod } /runtime` )
98120 expect ( result . ow . auth_handler ) . toBe ( bearerAuthHandler )
99121 } )
100122
101123 test ( 'should use custom deploy service URL from environment' , ( ) => {
124+ const mockEnv = 'prod'
125+ getCliEnv . mockReturnValue ( mockEnv )
126+
102127 const customUrl = 'https://custom-deploy-service.example.com'
103128 process . env . AIO_DEPLOY_SERVICE_URL = customUrl
104129 const config = { runtime : { } }
0 commit comments