This repository was archived by the owner on Feb 6, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
bin/si-luminork-api-tests/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,12 +233,32 @@ Deno.test('Schemas API - List and Find Schemas', async () => {
233233 ) {
234234 const variantId = getSchemaResponse . data . variantIds [ 0 ] ;
235235
236- const getVariantResponse = await api . schemas . getSchemaVariant (
237- config . workspaceId ,
238- changeSetId ,
239- firstSchema . schemaId ,
240- variantId ,
241- ) ;
236+ // Retry logic for handling 202 responses
237+ let getVariantResponse ;
238+ let attempts = 0 ;
239+ const maxAttempts = 5 ;
240+ const retryDelayMs = 1000 ; // 1 second
241+
242+ do {
243+ getVariantResponse = await api . schemas . getSchemaVariant (
244+ config . workspaceId ,
245+ changeSetId ,
246+ firstSchema . schemaId ,
247+ variantId ,
248+ ) ;
249+
250+ if ( getVariantResponse . status === 200 ) {
251+ break ;
252+ } else if ( getVariantResponse . status === 202 ) {
253+ attempts ++ ;
254+ if ( attempts < maxAttempts ) {
255+ console . log ( `Got 202 response, retrying in ${ retryDelayMs } ms (attempt ${ attempts } /${ maxAttempts } )` ) ;
256+ await new Promise ( resolve => setTimeout ( resolve , retryDelayMs ) ) ;
257+ }
258+ } else {
259+ break ; // Exit on unexpected status codes
260+ }
261+ } while ( getVariantResponse . status === 202 && attempts < maxAttempts ) ;
242262
243263 assertEquals ( getVariantResponse . status , 200 ) ;
244264 assertEquals ( getVariantResponse . data . variantId , variantId ) ;
You can’t perform that action at this time.
0 commit comments