import { test, expect } from './test-fixtures'; test.describe('菜单管理 - 完全Mock模式', () => { test.beforeEach(async ({ page, mockManager }) => { mockManager.enableMock(); mockManager.configureMock({ mode: 'full', delay: 100 }); mockManager.presetTestData({ menus: [ { id: 1, name: '系统管理', code: 'system', path: '/system', icon: 'SettingOutlined', parentId: 0, sortOrder: 1, status: 'ENABLED', component: '', redirect: '', description: '系统管理模块', children: [], createdAt: '2024-01-01T10:00:00.000Z', updatedAt: '2024-01-01T10:00:00.000Z' }, { id: 2, name: '用户管理', code: 'user', path: '/system/user', icon: 'UserOutlined', parentId: 1, sortOrder: 1, status: 'ENABLED', component: 'views/UserManagement.vue', redirect: '', description: '用户管理页面', children: [], createdAt: '2024-01-01T10:00:00.000Z', updatedAt: '2024-01-01T10:00:00.000Z' }, { id: 3, name: '角色管理', code: 'role', path: '/system/role', icon: 'TeamOutlined', parentId: 1, sortOrder: 2, status: 'ENABLED', component: 'views/RoleManagement.vue', redirect: '', description: '角色管理页面', children: [], createdAt: '2024-01-01T10:00:00.000Z', updatedAt: '2024-01-01T10:00:00.000Z' }, { id: 4, name: '菜单管理', code: 'menu', path: '/system/menu', icon: 'MenuOutlined', parentId: 1, sortOrder: 3, status: 'ENABLED', component: 'views/MenuManagement.vue', redirect: '', description: '菜单管理页面', children: [], createdAt: '2024-01-01T10:00:00.000Z', updatedAt: '2024-01-01T10:00:00.000Z' } ] }); 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('/menus'); await page.waitForLoadState('networkidle'); await expect(page.locator('.ant-table')).toBeVisible(); await expect(page.locator('text=系统管理')).toBeVisible(); await expect(page.locator('text=用户管理')).toBeVisible(); await expect(page.locator('text=角色管理')).toBeVisible(); await expect(page.locator('text=菜单管理')).toBeVisible(); }); test('应该能够创建新菜单', async ({ page }) => { await page.goto('/menus'); await page.waitForLoadState('networkidle'); await page.click('button:has-text("新增菜单")'); await page.fill('input[placeholder="请输入菜单名称"]', '测试菜单'); await page.fill('input[placeholder="请输入菜单标识"]', 'test_menu'); await page.fill('input[placeholder="请输入路由路径"]', '/test/menu'); await page.fill('input[placeholder="请输入组件路径"]', 'views/TestMenu.vue'); await page.click('button:has-text("确定")'); await expect(page.locator('text=创建成功')).toBeVisible(); }); test('应该能够编辑菜单', async ({ page }) => { await page.goto('/menus'); await page.waitForLoadState('networkidle'); await page.click('button:has-text("编辑"):first'); await page.fill('input[placeholder="请输入菜单名称"]', '更新后的菜单名称'); await page.click('button:has-text("确定")'); await expect(page.locator('text=更新成功')).toBeVisible(); }); test('应该能够删除菜单', async ({ page }) => { await page.goto('/menus'); await page.waitForLoadState('networkidle'); page.on('dialog', dialog => dialog.accept()); await page.click('button:has-text("删除"):first'); await expect(page.locator('text=删除成功')).toBeVisible(); }); });