|
@@ -1,22 +1,9 @@
|
|
|
import { test, expect } from "@playwright/test"
|
|
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
|
|
|
|
|
-}
|
|
|
|
|
|
|
+import { createSdk, getWorktree, promptSelector, sessionPath } from "./utils"
|
|
|
|
|
|
|
|
test("can open an existing session and type into the prompt", async ({ page }) => {
|
|
test("can open an existing session and type into the prompt", async ({ page }) => {
|
|
|
const directory = await getWorktree()
|
|
const directory = await getWorktree()
|
|
|
- const sdk = createOpencodeClient({ baseUrl: url, directory, throwOnError: true })
|
|
|
|
|
|
|
+ const sdk = createSdk(directory)
|
|
|
const title = `e2e smoke ${Date.now()}`
|
|
const title = `e2e smoke ${Date.now()}`
|
|
|
const created = await sdk.session.create({ title }).then((r) => r.data)
|
|
const created = await sdk.session.create({ title }).then((r) => r.data)
|
|
|
|
|
|
|
@@ -24,9 +11,9 @@ test("can open an existing session and type into the prompt", async ({ page }) =
|
|
|
const sessionID = created.id
|
|
const sessionID = created.id
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await page.goto(`/${base64Encode(directory)}/session/${sessionID}`)
|
|
|
|
|
|
|
+ await page.goto(sessionPath(directory, sessionID))
|
|
|
|
|
|
|
|
- const prompt = page.locator('[data-component="prompt-input"]')
|
|
|
|
|
|
|
+ const prompt = page.locator(promptSelector)
|
|
|
await expect(prompt).toBeVisible()
|
|
await expect(prompt).toBeVisible()
|
|
|
|
|
|
|
|
await prompt.click()
|
|
await prompt.click()
|