|
1 |
| -import { expect, type Page } from "@playwright/test"; |
| 1 | +import { type BrowserContext, expect, type Page } from "@playwright/test"; |
2 | 2 | import axios from "axios";
|
3 | 3 | import { type ChildProcess, exec, spawn } from "child_process";
|
4 | 4 | import { randomUUID } from "crypto";
|
@@ -445,7 +445,7 @@ const createTemplateVersionTar = async (
|
445 | 445 | resource.agents = resource.agents?.map(
|
446 | 446 | (agent: RecursivePartial<Agent>) => {
|
447 | 447 | if (agent.apps) {
|
448 |
| - agent.apps = agent.apps?.map((app: RecursivePartial<App>) => { |
| 448 | + agent.apps = agent.apps.map((app) => { |
449 | 449 | return {
|
450 | 450 | command: "",
|
451 | 451 | displayName: "example",
|
@@ -791,3 +791,23 @@ export const updateWorkspaceParameters = async (
|
791 | 791 | state: "visible",
|
792 | 792 | });
|
793 | 793 | };
|
| 794 | + |
| 795 | +export async function openTerminalWindow( |
| 796 | + page: Page, |
| 797 | + context: BrowserContext, |
| 798 | + workspaceName: string, |
| 799 | +): Promise<Page> { |
| 800 | + // Wait for the web terminal to open in a new tab |
| 801 | + const pagePromise = context.waitForEvent("page"); |
| 802 | + await page.getByTestId("terminal").click(); |
| 803 | + const terminal = await pagePromise; |
| 804 | + await terminal.waitForLoadState("domcontentloaded"); |
| 805 | + |
| 806 | + // Specify that the shell should be `bash`, to prevent inheriting a shell that |
| 807 | + // isn't POSIX compatible, such as Fish. |
| 808 | + const commandQuery = `?command=${encodeURIComponent("/usr/bin/env bash")}`; |
| 809 | + await expect(terminal).toHaveURL(`/@admin/${workspaceName}.dev/terminal`); |
| 810 | + await terminal.goto(`/@admin/${workspaceName}.dev/terminal${commandQuery}`); |
| 811 | + |
| 812 | + return terminal; |
| 813 | +} |
0 commit comments