增加 后端,后台管理系统,uniapp会员端的自动化测试。

This commit is contained in:
2026-07-21 18:09:29 +08:00
parent df0e68469b
commit 6b60b3b4da
64 changed files with 13095 additions and 376 deletions
+28 -10
View File
@@ -7,7 +7,7 @@ test.describe('基础UI功能测试', () => {
await page.goto('/');
await page.waitForLoadState('networkidle');
// 验证页面标题
// 验证页面标题(无论是否重定向,标题都包含 Novalon)
const title = await page.title();
expect(title).toContain('Novalon');
});
@@ -17,19 +17,37 @@ test.describe('基础UI功能测试', () => {
await page.goto('/login');
await page.waitForLoadState('networkidle');
// 验证登录表单元素
await expect(page.locator('input[type="text"]')).toBeVisible();
await expect(page.locator('input[type="password"]')).toBeVisible();
await expect(page.locator('button:has-text("登录")')).toBeVisible();
// 验证登录表单元素 - 使用更宽松的选择器
const usernameField = page.locator('input[type="text"], input[placeholder*="用户名"], input[placeholder*="账号"]');
const passwordField = page.locator('input[type="password"]');
const loginButton = page.locator('button:has-text("登录")');
// 登录页面至少应该有输入框和按钮
await expect(usernameField.first()).toBeVisible({ timeout: 10000 });
await expect(passwordField.first()).toBeVisible({ timeout: 10000 });
await expect(loginButton.first()).toBeVisible({ timeout: 10000 });
});
// 测试3: 页面导航
await test.step('验证页面导航功能', async () => {
// 检查页面是否有基本的导航元素 - 使用更灵活的选择器
// 测试3: 登录后页面导航
await test.step('登录后验证导航功能', async () => {
// 填写登录表单并提交
const usernameInput = page.locator('input[type="text"], input[placeholder*="用户名"], input[placeholder*="账号"]').first();
const passwordInput = page.locator('input[type="password"]').first();
const loginButton = page.locator('button:has-text("登录")').first();
await usernameInput.fill('admin');
await passwordInput.fill('Test@123');
await loginButton.click();
// 等待跳转到 Dashboard
await page.waitForURL('**/dashboard', { timeout: 30000 });
await page.waitForLoadState('networkidle');
// 登录后检查导航元素
const navigationSelectors = [
'nav', '.navbar', '.menu', '.el-menu', '.el-header',
'.layout-header', '.app-header', '[class*="header"]',
'[class*="nav"]', '[class*="menu"]'
'[class*="nav"]', '[class*="menu"]', '.sidebar', '.aside'
];
let hasNavigation = false;
@@ -63,7 +81,7 @@ test.describe('基础UI功能测试', () => {
});
test('应用静态资源加载', async ({ page }) => {
await page.goto('/');
await page.goto('/login');
// 验证CSS加载
const cssLoaded = await page.evaluate(() => {