test(app): e2e utilities

This commit is contained in:
Adam
2026-01-18 05:43:34 -06:00
parent f5eb90514a
commit dd19c3d8f2
6 changed files with 69 additions and 87 deletions

View File

@@ -1,29 +1,11 @@
import { test, expect } from "@playwright/test"
import { createOpencodeClient } from "@opencode-ai/sdk/v2/client"
import { base64Encode } from "@opencode-ai/util/encode"
const host = process.env.PLAYWRIGHT_SERVER_HOST ?? "localhost"
const port = process.env.PLAYWRIGHT_SERVER_PORT ?? "4096"
const url = `http://${host}:${port}`
async function getWorktree() {
const sdk = createOpencodeClient({ baseUrl: url, throwOnError: true })
const result = await sdk.path.get()
const data = result.data
if (!data?.worktree) throw new Error(`Failed to resolve a worktree from ${url}/path`)
return data.worktree
}
const mod = process.platform === "darwin" ? "Meta" : "Control"
import { gotoSession, modKey, promptSelector } from "./utils"
test("search palette opens and closes", async ({ page }) => {
const directory = await getWorktree()
const slug = base64Encode(directory)
await gotoSession(page)
await expect(page.locator(promptSelector)).toBeVisible()
await page.goto(`/${slug}/session`)
await expect(page.locator('[data-component="prompt-input"]')).toBeVisible()
await page.keyboard.press(`${mod}+P`)
await page.keyboard.press(`${modKey}+P`)
const dialog = page.getByRole("dialog")
await expect(dialog).toBeVisible()