Skip to content

Commit cfb484f

Browse files
authored
fix: always use bash when executing web terminal tests (#12755)
1 parent 064a08e commit cfb484f

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

site/e2e/helpers.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect, type Page } from "@playwright/test";
1+
import { type BrowserContext, expect, type Page } from "@playwright/test";
22
import axios from "axios";
33
import { type ChildProcess, exec, spawn } from "child_process";
44
import { randomUUID } from "crypto";
@@ -445,7 +445,7 @@ const createTemplateVersionTar = async (
445445
resource.agents = resource.agents?.map(
446446
(agent: RecursivePartial<Agent>) => {
447447
if (agent.apps) {
448-
agent.apps = agent.apps?.map((app: RecursivePartial<App>) => {
448+
agent.apps = agent.apps.map((app) => {
449449
return {
450450
command: "",
451451
displayName: "example",
@@ -791,3 +791,23 @@ export const updateWorkspaceParameters = async (
791791
state: "visible",
792792
});
793793
};
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+
}

site/e2e/tests/webTerminal.spec.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { randomUUID } from "crypto";
33
import {
44
createTemplate,
55
createWorkspace,
6+
openTerminalWindow,
67
startAgent,
78
stopAgent,
89
} from "../helpers";
@@ -33,14 +34,9 @@ test("web terminal", async ({ context, page }) => {
3334
},
3435
],
3536
});
36-
await createWorkspace(page, template);
37+
const workspaceName = await createWorkspace(page, template);
3738
const agent = await startAgent(page, token);
38-
39-
// Wait for the web terminal to open in a new tab
40-
const pagePromise = context.waitForEvent("page");
41-
await page.getByTestId("terminal").click();
42-
const terminal = await pagePromise;
43-
await terminal.waitForLoadState("domcontentloaded");
39+
const terminal = await openTerminalWindow(page, context, workspaceName);
4440

4541
await terminal.waitForSelector("div.xterm-rows", {
4642
state: "visible",

0 commit comments

Comments
 (0)