mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-02 17:30:58 +00:00
28 lines
1.4 KiB
TypeScript
28 lines
1.4 KiB
TypeScript
import { expect, type Page } from "@playwright/test"
|
|
import { SERVER } from "./app"
|
|
|
|
export async function openWithDirection(page: Page, route: string, direction: "ltr" | "rtl") {
|
|
await page.goto(`/e2e/utils/app-direction.html?${new URLSearchParams({ server: SERVER, route, direction })}`)
|
|
}
|
|
|
|
/**
|
|
* Opens the app at a route as the desktop shell starts it: the window's plugins run at once, and the app interface
|
|
* mounts over the preloaded route only when `start` runs, as it does once the desktop's server is up. One plugin
|
|
* stays loading until `finish` runs; commands are published meanwhile, but the routes wait.
|
|
*/
|
|
export async function openHeldStart(page: Page, route: string) {
|
|
await page.goto(
|
|
`/e2e/utils/app-direction.html?${new URLSearchParams({ server: SERVER, route, direction: "ltr", held: "" })}`,
|
|
)
|
|
const start = page.getByRole("button", { name: "Start app", exact: true, includeHidden: true })
|
|
await expect(start).toBeVisible()
|
|
|
|
return {
|
|
// A modal open meanwhile hides the page outside it, so the button is found and clicked past the modal.
|
|
start: async () => {
|
|
await start.dispatchEvent("click")
|
|
await expect(page.getByRole("button", { name: "Finish startup", exact: true, includeHidden: true })).toBeEnabled()
|
|
},
|
|
finish: () => page.getByRole("button", { name: "Finish startup", exact: true, includeHidden: true }).dispatchEvent("click"),
|
|
}
|
|
}
|