Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: always use bash when executing web terminal tests
  • Loading branch information
aslilac committed Mar 25, 2024
commit 237a5d1017cb3c000987348b1f8c3aeb7534bb5c
24 changes: 22 additions & 2 deletions site/e2e/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, type Page } from "@playwright/test";
import { type BrowserContext, expect, type Page } from "@playwright/test";
import axios from "axios";
import { type ChildProcess, exec, spawn } from "child_process";
import { randomUUID } from "crypto";
Expand Down Expand Up @@ -445,7 +445,7 @@ const createTemplateVersionTar = async (
resource.agents = resource.agents?.map(
(agent: RecursivePartial<Agent>) => {
if (agent.apps) {
agent.apps = agent.apps?.map((app: RecursivePartial<App>) => {
agent.apps = agent.apps.map((app) => {
return {
command: "",
displayName: "example",
Expand Down Expand Up @@ -791,3 +791,23 @@ export const updateWorkspaceParameters = async (
state: "visible",
});
};

export async function openTerminalWindow(
page: Page,
context: BrowserContext,
workspaceName: string,
): Promise<Page> {
// Wait for the web terminal to open in a new tab
const pagePromise = context.waitForEvent("page");
await page.getByTestId("terminal").click();
const terminal = await pagePromise;
await terminal.waitForLoadState("domcontentloaded");

// Specify that the shell should be `bash`, to prevent inheriting a shell that
// isn't POSIX compatible, such as Fish.
const commandQuery = `?command=${encodeURIComponent("/usr/bin/env bash")}`;
await expect(terminal).toHaveURL(`/@admin/${workspaceName}.dev/terminal`);
await terminal.goto(`/@admin/${workspaceName}.dev/terminal${commandQuery}`);

return terminal;
}
10 changes: 3 additions & 7 deletions site/e2e/tests/webTerminal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { randomUUID } from "crypto";
import {
createTemplate,
createWorkspace,
openTerminalWindow,
startAgent,
stopAgent,
} from "../helpers";
Expand Down Expand Up @@ -33,14 +34,9 @@ test("web terminal", async ({ context, page }) => {
},
],
});
await createWorkspace(page, template);
const workspaceName = await createWorkspace(page, template);
const agent = await startAgent(page, token);

// Wait for the web terminal to open in a new tab
const pagePromise = context.waitForEvent("page");
await page.getByTestId("terminal").click();
const terminal = await pagePromise;
await terminal.waitForLoadState("domcontentloaded");
const terminal = await openTerminalWindow(page, context, workspaceName);

await terminal.waitForSelector("div.xterm-rows", {
state: "visible",
Expand Down