| 13 | * @returns true if workspace is open, false otherwise |
| 14 | */ |
| 15 | export async function ensureWorkspaceOpen(startupPage: StartupPage): Promise<boolean> { |
| 16 | const startupVisible = await startupPage.isVisible(); |
| 17 | |
| 18 | if (!startupVisible) { |
| 19 | // Workspace is already open |
| 20 | return true; |
| 21 | } |
| 22 | |
| 23 | const testWorkspacePath = process.env.E2E_TEST_WORKSPACE || process.cwd(); |
| 24 | console.log('[WorkspaceUtils] Opening test workspace through frontend state:', testWorkspacePath); |
| 25 | |
| 26 | try { |
| 27 | const opened = await openWorkspace(testWorkspacePath); |
| 28 | if (!opened) { |
| 29 | return false; |
| 30 | } |
| 31 | await ensureCodeSessionOpen(); |
| 32 | console.log('[WorkspaceUtils] Test workspace opened successfully'); |
| 33 | return true; |
| 34 | } catch (error) { |
| 35 | console.error('[WorkspaceUtils] Failed to open test workspace:', error); |
| 36 | return false; |
| 37 | } |
| 38 | } |