import { test, expect } from '@playwright/test'; import { MockManager } from './mock-manager'; test.describe('仪表盘', () => { test.beforeEach(async ({ page }) => { const mockManager = new MockManager({ enabled: true, mode: 'full', mockPaths: [], delay: 0, logCalls: true, validateResponses: true, dataSource: 'memory' }); mockManager.presetTestData({ operationLogs: [ { id: 1, username: 'admin', action: '登录', content: '用户登录系统', ip: '192.168.1.100', status: 'success', createTime: '2024-01-15 10:30:00' }, { id: 2, username: 'admin', action: '创建', content: '创建用户 testuser', ip: '192.168.1.100', status: 'success', createTime: '2024-01-15 10:25:00' }, { id: 3, username: 'admin', action: '更新', content: '更新角色权限', ip: '192.168.1.100', status: 'success', createTime: '2024-01-15 10:20:00' }, { id: 4, username: 'testuser', action: '登录', content: '用户登录系统', ip: '192.168.1.101', status: 'success', createTime: '2024-01-15 10:15:00' }, { id: 5, username: 'admin', action: '删除', content: '删除菜单项', ip: '192.168.1.100', status: 'success', createTime: '2024-01-15 10:10:00' } ] }); await mockManager.interceptAPIRequest(page); await page.goto('/login'); await page.getByPlaceholder(/用户名/).fill('admin'); await page.getByPlaceholder(/密码/).fill('admin123'); await page.getByRole('button', { name: /登录/ }).click(); await page.waitForTimeout(3000); }); test('应该显示仪表盘页面', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); test('应该显示统计卡片', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); test('应该显示用户增长趋势图表', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); test('应该显示系统访问统计图表', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); test('应该显示最近操作日志表格', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); test('统计数据应该正确显示', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); test('操作日志应该正确显示', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); test('操作日志应该显示正确的状态标签', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); test('操作日志应该显示正确的操作类型标签', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); test('统计卡片应该显示正确的图标', async ({ page }) => { await page.waitForLoadState('networkidle'); await page.waitForTimeout(2000); }); });