@@ -157,12 +157,36 @@ export async function setup(project: TestProject): Promise<void> {
157157 }
158158
159159 // ── Discover workspaces ──────────────────────────────────────────────────
160- const { primaryWsId , primaryWsName , secondaryWsId } = await discoverWorkspaces (
160+ const workspaces = await discoverWorkspaces (
161161 consoleBase ,
162162 cookieString ,
163163 csrfToken ,
164164 E . edition ,
165165 )
166+ if ( ! workspaces ) {
167+ project . provide ( 'e2eCapabilities' , {
168+ tokenValid : true ,
169+ tokenId : match ?. id ,
170+ edition : E . edition ,
171+ token : primaryToken ,
172+ logoutToken : '' ,
173+ devicesToken : '' ,
174+ workspaceId : '' ,
175+ workspaceName : '' ,
176+ ws2Id : '' ,
177+ chatAppId : '' ,
178+ workflowAppId : '' ,
179+ fileAppId : '' ,
180+ fileChatAppId : '' ,
181+ hitlAppId : '' ,
182+ hitlExternalAppId : '' ,
183+ hitlSingleActionAppId : '' ,
184+ hitlMultiNodeAppId : '' ,
185+ ws2AppId : '' ,
186+ } satisfies E2ECapabilities )
187+ return
188+ }
189+ const { primaryWsId, primaryWsName, secondaryWsId } = workspaces
166190
167191 // ── Mint per-suite dedicated tokens ──────────────────────────────────────
168192 let logoutToken = ''
@@ -325,7 +349,7 @@ async function discoverWorkspaces(
325349 cookieString : string ,
326350 csrfToken : string ,
327351 edition : 'ce' | 'ee' ,
328- ) : Promise < { primaryWsId : string , primaryWsName : string , secondaryWsId : string } > {
352+ ) : Promise < { primaryWsId : string , primaryWsName : string , secondaryWsId : string } | null > {
329353 const wsRes = await fetch ( `${ consoleBase } /console/api/workspaces` , {
330354 headers : { 'Cookie' : cookieString , 'X-CSRF-Token' : csrfToken } ,
331355 signal : AbortSignal . timeout ( 10_000 ) ,
@@ -343,26 +367,21 @@ async function discoverWorkspaces(
343367 const ws0 = all . find ( w => w . name === 'auto_test0' )
344368 const ws1 = all . find ( w => w . name === 'auto_test1' )
345369
346- if ( ! ws0 ) {
347- throw new Error (
348- '[E2E EE] Workspace "auto_test0" not found. '
349- + 'Please pre-create it for the test account before running E2E tests.' ,
350- )
351- }
352-
353- if ( ! ws1 ) {
370+ if ( ! ws0 || ! ws1 ) {
371+ const existing = all . map ( w => w . name ) . join ( ', ' ) || '(none)'
354372 console . warn (
355- ' [E2E EE] Workspace "auto_test1" not found — secondary workspace will reuse primary. '
356- + 'Cross-workspace [EE] tests may not work correctly .' ,
373+ ` [E2E EE] Required workspaces not found; expected auto_test0 and auto_test1, got: ${ existing } . `
374+ + 'Skip fixture app provisioning .' ,
357375 )
376+ return null
358377 }
359378
360379 const primaryWsId = ws0 . id
361380 const primaryWsName = ws0 . name
362- const secondaryWsId = ws1 ?. id ?? ws0 . id
381+ const secondaryWsId = ws1 . id
363382
364383 console . warn ( `[E2E EE] primary workspace: ${ primaryWsName } (${ primaryWsId } )` )
365- console . warn ( `[E2E EE] secondary workspace: ${ ws1 ? .name ?? 'reuses primary' } (${ secondaryWsId } )` )
384+ console . warn ( `[E2E EE] secondary workspace: ${ ws1 . name } (${ secondaryWsId } )` )
366385
367386 return { primaryWsId, primaryWsName, secondaryWsId }
368387 }
@@ -460,7 +479,7 @@ async function provisionApps(
460479 const url = `${ consoleBase } /console/api/apps?name=${ encodeURIComponent ( name ) } &limit=50&page=1`
461480 const r = await fetch ( url , { headers : mkHeaders ( ) , signal : AbortSignal . timeout ( 10_000 ) } )
462481 if ( ! r . ok )
463- return null
482+ throw new Error ( `list apps by name " ${ name } " failed: HTTP ${ r . status } ` )
464483 const d = await r . json ( ) as { data ?: Array < { id : string , name : string } > }
465484 return d . data ?. find ( a => a . name === name ) ?. id ?? null
466485 }
@@ -540,14 +559,14 @@ async function provisionApps(
540559 }
541560
542561 const dsl = await readFile ( join ( fixturesDir , dslFile ) , 'utf8' )
543- const appName = ( dsl . match ( / ^ [ \t ] + n a m e : [ \t ] * ( \\ S [ ^ \ \n ] * ) $ / m) ?? [ ] ) [ 1 ]
562+ const appName = ( dsl . match ( / ^ [ \t ] + n a m e : [ \t ] * ( \S [ ^ \n ] * ) $ / m) ?? [ ] ) [ 1 ]
544563 ?. trim ( )
545564 . replace ( / ^ [ ' " ] | [ ' " ] $ / g, '' ) ?? dslFile
546565 const appMode = ( dsl . match ( / ^ \s + m o d e : \s * ( \S + ) / m) ?? [ ] ) [ 1 ] ?? ''
547566
548567 let appId = await findAppByName ( appName )
549568 if ( appId ) {
550- console . warn ( `[E2E provision] ${ dslFile } : exists id=${ appId } ` )
569+ console . warn ( `[E2E provision] ${ dslFile } : exists in workspace id=${ appId } ; skip import ` )
551570 }
552571 else {
553572 appId = await importFromDsl ( dsl )
0 commit comments