import { test, expect } from '@playwright/test' import { uiLogin } from '../utils/auth' test.describe('新建页 Agent 智能填充', () => { test('点击「让 Agent 智能填充」真实调用 AI 并回填字段', async ({ page }) => { test.setTimeout(420000) await uiLogin(page) await page.goto('/issues/new') await page.getByPlaceholder('请输入指摘标题').fill('登录页面在低分辨率下按钮错位、样式异常,影响操作') const fillBtn = page.getByRole('button', { name: /让 Agent 智能填充/i }) await fillBtn.click() await expect(fillBtn).toHaveClass(/ant-btn-loading/, { timeout: 15000 }) // 模型调用耗时波动大(数十秒到数分钟),axios 侧 180s 超时后走降级回填,故等待上限放宽到 240s await expect(fillBtn).not.toHaveClass(/ant-btn-loading/, { timeout: 240000 }) // 工程阶段/区分/影响度三个 Select 至少被回填 3 个非"请选择"值(AI 成功或降级都会回填) await expect.poll(async () => { return page.locator('.ant-select').evaluateAll(els => els.filter(e => { const t = e.textContent?.trim() ?? '' return t !== '' && t !== '请选择' }).length) }, { timeout: 30000, intervals: [2000] }).toBeGreaterThanOrEqual(3) // 优先级 Radio 也被回填(高/中/低 任一) const checked = (await page.locator('.ant-radio-button-wrapper-checked').allTextContents()).map(s => s.trim()).filter(Boolean) expect(checked.length).toBeGreaterThan(0) console.log('filled selects:', JSON.stringify(checked)) }) })