( page: Page, context: BrowserContext, workspaceName: string, agentName = "dev", )
| 1247 | }; |
| 1248 | |
| 1249 | export async function openTerminalWindow( |
| 1250 | page: Page, |
| 1251 | context: BrowserContext, |
| 1252 | workspaceName: string, |
| 1253 | agentName = "dev", |
| 1254 | ): Promise<Page> { |
| 1255 | // Wait for the web terminal to open in a new tab |
| 1256 | const pagePromise = context.waitForEvent("page"); |
| 1257 | await page |
| 1258 | .getByRole("link", { name: /terminal/i }) |
| 1259 | .click({ timeout: 60_000 }); |
| 1260 | const terminal = await pagePromise; |
| 1261 | await terminal.waitForLoadState("domcontentloaded"); |
| 1262 | |
| 1263 | // Specify that the shell should be `bash`, to prevent inheriting a shell that |
| 1264 | // isn't POSIX compatible, such as Fish. |
| 1265 | const user = currentUser(page); |
| 1266 | const commandQuery = `?command=${encodeURIComponent("/usr/bin/env bash")}`; |
| 1267 | await expectUrl(terminal).toHavePathName( |
| 1268 | `/@${user.username}/${workspaceName}.${agentName}/terminal`, |
| 1269 | ); |
| 1270 | await terminal.goto( |
| 1271 | `/@${user.username}/${workspaceName}.${agentName}/terminal${commandQuery}`, |
| 1272 | ); |
| 1273 | |
| 1274 | // The terminal command confirmation dialog requires explicit user |
| 1275 | // approval before the command executes. |
| 1276 | await terminal.getByRole("button", { name: "Run command" }).click(); |
| 1277 | |
| 1278 | return terminal; |
| 1279 | } |
| 1280 | |
| 1281 | type UserValues = { |
| 1282 | name: string; |
no test coverage detected