diff options
| author | Luke Parker <[email protected]> | 2026-03-12 17:35:26 +1000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-03-12 17:35:26 +1000 |
| commit | 328c6de80d51704c09bdd962df2ddf5b9d7c82ea (patch) | |
| tree | bf6426b3afeb824feaae73aa22cfc20e6e0d438d /packages/app/e2e/terminal | |
| parent | c9c0318e0e5c2fcd80fc1c32a1ccfe360f182f90 (diff) | |
| download | opencode-328c6de80d51704c09bdd962df2ddf5b9d7c82ea.tar.gz opencode-328c6de80d51704c09bdd962df2ddf5b9d7c82ea.zip | |
Fix terminal e2e flakiness with a real terminal driver (#17144)
Diffstat (limited to 'packages/app/e2e/terminal')
| -rw-r--r-- | packages/app/e2e/terminal/terminal-init.spec.ts | 6 | ||||
| -rw-r--r-- | packages/app/e2e/terminal/terminal-tabs.spec.ts | 21 | ||||
| -rw-r--r-- | packages/app/e2e/terminal/terminal.spec.ts | 3 |
3 files changed, 12 insertions, 18 deletions
diff --git a/packages/app/e2e/terminal/terminal-init.spec.ts b/packages/app/e2e/terminal/terminal-init.spec.ts index 18991bf76..d9bbfa2be 100644 --- a/packages/app/e2e/terminal/terminal-init.spec.ts +++ b/packages/app/e2e/terminal/terminal-init.spec.ts @@ -1,4 +1,5 @@ import { test, expect } from "../fixtures" +import { waitTerminalReady } from "../actions" import { promptSelector, terminalSelector } from "../selectors" import { terminalToggleKey } from "../utils" @@ -13,8 +14,7 @@ test("smoke terminal mounts and can create a second tab", async ({ page, gotoSes await page.keyboard.press(terminalToggleKey) } - await expect(terminals.first()).toBeVisible() - await expect(terminals.first().locator("textarea")).toHaveCount(1) + await waitTerminalReady(page, { term: terminals.first() }) await expect(terminals).toHaveCount(1) // Ghostty captures a lot of keybinds when focused; move focus back @@ -24,5 +24,5 @@ test("smoke terminal mounts and can create a second tab", async ({ page, gotoSes await expect(tabs).toHaveCount(2) await expect(terminals).toHaveCount(1) - await expect(terminals.first().locator("textarea")).toHaveCount(1) + await waitTerminalReady(page, { term: terminals.first() }) }) diff --git a/packages/app/e2e/terminal/terminal-tabs.spec.ts b/packages/app/e2e/terminal/terminal-tabs.spec.ts index afa6254cd..ca1f7eee8 100644 --- a/packages/app/e2e/terminal/terminal-tabs.spec.ts +++ b/packages/app/e2e/terminal/terminal-tabs.spec.ts @@ -1,4 +1,5 @@ import type { Page } from "@playwright/test" +import { runTerminal, waitTerminalReady } from "../actions" import { test, expect } from "../fixtures" import { terminalSelector } from "../selectors" import { terminalToggleKey, workspacePersistKey } from "../utils" @@ -17,16 +18,7 @@ async function open(page: Page) { const terminal = page.locator(terminalSelector) const visible = await terminal.isVisible().catch(() => false) if (!visible) await page.keyboard.press(terminalToggleKey) - await expect(terminal).toBeVisible() - await expect(terminal.locator("textarea")).toHaveCount(1) -} - -async function run(page: Page, cmd: string) { - const terminal = page.locator(terminalSelector) - await expect(terminal).toBeVisible() - await terminal.click() - await page.keyboard.type(cmd) - await page.keyboard.press("Enter") + await waitTerminalReady(page, { term: terminal }) } async function store(page: Page, key: string) { @@ -56,15 +48,16 @@ test("inactive terminal tab buffers persist across tab switches", async ({ page, await gotoSession() await open(page) - await run(page, `echo ${one}`) + await runTerminal(page, { cmd: `echo ${one}`, token: one }) await page.getByRole("button", { name: /new terminal/i }).click() await expect(tabs).toHaveCount(2) - await run(page, `echo ${two}`) + await runTerminal(page, { cmd: `echo ${two}`, token: two }) await first.click() await expect(first).toHaveAttribute("aria-selected", "true") + await expect .poll( async () => { @@ -76,7 +69,7 @@ test("inactive terminal tab buffers persist across tab switches", async ({ page, second: second.includes(two), } }, - { timeout: 30_000 }, + { timeout: 5_000 }, ) .toEqual({ first: false, second: true }) @@ -93,7 +86,7 @@ test("inactive terminal tab buffers persist across tab switches", async ({ page, second: second.includes(two), } }, - { timeout: 30_000 }, + { timeout: 5_000 }, ) .toEqual({ first: true, second: false }) }) diff --git a/packages/app/e2e/terminal/terminal.spec.ts b/packages/app/e2e/terminal/terminal.spec.ts index ef88aa34e..768f7c182 100644 --- a/packages/app/e2e/terminal/terminal.spec.ts +++ b/packages/app/e2e/terminal/terminal.spec.ts @@ -1,4 +1,5 @@ import { test, expect } from "../fixtures" +import { waitTerminalReady } from "../actions" import { terminalSelector } from "../selectors" import { terminalToggleKey } from "../utils" @@ -13,5 +14,5 @@ test("terminal panel can be toggled", async ({ page, gotoSession }) => { } await page.keyboard.press(terminalToggleKey) - await expect(terminal).toBeVisible() + await waitTerminalReady(page, { term: terminal }) }) |
