* Create workspace and handle cleanup on test failure * Returns result and cleanup function
( env: TestEnvironment, projectPath: string, branchName: string, trunkBranch: string, runtimeConfig?: RuntimeConfig )
| 120 | * Returns result and cleanup function |
| 121 | */ |
| 122 | async function createWorkspaceWithCleanup( |
| 123 | env: TestEnvironment, |
| 124 | projectPath: string, |
| 125 | branchName: string, |
| 126 | trunkBranch: string, |
| 127 | runtimeConfig?: RuntimeConfig |
| 128 | ): Promise<{ |
| 129 | result: |
| 130 | | { success: true; metadata: FrontendWorkspaceMetadata } |
| 131 | | { success: false; error: string }; |
| 132 | cleanup: () => Promise<void>; |
| 133 | }> { |
| 134 | // Trust the project so hooks and scripts can run during workspace creation |
| 135 | await env.orpc.projects.setTrust({ projectPath, trusted: true }); |
| 136 | |
| 137 | const result = await env.orpc.workspace.create({ |
| 138 | projectPath, |
| 139 | branchName, |
| 140 | trunkBranch, |
| 141 | runtimeConfig, |
| 142 | }); |
| 143 | console.log("Create invoked, success:", result.success); |
| 144 | |
| 145 | // Note: Events are forwarded via test setup wiring in setup.ts: |
| 146 | // workspaceService.on("chat") -> windowService.send() -> webContents.send() |
| 147 | // No need for additional ORPC subscription pipe here. |
| 148 | |
| 149 | const cleanup = async () => { |
| 150 | if (result.success) { |
| 151 | await env.orpc.workspace.remove({ workspaceId: result.metadata.id }); |
| 152 | } |
| 153 | }; |
| 154 | |
| 155 | return { result, cleanup }; |
| 156 | } |
| 157 | |
| 158 | describeIntegration("WORKSPACE_CREATE with both runtimes", () => { |
| 159 | beforeAll(async () => { |