import { test, expect } from '@playwright/test'; import { LoginPage } from '../../novalon-manage-web/e2e/pages/LoginPage'; test.describe('UAT - 系统导航和菜单', () => { let loginPage: LoginPage; test.beforeEach(async ({ page }) => { loginPage = new LoginPage(page); await loginPage.goto(); }); test('Dashboard页面可访问', async ({ page }) => { await loginPage.login('admin', 'admin123'); await page.waitForLoadState('networkidle'); await page.goto('http://localhost:3003/dashboard'); await page.waitForLoadState('networkidle'); const currentUrl = page.url(); console.log('当前URL:', currentUrl); expect(currentUrl).toContain('/dashboard'); }); test('主要菜单项可访问', async ({ page }) => { await loginPage.login('admin', 'admin123'); await page.waitForLoadState('networkidle'); const menuItems = [ { path: '/users', name: '用户管理' }, { path: '/roles', name: '角色管理' }, { path: '/menus', name: '菜单管理' }, { path: '/sys/config', name: '系统配置' }, { path: '/dict', name: '字典管理' } ]; for (const item of menuItems) { console.log(`测试菜单: ${item.name}`); await page.goto(`http://localhost:3003${item.path}`); await page.waitForLoadState('networkidle'); const currentUrl = page.url(); expect(currentUrl).toContain(item.path); const pageTitle = await page.title(); console.log(` 页面标题: ${pageTitle}`); expect(pageTitle).toBeTruthy(); } }); test('侧边栏导航功能', async ({ page }) => { await loginPage.login('admin', 'admin123'); await page.waitForLoadState('networkidle'); const sidebar = page.locator('.el-aside, .sidebar, [class*="sidebar"]'); const sidebarVisible = await sidebar.count() > 0; console.log('侧边栏存在:', sidebarVisible); if (sidebarVisible) { const menuItems = sidebar.locator('a, .el-menu-item'); const itemCount = await menuItems.count(); console.log('菜单项数量:', itemCount); expect(itemCount).toBeGreaterThan(0); } }); });