summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-02-04 10:28:24 -0600
committerAdam <[email protected]>2026-02-04 10:28:24 -0600
commitc875a1fc900f044874b2072468719e117e948840 (patch)
tree4d350f1bef21ee412070792554f940fd97ea3e41
parent1721c6efdf4d6b4c786fb49aabc544e3b4a3b616 (diff)
downloadopencode-c875a1fc900f044874b2072468719e117e948840.tar.gz
opencode-c875a1fc900f044874b2072468719e117e948840.zip
test(app): fix e2e test action
-rw-r--r--packages/app/e2e/actions.ts47
1 files changed, 44 insertions, 3 deletions
diff --git a/packages/app/e2e/actions.ts b/packages/app/e2e/actions.ts
index ebcc9effd..3467effa6 100644
--- a/packages/app/e2e/actions.ts
+++ b/packages/app/e2e/actions.ts
@@ -21,7 +21,12 @@ import {
import type { createSdk } from "./utils"
export async function defocus(page: Page) {
- await page.mouse.click(5, 5)
+ await page
+ .evaluate(() => {
+ const el = document.activeElement
+ if (el instanceof HTMLElement) el.blur()
+ })
+ .catch(() => undefined)
}
export async function openPalette(page: Page) {
@@ -68,14 +73,50 @@ export async function toggleSidebar(page: Page) {
export async function openSidebar(page: Page) {
if (!(await isSidebarClosed(page))) return
+
+ const button = page.getByRole("button", { name: /toggle sidebar/i }).first()
+ const visible = await button
+ .isVisible()
+ .then((x) => x)
+ .catch(() => false)
+
+ if (visible) await button.click()
+ if (!visible) await toggleSidebar(page)
+
+ const main = page.locator("main")
+ const opened = await expect(main)
+ .not.toHaveClass(/xl:border-l/, { timeout: 1500 })
+ .then(() => true)
+ .catch(() => false)
+
+ if (opened) return
+
await toggleSidebar(page)
- await expect(page.locator("main")).not.toHaveClass(/xl:border-l/)
+ await expect(main).not.toHaveClass(/xl:border-l/)
}
export async function closeSidebar(page: Page) {
if (await isSidebarClosed(page)) return
+
+ const button = page.getByRole("button", { name: /toggle sidebar/i }).first()
+ const visible = await button
+ .isVisible()
+ .then((x) => x)
+ .catch(() => false)
+
+ if (visible) await button.click()
+ if (!visible) await toggleSidebar(page)
+
+ const main = page.locator("main")
+ const closed = await expect(main)
+ .toHaveClass(/xl:border-l/, { timeout: 1500 })
+ .then(() => true)
+ .catch(() => false)
+
+ if (closed) return
+
await toggleSidebar(page)
- await expect(page.locator("main")).toHaveClass(/xl:border-l/)
+ await expect(main).toHaveClass(/xl:border-l/)
}
export async function openSettings(page: Page) {