@@ -27,6 +27,12 @@ describe('Sites Operations E2E Tests', function () {
2727 let serverHostname : string ;
2828 let ownSandboxId : null | string = null ;
2929
30+ async function sleep ( ms : number ) : Promise < void > {
31+ await new Promise ( ( resolve ) => {
32+ setTimeout ( resolve , ms ) ;
33+ } ) ;
34+ }
35+
3036 before ( async function ( ) {
3137 if ( ! process . env . SFCC_CLIENT_ID || ! process . env . SFCC_CLIENT_SECRET ) {
3238 this . skip ( ) ;
@@ -66,13 +72,32 @@ describe('Sites Operations E2E Tests', function () {
6672 console . log ( `Created dedicated sandbox ${ ownSandboxId } at ${ serverHostname } ` ) ;
6773 }
6874
69- const importResult = await runCLI ( [ 'job' , 'import' , SITE_ARCHIVE_PATH , '--server' , serverHostname ] ) ;
75+ async function runImportWithRetry ( remainingRetries : number ) {
76+ const importResult = await runCLI ( [ 'job' , 'import' , SITE_ARCHIVE_PATH , '--server' , serverHostname ] ) ;
77+ if ( importResult . exitCode === 0 ) return importResult ;
78+
79+ const msg = importResult . stderr || importResult . stdout ;
80+ const isTransient = / f e t c h f a i l e d | E C O N N R E S E T | E T I M E D O U T / i. test ( msg ) ;
81+
82+ if ( ! isTransient || remainingRetries <= 0 ) return importResult ;
83+
84+ console . warn (
85+ `Sites E2E: transient import error, retrying after delay (remaining retries: ${ remainingRetries } ):` ,
86+ msg ,
87+ ) ;
88+ await sleep ( 2000 ) ;
89+ return runImportWithRetry ( remainingRetries - 1 ) ;
90+ }
91+
92+ const importResult = await runImportWithRetry ( 2 ) ;
7093
7194 if ( importResult . exitCode !== 0 ) {
7295 const msg = importResult . stderr || importResult . stdout ;
7396 // If the sandbox/client lacks permissions, treat this as a valid customer scenario
74- // and skip the suite rather than failing in before().
75- if ( / n o t \s + a l l o w e d | u n a u t h o r i z e d | f o r b i d d e n | 4 0 1 | 4 0 3 / i. test ( msg ) ) {
97+ // and skip the suite rather than failing in before(). Also skip on transient
98+ // network issues where the underlying HTTP fetch fails.
99+ if ( / n o t \s + a l l o w e d | u n a u t h o r i z e d | f o r b i d d e n | 4 0 1 | 4 0 3 | f e t c h f a i l e d / i. test ( msg ) ) {
100+ console . warn ( 'Sites E2E: skipping suite due to import error:' , msg ) ;
76101 this . skip ( ) ;
77102 }
78103 expect ( importResult . exitCode ) . to . equal ( 0 , msg ) ;
0 commit comments