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
+49
View File
@@ -0,0 +1,49 @@
"""
公司管理测试 —— /api/companies
覆盖: 公司列表 / 当前公司详情 / 更新公司信息 / 权限
"""
import pytest
from httpx import AsyncClient
from tests.conftest import COMPANY_ID
class TestCompanyList:
"""GET /api/companies"""
async def test_list_companies(self, client: AsyncClient, admin_headers):
"""管理员获取公司列表 → 200"""
resp = await client.get("/api/companies", headers=admin_headers)
assert resp.status_code == 200
data = resp.json()["data"]
assert "companies" in data
assert len(data["companies"]) >= 1
assert data["companies"][0]["code"] == "TEST-CO"
class TestCurrentCompany:
"""GET /api/companies/current"""
async def test_get_current_company(self, client: AsyncClient, admin_headers):
"""获取当前公司详情 → 200"""
resp = await client.get("/api/companies/current", headers=admin_headers)
assert resp.status_code == 200
data = resp.json()["data"]
assert data["name"] == "测试润滑油有限公司"
class TestUpdateCompany:
"""PUT /api/companies/current"""
async def test_admin_update_company(self, client: AsyncClient, admin_headers):
"""管理员更新公司信息 → 200"""
resp = await client.put("/api/companies/current", headers=admin_headers, json={
"full_info": {"full_name": "天津测试润滑油有限公司-改", "tax_id": "91120000XXXX"}
})
assert resp.status_code == 200
async def test_sales_update_company_forbidden(self, client: AsyncClient, sales_headers):
"""普通销售更新公司 → 403"""
resp = await client.put("/api/companies/current", headers=sales_headers, json={
"full_info": {"full_name": "hack"}
})
assert resp.status_code == 403