Files
hermes-ui/tests/e2e/chat-startup-recovery.spec.ts
T
toor 3ca960f388
Build / build (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s
优化页面交互并增强 Provider 配置能力
- 表单下拉框不再用 label 包裹,改为 div + aria-label,避免点击后
  下拉面板瞬间关闭
- Provider 卡片新增「从上游获取模型」和「修改」入口,支持编辑
  base URL、API Key 与 api_mode,凭据写入对应的环境变量
- 服务端抽出 provider-model-discovery 统一不同 api_mode 的模型发现,
  旧的 custom_providers 与新的 providers 字典结构都能正确更新
- Agent Bridge 改为后台启动,HTTP 接口在 Python 运行时就绪前即可用;
  worker 连接被拒时按类型重试,不重放可能已产生副作用的请求
- 断线重连后恢复 profiles、models 与会话列表,健康检查改为自调度
  的 setTimeout,离线时 2 秒后重试
- 批量删除确认文案改用 Popconfirm content,避免变成侧栏触发器文本
2026-10-22 14:29:48 +08:00

48 lines
2.3 KiB
TypeScript

import { expect, test } from '@playwright/test'
import { authenticate, mockChatSocket, mockHermesApi, TEST_ACCESS_KEY } from './fixtures'
const session = { id: 'restored-chat', profile: 'research', source: 'cli', title: 'Restored conversation', started_at: 1000, last_active: 1100, message_count: 2 }
for (const path of ['/hermes/chat', '/hermes/session/restored-chat?profile=research']) {
test(`recovers sessions and preserves the route after backend restart: ${path}`, async ({ page }) => {
await authenticate(page, TEST_ACCESS_KEY, 'research')
await mockHermesApi(page, { sessions: [session] })
await mockChatSocket(page)
let ready = false
let healthRequests = 0
await page.route(url => url.pathname === '/health', async route => {
healthRequests++
if (healthRequests === 1) await route.fulfill({ status: 503, json: { error: 'starting' } })
else {
ready = true
await route.fulfill({ json: { status: 'ok' } })
}
})
await page.route(url => url.pathname === '/api/hermes/sessions', async route => {
await route.fulfill(ready
? { json: { sessions: [session] } }
: { status: 503, json: { error: 'starting' } })
})
await page.goto(`/#${path}`)
await expect(page.locator('.session-item', { hasText: 'Restored conversation' })).toBeVisible({ timeout: 15000 })
expect(healthRequests).toBeGreaterThan(1)
if (path.includes('/session/')) await expect(page).toHaveURL(/session\/restored-chat/);
})
}
test('batch-delete text appears in its confirmation popup without leaking into the sidebar', async ({ page }) => {
await authenticate(page, TEST_ACCESS_KEY, 'research')
await mockHermesApi(page, { sessions: [session] })
await mockChatSocket(page)
await page.goto('/#/hermes/chat')
await page.getByTitle('Batch selection', { exact: true }).click()
await page.locator('.session-item-checkbox').first().click()
const confirmation = 'Delete 1 selected sessions?'
await expect(page.locator('.page-sidebar-top')).not.toContainText(confirmation)
await page.getByRole('button', { name: 'Delete', exact: true }).click()
const popup = page.locator('.arco-popconfirm')
await expect(popup).toBeVisible()
await expect(popup).toContainText(confirmation)
await expect(popup.getByRole('button', { name: /cancel/i })).toBeVisible()
})