45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
import { uiLogin, apiLogin } from '../utils/auth'
|
|
import { getDashboardViaApi } from '../utils/api-helpers'
|
|
|
|
test.describe('工作台 Dashboard', () => {
|
|
let apiToken = ''
|
|
|
|
test.beforeEach(async ({ request }) => {
|
|
apiToken = (await apiLogin(request)).accessToken
|
|
})
|
|
|
|
test('登录后工作台显示统计与图表', async ({ page }) => {
|
|
await uiLogin(page)
|
|
await page.goto('/dashboard')
|
|
await expect(page.getByText('工作台概览')).toBeVisible()
|
|
|
|
await expect(page.getByText('Agent 快捷指令')).toBeVisible()
|
|
await expect(page.getByText('指摘处理趋势')).toBeVisible()
|
|
await expect(page.getByText('Agent 洞察')).toBeVisible()
|
|
await expect(page.getByText('最新动态')).toBeVisible()
|
|
await expect(page.getByText('指摘状态分布')).toBeVisible()
|
|
})
|
|
|
|
test('统计卡显示正确的数量(API 对比)', async ({ page, request }) => {
|
|
const stats = await getDashboardViaApi(request, apiToken)
|
|
await uiLogin(page)
|
|
await page.goto('/dashboard')
|
|
|
|
const pending = page.locator('.ant-statistic', { hasText: '待处理指摘' }).first()
|
|
await expect(pending.getByText('待处理指摘', { exact: true })).toBeVisible()
|
|
await expect(pending.getByText(String(stats.pendingCount))).toBeVisible()
|
|
|
|
await expect(page.locator('.ant-statistic', { hasText: '进行中指摘' }).first()).toBeVisible()
|
|
await expect(page.locator('.ant-statistic', { hasText: '本月已完成' }).first()).toBeVisible()
|
|
})
|
|
|
|
test('Agent 快捷指令输入框存在且可输入', async ({ page }) => {
|
|
await uiLogin(page)
|
|
await page.goto('/dashboard')
|
|
const input = page.getByPlaceholder(/例如:查找知识库/)
|
|
await input.fill('测试指令')
|
|
await expect(input).toHaveValue('测试指令')
|
|
})
|
|
})
|