11/* eslint-disable no-restricted-imports, no-await-in-loop */
22import { authFixture } from './auth.js'
33import { navigateToDashboard } from './browser.js'
4+ import { CLI_TIMEOUT , BROWSER_TIMEOUT } from './constants.js'
45import * as path from 'path'
56import * as fs from 'fs'
67import type { CLIContext , CLIProcess , ExecResult } from './cli.js'
@@ -41,7 +42,7 @@ export async function createApp(ctx: {
4142
4243 const result = await cli . execCreateApp ( args , {
4344 env : { FORCE_COLOR : '0' } ,
44- timeout : 5 * 60 * 1000 ,
45+ timeout : CLI_TIMEOUT . long ,
4546 } )
4647
4748 let appDir = ''
@@ -111,11 +112,11 @@ export async function generateExtension(
111112) : Promise < ExecResult > {
112113 const args = [ 'app' , 'generate' , 'extension' , '--name' , ctx . name , '--path' , ctx . appDir , '--template' , ctx . template ]
113114 if ( ctx . flavor ) args . push ( '--flavor' , ctx . flavor )
114- return ctx . cli . exec ( args , { timeout : 5 * 60 * 1000 } )
115+ return ctx . cli . exec ( args , { timeout : CLI_TIMEOUT . long } )
115116}
116117
117118export async function buildApp ( ctx : CLIContext ) : Promise < ExecResult > {
118- return ctx . cli . exec ( [ 'app' , 'build' , '--path' , ctx . appDir ] , { timeout : 5 * 60 * 1000 } )
119+ return ctx . cli . exec ( [ 'app' , 'build' , '--path' , ctx . appDir ] , { timeout : CLI_TIMEOUT . long } )
119120}
120121
121122export async function deployApp (
@@ -133,7 +134,7 @@ export async function deployApp(
133134 if ( ctx . version ) args . push ( '--version' , ctx . version )
134135 if ( ctx . message ) args . push ( '--message' , ctx . message )
135136 if ( ctx . config ) args . push ( '--config' , ctx . config )
136- return ctx . cli . exec ( args , { timeout : 5 * 60 * 1000 } )
137+ return ctx . cli . exec ( args , { timeout : CLI_TIMEOUT . long } )
137138}
138139
139140export async function appInfo ( ctx : CLIContext ) : Promise < {
@@ -153,7 +154,7 @@ export async function appInfo(ctx: CLIContext): Promise<{
153154}
154155
155156export async function functionBuild ( ctx : CLIContext ) : Promise < ExecResult > {
156- return ctx . cli . exec ( [ 'app' , 'function' , 'build' , '--path' , ctx . appDir ] , { timeout : 3 * 60 * 1000 } )
157+ return ctx . cli . exec ( [ 'app' , 'function' , 'build' , '--path' , ctx . appDir ] , { timeout : CLI_TIMEOUT . medium } )
157158}
158159
159160export async function functionRun (
@@ -162,13 +163,13 @@ export async function functionRun(
162163 } ,
163164) : Promise < ExecResult > {
164165 return ctx . cli . exec ( [ 'app' , 'function' , 'run' , '--path' , ctx . appDir , '--input' , ctx . inputPath ] , {
165- timeout : 60 * 1000 ,
166+ timeout : CLI_TIMEOUT . short ,
166167 } )
167168}
168169
169170export async function versionsList ( ctx : CLIContext ) : Promise < ExecResult > {
170171 return ctx . cli . exec ( [ 'app' , 'versions' , 'list' , '--path' , ctx . appDir , '--json' ] , {
171- timeout : 60 * 1000 ,
172+ timeout : CLI_TIMEOUT . short ,
172173 } )
173174}
174175
@@ -178,7 +179,7 @@ export async function configLink(
178179 } ,
179180) : Promise < ExecResult > {
180181 return ctx . cli . exec ( [ 'app' , 'config' , 'link' , '--path' , ctx . appDir , '--client-id' , ctx . clientId ] , {
181- timeout : 2 * 60 * 1000 ,
182+ timeout : CLI_TIMEOUT . medium ,
182183 } )
183184}
184185
@@ -223,7 +224,7 @@ export async function uninstallApp(
223224 const orgId = ctx . orgId ?? ( process . env . E2E_ORG_ID ?? '' ) . trim ( )
224225
225226 await browserPage . goto ( `${ appUrl } /installs` , { waitUntil : 'domcontentloaded' } )
226- await browserPage . waitForTimeout ( 3000 )
227+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . medium )
227228
228229 const rows = await browserPage . locator ( 'table tbody tr' ) . all ( )
229230 const storeNames : string [ ] = [ ]
@@ -245,20 +246,20 @@ export async function uninstallApp(
245246 let navigated = false
246247 for ( let attempt = 1 ; attempt <= 3 ; attempt ++ ) {
247248 await browserPage . goto ( dashboardUrl , { waitUntil : 'domcontentloaded' } )
248- await browserPage . waitForTimeout ( 3000 )
249+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . medium )
249250
250251 const pageText = ( await browserPage . textContent ( 'body' ) ) ?? ''
251252 if ( pageText . includes ( '500' ) || pageText . includes ( 'Internal Server Error' ) ) continue
252253
253254 const orgButton = browserPage . locator ( 'header button' ) . last ( )
254- if ( ! ( await orgButton . isVisible ( { timeout : 5000 } ) . catch ( ( ) => false ) ) ) continue
255+ if ( ! ( await orgButton . isVisible ( { timeout : BROWSER_TIMEOUT . medium } ) . catch ( ( ) => false ) ) ) continue
255256 await orgButton . click ( )
256- await browserPage . waitForTimeout ( 1000 )
257+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . short )
257258
258259 const storeLink = browserPage . locator ( 'a, button' ) . filter ( { hasText : storeName } ) . first ( )
259- if ( ! ( await storeLink . isVisible ( { timeout : 5000 } ) . catch ( ( ) => false ) ) ) continue
260+ if ( ! ( await storeLink . isVisible ( { timeout : BROWSER_TIMEOUT . medium } ) . catch ( ( ) => false ) ) ) continue
260261 await storeLink . click ( )
261- await browserPage . waitForTimeout ( 3000 )
262+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . medium )
262263 navigated = true
263264 break
264265 }
@@ -271,41 +272,41 @@ export async function uninstallApp(
271272 // Navigate to store's apps settings page
272273 const storeAdminUrl = browserPage . url ( )
273274 await browserPage . goto ( `${ storeAdminUrl . replace ( / \/ $ / , '' ) } /settings/apps` , { waitUntil : 'domcontentloaded' } )
274- await browserPage . waitForTimeout ( 5000 )
275+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . long )
275276
276277 // Dismiss any Dev Console dialog
277278 const cancelButton = browserPage . locator ( 'button:has-text("Cancel")' )
278- if ( await cancelButton . isVisible ( { timeout : 2000 } ) . catch ( ( ) => false ) ) {
279+ if ( await cancelButton . isVisible ( { timeout : BROWSER_TIMEOUT . medium } ) . catch ( ( ) => false ) ) {
279280 await cancelButton . click ( )
280- await browserPage . waitForTimeout ( 1000 )
281+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . short )
281282 }
282283
283284 // Find the app in the installed list (plain span, not Dev Console's Polaris text)
284285 const appSpan = browserPage . locator ( `span:has-text("${ appName } "):not([class*="Polaris"])` ) . first ( )
285- if ( ! ( await appSpan . isVisible ( { timeout : 5000 } ) . catch ( ( ) => false ) ) ) {
286+ if ( ! ( await appSpan . isVisible ( { timeout : BROWSER_TIMEOUT . medium } ) . catch ( ( ) => false ) ) ) {
286287 allUninstalled = false
287288 continue
288289 }
289290
290291 // Click the ⋯ menu button next to the app name
291292 const menuButton = appSpan . locator ( 'xpath=./following::button[1]' )
292293 await menuButton . click ( )
293- await browserPage . waitForTimeout ( 1000 )
294+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . short )
294295
295296 // Click "Uninstall" in the dropdown menu
296297 const uninstallOption = browserPage . locator ( 'text=Uninstall' ) . last ( )
297- if ( ! ( await uninstallOption . isVisible ( { timeout : 3000 } ) . catch ( ( ) => false ) ) ) {
298+ if ( ! ( await uninstallOption . isVisible ( { timeout : BROWSER_TIMEOUT . medium } ) . catch ( ( ) => false ) ) ) {
298299 allUninstalled = false
299300 continue
300301 }
301302 await uninstallOption . click ( )
302- await browserPage . waitForTimeout ( 2000 )
303+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . medium )
303304
304305 // Handle confirmation dialog
305306 const confirmButton = browserPage . locator ( 'button:has-text("Uninstall"), button:has-text("Confirm")' ) . last ( )
306- if ( await confirmButton . isVisible ( { timeout : 3000 } ) . catch ( ( ) => false ) ) {
307+ if ( await confirmButton . isVisible ( { timeout : BROWSER_TIMEOUT . medium } ) . catch ( ( ) => false ) ) {
307308 await confirmButton . click ( )
308- await browserPage . waitForTimeout ( 3000 )
309+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . medium )
309310 }
310311 // eslint-disable-next-line no-catch-all/no-catch-all
311312 } catch ( _err ) {
@@ -325,32 +326,32 @@ export async function deleteApp(
325326 const { browserPage, appUrl} = ctx
326327
327328 await browserPage . goto ( `${ appUrl } /settings` , { waitUntil : 'domcontentloaded' } )
328- await browserPage . waitForTimeout ( 3000 )
329+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . medium )
329330
330331 // Retry if delete button is disabled (uninstall propagation delay)
331332 const deleteButton = browserPage . locator ( 'button:has-text("Delete app")' ) . first ( )
332333 for ( let attempt = 1 ; attempt <= 5 ; attempt ++ ) {
333334 await deleteButton . scrollIntoViewIfNeeded ( )
334335 const isDisabled = await deleteButton . getAttribute ( 'disabled' )
335336 if ( ! isDisabled ) break
336- await browserPage . waitForTimeout ( 5000 )
337+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . long )
337338 await browserPage . reload ( { waitUntil : 'domcontentloaded' } )
338- await browserPage . waitForTimeout ( 3000 )
339+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . medium )
339340 }
340341
341- await deleteButton . click ( { timeout : 10_000 } )
342- await browserPage . waitForTimeout ( 2000 )
342+ await deleteButton . click ( { timeout : BROWSER_TIMEOUT . long } )
343+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . medium )
343344
344345 // Handle confirmation dialog — may need to type "DELETE"
345346 const confirmInput = browserPage . locator ( 'input[type="text"]' ) . last ( )
346- if ( await confirmInput . isVisible ( { timeout : 3000 } ) . catch ( ( ) => false ) ) {
347+ if ( await confirmInput . isVisible ( { timeout : BROWSER_TIMEOUT . medium } ) . catch ( ( ) => false ) ) {
347348 await confirmInput . fill ( 'DELETE' )
348- await browserPage . waitForTimeout ( 500 )
349+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . short )
349350 }
350351
351352 const confirmButton = browserPage . locator ( 'button:has-text("Delete app")' ) . last ( )
352353 await confirmButton . click ( )
353- await browserPage . waitForTimeout ( 3000 )
354+ await browserPage . waitForTimeout ( BROWSER_TIMEOUT . medium )
354355}
355356
356357/** Best-effort teardown: find app on dashboard by name, uninstall from all stores, delete. */
0 commit comments