46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
import { uiLogin } from '../utils/auth'
|
|
import { createIssueViaApi, deleteIssueViaApi } from '../utils/api-helpers'
|
|
|
|
test.describe('Agent 驾驶舱', () => {
|
|
let apiToken = ''
|
|
let issueId = 0
|
|
|
|
test.beforeEach(async ({ page, request }) => {
|
|
const created = await createIssueViaApi(request)
|
|
issueId = created.issue.id
|
|
apiToken = created.token
|
|
await uiLogin(page)
|
|
})
|
|
|
|
test.afterEach(async ({ request }) => {
|
|
if (issueId) {
|
|
await deleteIssueViaApi(request, issueId, apiToken).catch(() => {})
|
|
}
|
|
})
|
|
|
|
test('执行指令后显示工具卡片', async ({ page }) => {
|
|
test.setTimeout(560000)
|
|
await page.goto(`/issues/${issueId}`)
|
|
await expect(page.getByText('IMS Agent 驾驶舱')).toBeVisible()
|
|
|
|
await page.getByPlaceholder(/给 Agent 下达指令/).fill('查找知识库相似案例并生成对应方案')
|
|
await page.getByRole('button', { name: /执行指令/i }).click()
|
|
|
|
// 模型输出工具调用后 SSE 渲染工具卡片(真实模型可能只输出 search_knowledge,不强依赖具体工具)
|
|
await expect(page.getByText(/call:/).first()).toBeVisible({ timeout: 480000 })
|
|
})
|
|
|
|
test('写工具触发审批后可批准', async ({ page }) => {
|
|
test.setTimeout(480000)
|
|
await page.goto(`/issues/${issueId}`)
|
|
await page.getByPlaceholder(/给 Agent 下达指令/).fill('请调用 update_issue 工具,把本指摘的优先级改为 high')
|
|
await page.getByRole('button', { name: /执行指令/i }).click()
|
|
|
|
await expect(page.getByText('需要您的审批')).toBeVisible({ timeout: 420000 })
|
|
await page.getByRole('button', { name: /批准执行/i }).click()
|
|
await expect(page.getByText('已批准执行')).toBeVisible({ timeout: 30000 })
|
|
await expect(page.getByText(/Agent 指令已批准/)).toBeVisible({ timeout: 30000 })
|
|
})
|
|
})
|