diff options
| author | Adam <[email protected]> | 2026-01-20 09:34:05 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2026-01-20 14:02:09 -0600 |
| commit | 1ac0980c80f9e670145c20e51b03d25242f3ab22 (patch) | |
| tree | 861867ef4a1ea36a359815b1ab39a6304e1d23db /packages/app | |
| parent | 1d6f650f5340c439c596fc49010b9114e72b0793 (diff) | |
| download | opencode-1ac0980c80f9e670145c20e51b03d25242f3ab22.tar.gz opencode-1ac0980c80f9e670145c20e51b03d25242f3ab22.zip | |
test(app): windows e2e
Diffstat (limited to 'packages/app')
| -rw-r--r-- | packages/app/e2e/prompt.spec.ts | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/packages/app/e2e/prompt.spec.ts b/packages/app/e2e/prompt.spec.ts new file mode 100644 index 000000000..26cab5a38 --- /dev/null +++ b/packages/app/e2e/prompt.spec.ts @@ -0,0 +1,67 @@ +import { test, expect } from "./fixtures" +import { promptSelector } from "./utils" + +function sessionIDFromUrl(url: string) { + const match = /\/session\/([^/?#]+)/.exec(url) + return match?.[1] +} + +test("can send a prompt and receive a reply", async ({ page, sdk, gotoSession }) => { + test.setTimeout(120_000) + + const pageErrors: string[] = [] + const onPageError = (err: Error) => { + pageErrors.push(err.message) + } + page.on("pageerror", onPageError) + + await gotoSession() + + const token = `E2E_OK_${Date.now()}` + + const prompt = page.locator(promptSelector) + await prompt.click() + await page.keyboard.type(`Reply with exactly: ${token}`) + await page.keyboard.press("Enter") + + await expect(page).toHaveURL(/\/session\/[^/?#]+/, { timeout: 30_000 }) + + const sessionID = (() => { + const id = sessionIDFromUrl(page.url()) + if (!id) throw new Error(`Failed to parse session id from url: ${page.url()}`) + return id + })() + + try { + await expect + .poll( + async () => { + const messages = await sdk.session.messages({ sessionID, limit: 50 }).then((r) => r.data ?? []) + const assistant = messages + .slice() + .reverse() + .find((m) => m.info.role === "assistant") + + return ( + assistant?.parts + .filter((p) => p.type === "text") + .map((p) => p.text) + .join("\n") ?? "" + ) + }, + { timeout: 90_000 }, + ) + + .toContain(token) + + const reply = page.locator('[data-component="text-part"]').filter({ hasText: token }).first() + await expect(reply).toBeVisible({ timeout: 90_000 }) + } finally { + page.off("pageerror", onPageError) + await sdk.session.delete({ sessionID }).catch(() => undefined) + } + + if (pageErrors.length > 0) { + throw new Error(`Page error(s):\n${pageErrors.join("\n")}`) + } +}) |
