@@ -23,8 +23,9 @@ export async function fetchFormFields(
2323 projectId : string ,
2424 config : BrowserStackConfig ,
2525) : Promise < { default_fields : any ; custom_fields : any } > {
26+ const tmBaseUrl = await getTMBaseURL ( config ) ;
2627 const res = await apiClient . get ( {
27- url : await FORM_FIELDS_URL ( projectId ) ,
28+ url : FORM_FIELDS_URL ( tmBaseUrl , projectId ) ,
2829 headers : {
2930 "API-TOKEN" : getBrowserStackAuth ( config ) ,
3031 } ,
@@ -43,9 +44,9 @@ export async function triggerTestCaseGeneration(
4344 source : string ,
4445 config : BrowserStackConfig ,
4546) : Promise < string > {
46- const tmBaseUrl = await getTMBaseURL ( ) ;
47+ const tmBaseUrl = await getTMBaseURL ( config ) ;
4748 const res = await apiClient . post ( {
48- url : await TCG_TRIGGER_URL ( ) ,
49+ url : TCG_TRIGGER_URL ( tmBaseUrl ) ,
4950 headers : {
5051 "API-TOKEN" : getBrowserStackAuth ( config ) ,
5152 "Content-Type" : "application/json" ,
@@ -80,8 +81,9 @@ export async function fetchTestCaseDetails(
8081 if ( testCaseIds . length === 0 ) {
8182 throw new Error ( "No testCaseIds provided to fetchTestCaseDetails" ) ;
8283 }
84+ const tmBaseUrl = await getTMBaseURL ( config ) ;
8385 const res = await apiClient . post ( {
84- url : await FETCH_DETAILS_URL ( ) ,
86+ url : FETCH_DETAILS_URL ( tmBaseUrl ) ,
8587 headers : {
8688 "API-TOKEN" : getBrowserStackAuth ( config ) ,
8789 "request-source" : source ,
@@ -109,7 +111,8 @@ export async function pollTestCaseDetails(
109111) : Promise < Record < string , any > > {
110112 const detailMap : Record < string , any > = { } ;
111113 let done = false ;
112- const TCG_POLL_URL_VALUE = await TCG_POLL_URL ( ) ;
114+ const tmBaseUrl = await getTMBaseURL ( config ) ;
115+ const TCG_POLL_URL_VALUE = TCG_POLL_URL ( tmBaseUrl ) ;
113116
114117 while ( ! done ) {
115118 // add a bit of jitter to avoid synchronized polling storms
@@ -160,7 +163,8 @@ export async function pollScenariosTestDetails(
160163 const scenariosMap : Record < string , Scenario > = { } ;
161164 const detailPromises : Promise < Record < string , any > > [ ] = [ ] ;
162165 let iteratorCount = 0 ;
163- const TCG_POLL_URL_VALUE = await TCG_POLL_URL ( ) ;
166+ const tmBaseUrl = await getTMBaseURL ( config ) ;
167+ const TCG_POLL_URL_VALUE = TCG_POLL_URL ( tmBaseUrl ) ;
164168
165169 // Promisify interval-style polling using a wrapper
166170 await new Promise < void > ( ( resolve , reject ) => {
@@ -283,7 +287,8 @@ export async function bulkCreateTestCases(
283287 const total = Object . keys ( scenariosMap ) . length ;
284288 let doneCount = 0 ;
285289 let testCaseCount = 0 ;
286- const BULK_CREATE_URL_VALUE = await BULK_CREATE_URL ( projectId , folderId ) ;
290+ const tmBaseUrl = await getTMBaseURL ( config ) ;
291+ const BULK_CREATE_URL_VALUE = BULK_CREATE_URL ( tmBaseUrl , projectId , folderId ) ;
287292
288293 for ( const { id, testcases } of Object . values ( scenariosMap ) ) {
289294 const testCaseLength = testcases . length ;
@@ -346,7 +351,7 @@ export async function projectIdentifierToId(
346351 projectId : string ,
347352 config : BrowserStackConfig ,
348353) : Promise < string > {
349- const tmBaseUrl = await getTMBaseURL ( ) ;
354+ const tmBaseUrl = await getTMBaseURL ( config ) ;
350355 const url = `${ tmBaseUrl } /api/v1/projects/?q=${ projectId } ` ;
351356
352357 const response = await apiClient . get ( {
@@ -374,7 +379,7 @@ export async function testCaseIdentifierToDetails(
374379 testCaseIdentifier : string ,
375380 config : BrowserStackConfig ,
376381) : Promise < { testCaseId : string ; folderId : string } > {
377- const tmBaseUrl = await getTMBaseURL ( ) ;
382+ const tmBaseUrl = await getTMBaseURL ( config ) ;
378383 const url = `${ tmBaseUrl } /api/v1/projects/${ projectId } /test-cases/search?q[query]=${ testCaseIdentifier } ` ;
379384
380385 const response = await apiClient . get ( {
0 commit comments