import { test, expect } from './test-fixtures'; test.describe('用户管理 - 完全Mock模式', () => { test.beforeEach(async ({ page, mockManager }) => { mockManager.enableMock(); mockManager.configureMock({ mode: 'full', delay: 100 }); mockManager.presetTestData({ users: [ { id: 1, username: 'testuser1', email: 'test1@example.com', status: 1, createTime: '2024-01-01 10:00:00' }, { id: 2, username: 'testuser2', email: 'test2@example.com', status: 1, createTime: '2024-01-02 10:00:00' }, { id: 3, username: 'testuser3', email: 'test3@example.com', status: 0, createTime: '2024-01-03 10:00:00' } ] }); await page.goto('/'); await page.fill('input[placeholder="请输入用户名"]', 'admin'); await page.fill('input[placeholder="请输入密码"]', 'admin123'); await page.click('button[type="submit"]'); await page.waitForURL(/.*dashboard/, { timeout: 10000 }); }); test.afterEach(async ({ mockManager }) => { mockManager.clearPresets(); mockManager.disableMock(); }); test('应该显示用户列表', async ({ page }) => { await page.goto('/users'); await page.waitForLoadState('networkidle'); await expect(page.locator('.ant-table')).toBeVisible(); }); test('应该能够搜索用户', async ({ page }) => { await page.goto('/users'); await page.waitForLoadState('networkidle'); const searchInput = page.locator('input[placeholder*="搜索"]').first(); await searchInput.fill('testuser1'); const searchButton = page.locator('button').filter({ hasText: /搜索|查询/ }).first(); await searchButton.click(); await page.waitForTimeout(500); }); test('应该能够打开新增用户对话框', async ({ page }) => { await page.goto('/users'); await page.waitForLoadState('networkidle'); const addButton = page.locator('button').filter({ hasText: /新增|添加/ }).first(); await addButton.click(); await expect(page.locator('.ant-modal')).toBeVisible(); await expect(page.locator('.ant-modal').getByText('新增用户')).toBeVisible(); }); });