mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 05:01:03 +03:00
26 lines
935 B
TypeScript
26 lines
935 B
TypeScript
import { expect, type Locator, type Page } from "@playwright/test"
|
|
import { sessionHref } from "./app"
|
|
|
|
export const APP_READY_TIMEOUT = 30_000
|
|
|
|
export async function expectAppVisible(locator: Locator) {
|
|
await expect(locator).toBeVisible({ timeout: APP_READY_TIMEOUT })
|
|
}
|
|
|
|
export async function expectSessionTitle(page: Page, title: string) {
|
|
if ((page.viewportSize()?.width ?? 1280) < 768) {
|
|
const trigger = page.locator('[data-slot="mobile-tabs-trigger"]')
|
|
await expectAppVisible(trigger)
|
|
await expect(trigger.locator('span[dir="auto"]')).toHaveText(title, { timeout: APP_READY_TIMEOUT })
|
|
|
|
return
|
|
}
|
|
|
|
await expectAppVisible(page.getByRole("heading", { name: title }))
|
|
}
|
|
|
|
export async function expectSessionReady(page: Page, input: { server: string; sessionID: string; title: string }) {
|
|
await expect(page).toHaveURL(sessionHref(input.sessionID, input.server))
|
|
await expectSessionTitle(page, input.title)
|
|
}
|