mirror of https://github.com/coder/coder.git
fix: always use bash when executing web terminal tests (#12755)
This commit is contained in:
parent
064a08efa5
commit
cfb484fa25
|
@ -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";
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import { randomUUID } from "crypto";
|
|||
import {
|
||||
createTemplate,
|
||||
createWorkspace,
|
||||
openTerminalWindow,
|
||||
startAgent,
|
||||
stopAgent,
|
||||
} from "../helpers";
|
||||
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue