Files

67 lines
2.7 KiB
TypeScript

import { expect, test } from '@playwright/test'
import { signIn } from './session'
import { sidebar } from './app'
test.describe('more', () => {
test.beforeEach(async ({ page }) => {
await signIn(page)
await page.setViewportSize({ width: 1440, height: 900 })
await page.goto('/chat')
await page.waitForLoadState('networkidle')
await sidebar(page)
await page.waitForTimeout(900)
// The group is closed by default — it is the least-used shelf in the column.
await page.getByRole('button', { name: 'More', exact: true }).first().click()
await page.waitForTimeout(400)
})
for (const [row, lands] of [
['Connectors', '/integrations'],
['Docs', '/docs'],
] as const) {
test(`${row} arrives at ${lands}`, async ({ page }) => {
await page.getByRole('button', { name: row, exact: true }).click()
await page.waitForURL(new RegExp(`${lands}$`), { timeout: 15_000 })
await expect(page.getByRole('heading', { level: 1 }).first()).toBeVisible()
})
}
test('Terminals opens Tabs in a tab of its own', async ({ page }) => {
// It leaves this window on purpose, so what is asserted is the address it
// asks for rather than a navigation — a reader who followed it in place
// would lose the project they were building to reach a shell.
await page.addInitScript(() => {
;(window as unknown as { asked?: string }).asked = undefined
window.open = ((url?: string | URL) => {
;(window as unknown as { asked?: string }).asked = String(url)
return null
}) as typeof window.open
})
await page.reload()
await page.waitForLoadState('networkidle')
await sidebar(page)
await page.waitForTimeout(900)
await page.getByRole('button', { name: 'More', exact: true }).first().click()
await page.waitForTimeout(400)
await page.getByRole('button', { name: 'Terminals', exact: true }).click()
expect(
await page.evaluate(() => (window as unknown as { asked?: string }).asked),
).toBe('https://tabs.hanzo.ai/app')
})
for (const pane of ['Skills', 'Usage'] as const) {
test(`${pane} opens Settings on that pane`, async ({ page }) => {
await page.getByRole('button', { name: pane, exact: true }).click()
// Settings opens OVER the room, so the address does not move and there is
// no heading to read: what says it arrived is Settings' own list marking
// the pane it is showing. Two rows carry the word — the sidebar's and
// Settings' — so the one asserted is the one that is CURRENT.
await expect(
page.locator(`[aria-current="true"]`).filter({ hasText: pane }).first(),
).toBeVisible({ timeout: 15_000 })
})
}
})