v0.2.0: CRM/ERP 系统升级 - 清理 .gitignore 并移除误提交的 venv/env/db 文件

- 更新 .gitignore:全面覆盖环境变量、数据库、日志、缓存、上传文件
- 移除误跟踪的 server/venv/、crm_data.db、.env 文件
- 新增 server/.env.example 模板
- 新增合同管理、利润核算、AI教练等功能模块
- 新增 Playwright e2e 测试套件
- 前后端多项功能升级和 bug 修复
This commit is contained in:
hankin
2026-05-11 07:24:19 +00:00
parent 0f4c6b7924
commit 815cbf9d8c
2526 changed files with 11875 additions and 804148 deletions
+68
View File
@@ -0,0 +1,68 @@
/**
* 登录页面测试
* 覆盖: 页面渲染 / 正确登录 / 错误密码 / 空字段校验 / 跳转
*/
import { test, expect } from '@playwright/test';
// 登录测试不使用全局 auth,独立登录
test.use({ storageState: { cookies: [], origins: [] } });
test.describe('登录页面', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/login');
});
test('页面正确渲染', async ({ page }) => {
// 标题
await expect(page.locator('.login-title')).toContainText('天津硕博霖 CRM 系统');
await expect(page.locator('.login-subtitle')).toContainText('v2.0');
// 表单元素
await expect(page.getByPlaceholder('用户名')).toBeVisible();
await expect(page.getByPlaceholder('密码')).toBeVisible();
await expect(page.getByRole('button', { name: '登 录' })).toBeVisible();
});
test('正确账密登录后跳转工作台', async ({ page }) => {
await page.getByPlaceholder('用户名').fill('admin');
await page.getByPlaceholder('密码').fill('123456');
await page.getByRole('button', { name: '登 录' }).click();
// 等待跳转到首页
await page.waitForURL('/', { timeout: 10000 });
// 侧边栏菜单应出现
await expect(page.locator('.el-menu--vertical').first()).toBeVisible({ timeout: 5000 });
});
test('错误密码弹出错误提示', async ({ page }) => {
await page.getByPlaceholder('用户名').fill('admin');
await page.getByPlaceholder('密码').fill('wrong123');
await page.getByRole('button', { name: '登 录' }).click();
// Element Plus 的 ElMessage 错误提示
await expect(page.locator('.el-message--error')).toBeVisible({ timeout: 5000 });
});
test('空字段显示校验提示', async ({ page }) => {
// 直接点登录
await page.getByRole('button', { name: '登 录' }).click();
// el-form 校验提示
await expect(page.locator('.el-form-item__error')).toHaveCount(2);
await expect(page.locator('.el-form-item__error').first()).toContainText('请输入用户名');
});
test('密码少于6位提示校验', async ({ page }) => {
await page.getByPlaceholder('用户名').fill('admin');
await page.getByPlaceholder('密码').fill('123');
await page.getByRole('button', { name: '登 录' }).click();
await expect(page.locator('.el-form-item__error')).toContainText('密码至少 6 位');
});
test('未登录访问首页被重定向到登录页', async ({ page }) => {
await page.goto('/');
await page.waitForURL(/\/login/);
await expect(page.locator('.login-title')).toBeVisible();
});
});