@@ -174,6 +174,29 @@ export default class httpClient {
174174 }
175175
176176
177+ getSmartUICapabilities ( sessionId : string , config : any , git : any , log : Logger ) {
178+ console . log ( `get smartui caps api called with sessionId: ${ sessionId } ` ) ;
179+ const serializedConfig = JSON . stringify ( config ) ;
180+ const serializedGit = JSON . stringify ( git ) ;
181+ console . log ( `Serialized Config: ${ serializedConfig } ` ) ;
182+ console . log ( `Serialized Git: ${ serializedGit } ` ) ;
183+ return this . request ( {
184+ url : '/sessions/capabilities' ,
185+ method : 'GET' ,
186+ params : {
187+ sessionId : sessionId ,
188+ config : serializedConfig ,
189+ git : serializedGit ,
190+ } ,
191+ headers : {
192+ projectToken : '' ,
193+ projectName : '' ,
194+ username : '' ,
195+ accessKey : ''
196+ } ,
197+ } , log ) ;
198+ }
199+
177200 finalizeBuild ( buildId : string , totalSnapshots : number , log : Logger ) {
178201 let params : Record < string , string | number > = { buildId } ;
179202 if ( totalSnapshots > - 1 ) params . totalSnapshots = totalSnapshots ;
@@ -185,9 +208,33 @@ export default class httpClient {
185208 } , log )
186209 }
187210
188- uploadSnapshot ( ctx : Context , snapshot : ProcessedSnapshot ) {
211+ async finalizeBuildForCapsWithToken ( buildId : string , totalSnapshots : number , projectToken : string , log : Logger ) : Promise < void > {
212+ try {
213+ let params : Record < string , string | number > = { buildId } ;
214+ if ( totalSnapshots > - 1 ) params . totalSnapshots = totalSnapshots ;
215+
216+ await this . request ( {
217+ url : '/build' ,
218+ method : 'DELETE' ,
219+ params : params ,
220+ headers : {
221+ projectToken : projectToken , // Use projectToken dynamically
222+ } ,
223+ } , log ) ;
224+
225+ log . debug ( `Successfully finalized build ${ buildId } with ${ totalSnapshots } snapshots and projectToken ${ projectToken } ` ) ;
226+ } catch ( error : any ) {
227+ log . debug ( `Failed to finalize build ${ buildId } : ${ error . message } ` ) ;
228+ throw error ; // Re-throw error for further handling if necessary
229+ }
230+ }
231+
232+
233+ uploadSnapshot ( ctx : Context , snapshot : ProcessedSnapshot , capsBuildId : string ) {
234+ // Use capsBuildId if provided, otherwise fallback to ctx.build.id
235+ const buildId = capsBuildId !== '' ? capsBuildId : ctx . build . id ;
189236 return this . request ( {
190- url : `/builds/${ ctx . build . id } /snapshot` ,
237+ url : `/builds/${ buildId } /snapshot` ,
191238 method : 'POST' ,
192239 headers : { 'Content-Type' : 'application/json' } ,
193240 data : {
@@ -197,7 +244,7 @@ export default class httpClient {
197244 source : 'cli'
198245 }
199246 }
200- } , ctx . log )
247+ } , ctx . log ) ;
201248 }
202249
203250 processSnapshot ( ctx : Context , snapshot : ProcessedSnapshot , snapshotUuid : string ) {
@@ -217,6 +264,28 @@ export default class httpClient {
217264 }
218265 } , ctx . log )
219266 }
267+ uploadSnapshotForCaps ( ctx : Context , snapshot : ProcessedSnapshot , capsBuildId : string , capsProjectToken : string ) {
268+ // Use capsBuildId if provided, otherwise fallback to ctx.build.id
269+ const buildId = capsBuildId !== '' ? capsBuildId : ctx . build . id ;
270+
271+ return this . request ( {
272+ url : `/builds/${ buildId } /snapshot` ,
273+ method : 'POST' ,
274+ headers : {
275+ 'Content-Type' : 'application/json' ,
276+ projectToken : capsProjectToken !== '' ? capsProjectToken : this . projectToken // Use capsProjectToken dynamically
277+ } ,
278+ data : {
279+ snapshot,
280+ test : {
281+ type : ctx . testType ,
282+ source : 'cli'
283+ }
284+ }
285+ } , ctx . log ) ;
286+ }
287+
288+
220289
221290 uploadScreenshot (
222291 { id : buildId , name : buildName , baseline } : Build ,
0 commit comments