mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import { expect, story } from "../../stories/playwright/story"
|
|
|
|
story(
|
|
"chooses a worktree for a session whose folder is gone from the shared worktree dialog",
|
|
async ({ mount, page }) => {
|
|
await mount("session-missing-location--many-worktrees")
|
|
|
|
const trigger = page.getByRole("button", { name: "Choose worktree", exact: true })
|
|
|
|
const search = page.getByRole("combobox", { name: "Search worktrees", exact: true })
|
|
|
|
const rows = page.getByRole("option")
|
|
|
|
await trigger.focus()
|
|
await page.keyboard.press("Enter")
|
|
await expect(search).toBeFocused()
|
|
await expect(rows.first()).toContainText("/Users/alex/work/opencode")
|
|
|
|
// Hovering moves the highlight, never focus, so typing still reaches the search field.
|
|
for (const index of [2, 3, 4, 5, 6, 7, 8]) {
|
|
await rows.nth(index).hover()
|
|
await expect(search).toBeFocused()
|
|
}
|
|
|
|
// The search field names the active row, so Tab and Shift+Tab never land on a row.
|
|
for (const key of ["Tab", "Shift+Tab"]) {
|
|
await search.focus()
|
|
await page.keyboard.press(key)
|
|
await expect(page.locator('[role="option"]:focus')).toHaveCount(0)
|
|
}
|
|
|
|
await search.focus()
|
|
await page.keyboard.type("rev")
|
|
await expect(search).toHaveValue("rev")
|
|
|
|
await page.keyboard.press("Escape")
|
|
await expect(search).toBeHidden()
|
|
await expect(trigger).toBeFocused()
|
|
expect(await trigger.evaluate((element) => element.matches(":focus-visible"))).toBe(true)
|
|
|
|
await page.keyboard.press("Enter")
|
|
await expect(search).toBeFocused()
|
|
await page.keyboard.type("comp")
|
|
await expect(rows).toHaveCount(1)
|
|
await expect(rows).toContainText("opencode-composer")
|
|
|
|
// The main checkout leads the list, so clearing the search and pressing Enter moves the session there.
|
|
await search.fill("")
|
|
await page.keyboard.press("Enter")
|
|
await expect(page.getByText("Session moved to /Users/alex/work/opencode", { exact: true })).toBeVisible()
|
|
},
|
|
)
|