MCPcopy Index your code
hub / github.com/coder/coder / openTerminalWindow

Function openTerminalWindow

site/e2e/helpers.ts:1249–1279  ·  view source on GitHub ↗
(
	page: Page,
	context: BrowserContext,
	workspaceName: string,
	agentName = "dev",
)

Source from the content-addressed store, hash-verified

1247};
1248
1249export 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
1281type UserValues = {
1282 name: string;

Callers 2

Calls 1

currentUserFunction · 0.85

Tested by

no test coverage detected