- 表单下拉框不再用 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,避免变成侧栏触发器文本
43 lines
1.8 KiB
TypeScript
43 lines
1.8 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
import { authenticate, mockHermesApi, TEST_ACCESS_KEY } from './fixtures'
|
|
|
|
test('fetches custom provider models through the backend proxy', async ({ page }) => {
|
|
await authenticate(page, TEST_ACCESS_KEY)
|
|
const api = await mockHermesApi(page)
|
|
|
|
const thirdPartyRequests: string[] = []
|
|
page.on('request', (request) => {
|
|
const url = request.url()
|
|
if (url.startsWith('https://provider.example.test')) {
|
|
thirdPartyRequests.push(url)
|
|
}
|
|
})
|
|
|
|
await page.goto('/#/hermes/models')
|
|
|
|
await page.getByRole('button', { name: 'Add Provider' }).click()
|
|
await page.getByRole('button', { name: 'Custom' }).click()
|
|
await page.getByPlaceholder('e.g. https://api.example.com/v1').fill('https://provider.example.test/v1')
|
|
await page.getByPlaceholder('sk-...').fill('test-provider-key')
|
|
await page.getByRole('button', { name: 'Fetch', exact: true }).click()
|
|
|
|
await expect(page.getByText('Found 2 models')).toBeVisible()
|
|
// Scope to the dropdown options: Arco renders both the select's current value
|
|
// and the option list, so a bare text match resolves to two nodes. The option
|
|
// list is collapsed by this point, so assert presence rather than visibility.
|
|
await expect(
|
|
page.locator('.arco-select-option-content', { hasText: 'proxy-model-a' }),
|
|
).toHaveCount(1)
|
|
|
|
const proxyRequest = api.requests.find((request) => request.pathname === '/api/hermes/provider-models')
|
|
expect(proxyRequest).toBeTruthy()
|
|
expect(proxyRequest?.method).toBe('POST')
|
|
expect(proxyRequest?.headers.authorization).toBe(`Bearer ${TEST_ACCESS_KEY}`)
|
|
expect(JSON.parse(proxyRequest?.postData || '{}')).toMatchObject({
|
|
base_url: 'https://provider.example.test/v1',
|
|
api_key: 'test-provider-key',
|
|
})
|
|
expect(thirdPartyRequests).toEqual([])
|
|
expect(api.unexpectedRequests).toEqual([])
|
|
})
|