import { test, expect } from '@playwright/test'; import { LoginPage } from '../pages/LoginPage'; import { DashboardPage } from '../pages/DashboardPage'; import { MenuManagementPage } from '../pages/MenuManagementPage'; test.describe('User Journey: 菜单管理全链路', () => { test.describe.configure({ mode: 'serial' }); const timestamp = Date.now(); const menuName = `E2E菜单_${timestamp}`; test('UJ-03: 菜单创建→编辑→删除', async ({ page }) => { const loginPage = new LoginPage(page); const menuPage = new MenuManagementPage(page); await test.step('登录', async () => { await loginPage.goto(); await loginPage.login('admin', 'Test@123'); }); await test.step('导航到菜单管理', async () => { await menuPage.goto(); }); await test.step('创建新菜单', async () => { await menuPage.clickCreateMenu(); await menuPage.fillMenuForm({ name: menuName, type: 'menu', path: `/e2e-test-${timestamp}`, icon: 'file', component: `e2e/Test_${timestamp}`, permission: `e2e:test_${timestamp}`, sort: 99, status: 'ACTIVE', visible: true, }); await menuPage.submitForm(); const success = await menuPage.containsText(menuName); expect(success).toBe(true); }); await test.step('编辑菜单', async () => { await menuPage.editMenu(menuName); const modal = page.locator('.ant-modal').filter({ hasText: /编辑菜单/ }); const nameInput = modal.locator('.ant-form-item').filter({ hasText: '菜单名称' }).locator('input'); await nameInput.clear(); await nameInput.fill(`${menuName}_已编辑`); await menuPage.submitForm(); }); await test.step('删除菜单', async () => { await menuPage.goto(); await menuPage.deleteMenu(`${menuName}_已编辑`); await menuPage.confirmDelete(); }); }); });