Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com> Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Jay <53023+jayair@users.noreply.github.com> Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com> Co-authored-by: BB84 <110078428+BB-84C@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com> Co-authored-by: Dax <mail@thdxr.com> Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: Jay V <air@live.ca> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com> Co-authored-by: Jack <jack@anoma.ly> Co-authored-by: Sebastian <hasta84@gmail.com> Co-authored-by: Jérôme Benoit <jerome.benoit@sap.com> Co-authored-by: Test User <test@test.com> Co-authored-by: Simon Klee <hello@simonklee.dk> Co-authored-by: Rahul A Mistry <149420892+ProdigyRahul@users.noreply.github.com> Co-authored-by: Qiping Li <liqiping1991@gmail.com> Co-authored-by: liqiping <liqiping@msh.team> Co-authored-by: OpeOginni <107570612+OpeOginni@users.noreply.github.com> Co-authored-by: Matthias Reso <13337103+mreso@users.noreply.github.com> Co-authored-by: tobwen <1864057+tobwen@users.noreply.github.com> Co-authored-by: Daniel Polito <danielbpolito@gmail.com> Co-authored-by: opencode <noreply@opencode.ai> Co-authored-by: Devin R Leopold <devin.leopold@gmail.com> Co-authored-by: Zach Bruggeman <mail@bruggie.com> Co-authored-by: Zach Bruggeman <zbruggeman@ramp.com> Co-authored-by: Kit Langton <kit.langton@gmail.com> Co-authored-by: David Siewert <david1gruppenplan@gmail.com> Co-authored-by: Andrei Dziahel <develop7@develop7.info> Co-authored-by: adityachaudhary99 <adityaachaudhary2003@gmail.com> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: Matt Carey <mcarey@cloudflare.com>
117 lines
3.6 KiB
TypeScript
117 lines
3.6 KiB
TypeScript
import { expect, test } from "@playwright/test"
|
|
import { mockOpenCodeServer } from "../utils/mock-server"
|
|
import { expectSessionTitle } from "../utils/waits"
|
|
|
|
const directory = "C:/OpenCode/HiddenTerminalRegression"
|
|
const projectID = "proj_hidden_terminal_regression"
|
|
const sessionID = "ses_hidden_terminal_regression"
|
|
const title = "Hidden terminal regression"
|
|
|
|
test("unmounts the terminal panel while it is hidden", async ({ page }) => {
|
|
await page.setViewportSize({ width: 1400, height: 900 })
|
|
await mockOpenCodeServer(page, {
|
|
protocol: "v2",
|
|
directory,
|
|
project: {
|
|
id: projectID,
|
|
worktree: directory,
|
|
vcs: "git",
|
|
name: "hidden-terminal-regression",
|
|
time: { created: 1700000000000, updated: 1700000000000 },
|
|
sandboxes: [],
|
|
},
|
|
provider: {
|
|
all: [
|
|
{
|
|
id: "opencode",
|
|
name: "OpenCode",
|
|
models: { test: { id: "test", name: "Test", limit: { context: 200_000 } } },
|
|
},
|
|
],
|
|
connected: ["opencode"],
|
|
default: { providerID: "opencode", modelID: "test" },
|
|
},
|
|
sessions: [
|
|
{
|
|
id: sessionID,
|
|
slug: "hidden-terminal-regression",
|
|
projectID,
|
|
directory,
|
|
title,
|
|
version: "dev",
|
|
time: { created: 1700000000000, updated: 1700000000000 },
|
|
},
|
|
],
|
|
pageMessages: () => ({ items: [] }),
|
|
})
|
|
await page.route("**/api/pty*", (route) =>
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: "application/json",
|
|
body: JSON.stringify({
|
|
location: { directory, project: { id: projectID, directory } },
|
|
data: {
|
|
id: "pty_hidden_terminal",
|
|
title: "Terminal 1",
|
|
command: "cmd.exe",
|
|
args: [],
|
|
cwd: directory,
|
|
status: "running",
|
|
pid: 1,
|
|
},
|
|
}),
|
|
}),
|
|
)
|
|
await page.route("**/api/pty/pty_hidden_terminal*", (route) =>
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: "application/json",
|
|
body: JSON.stringify({
|
|
location: { directory, project: { id: projectID, directory } },
|
|
data: {
|
|
id: "pty_hidden_terminal",
|
|
title: "Terminal 1",
|
|
command: "cmd.exe",
|
|
args: [],
|
|
cwd: directory,
|
|
status: "running",
|
|
pid: 1,
|
|
},
|
|
}),
|
|
}),
|
|
)
|
|
await page.route("**/api/pty/pty_hidden_terminal/connect-token*", (route) =>
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: "application/json",
|
|
body: JSON.stringify({
|
|
location: { directory, project: { id: projectID, directory } },
|
|
data: { ticket: "e2e-ticket", expires_in: 60 },
|
|
}),
|
|
}),
|
|
)
|
|
await page.routeWebSocket("**/api/pty/pty_hidden_terminal/connect", () => undefined)
|
|
|
|
await page.goto(`/${base64Encode(directory)}/session/${sessionID}`)
|
|
await expectSessionTitle(page, title)
|
|
|
|
await page.keyboard.press("Control+Backquote")
|
|
const panel = page.locator("#terminal-panel")
|
|
await expect(panel).toHaveAttribute("aria-hidden", "false")
|
|
await expect(page.locator('[data-component="terminal"]')).toBeVisible()
|
|
|
|
await page.keyboard.press("Control+Backquote")
|
|
await expect(panel).toHaveCount(0)
|
|
await expect(page.locator('[data-component="terminal"]')).toHaveCount(0)
|
|
|
|
await page.setViewportSize({ width: 1200, height: 700 })
|
|
await expect(page.locator('[data-component="terminal"]')).toHaveCount(0)
|
|
|
|
await page.keyboard.press("Control+Backquote")
|
|
await expect(panel).toBeVisible()
|
|
await expect(page.locator('[data-component="terminal"]')).toBeVisible()
|
|
})
|
|
|
|
function base64Encode(value: string) {
|
|
return Buffer.from(value, "utf8").toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "")
|
|
}
|