Files
lisglosips/docs/TEST_RESULTS_STEP1_BASELINE_20260628.md
T

185 lines
5.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 第 1 步测试结果:本地静态与自动化基线
执行时间:2026-06-28 18:44:25 +08:00
执行范围:
- ESLint 静态检查
- TypeScript 项目引用类型检查
- 全量 Vitest
- Monorepo 构建
- Prisma schema 校验
## 1. 结果总览
| 检查项 | 命令 | 结果 |
| --- | --- | --- |
| Lint | `corepack pnpm@10.33.0 lint` | 通过 |
| Typecheck | `corepack pnpm@10.33.0 typecheck` | 通过 |
| Test | `corepack pnpm@10.33.0 test` | 未通过 |
| Build | `corepack pnpm@10.33.0 build` | 通过 |
| Prisma validate | `corepack pnpm@10.33.0 prisma:validate` | 通过 |
整体结论:首次执行第 1 步基线未完全通过,阻断项为全量 Vitest 中 7 个 API e2e suite 的 `beforeAll` hook 默认 10 秒超时。其余静态检查、类型检查、构建和 Prisma schema 校验均通过。
复测结论:已在 `vitest.config.ts` 显式设置 `hookTimeout: 60000`,随后重新执行裸 `corepack pnpm@10.33.0 test`,25 个测试文件、88 个测试用例全部通过。该结果说明首次失败是全 AppModule e2e 初始化超过默认 hook timeout 导致,不是业务断言失败。
## 2. 详细结果
### 2.1 Lint
命令:
```powershell
corepack pnpm@10.33.0 lint
```
结果:通过。
摘要:
- 执行 `eslint .`
- 未发现 ESLint 报错。
### 2.2 Typecheck
命令:
```powershell
corepack pnpm@10.33.0 typecheck
```
结果:通过。
摘要:
- 执行 `tsc -b tsconfig.build.json --pretty`
- TypeScript 项目引用检查通过。
### 2.3 Test
命令:
```powershell
corepack pnpm@10.33.0 test
```
结果:未通过。
Vitest 汇总:
- Test Files7 failed18 passed,共 25。
- Tests68 passed20 skipped,共 88。
- Duration45.57s。
失败原因:
7 个 API e2e suite 在 `beforeAll` 阶段触发默认 10000ms hook timeout
| 失败文件 | 失败位置 | 摘要 |
| --- | --- | --- |
| `apps/api/src/app.e2e.spec.ts` | `beforeAll` line 10 | API health e2e 初始化超时 |
| `apps/api/src/modules/auth/auth.e2e.spec.ts` | `beforeAll` line 85 | Auth API e2e 初始化超时 |
| `apps/api/src/modules/customers/customers.e2e.spec.ts` | `beforeAll` line 161 | Customers API e2e 初始化超时 |
| `apps/api/src/modules/landing-line-groups/landing-line-groups.e2e.spec.ts` | `beforeAll` line 228 | Landing line groups API e2e 初始化超时 |
| `apps/api/src/modules/recharges/recharges.e2e.spec.ts` | `beforeAll` line 124 | Recharges API e2e 初始化超时 |
| `apps/api/src/modules/security/security-rbac-audit.e2e.spec.ts` | `beforeAll` line 172 | Security/RBAC/Audit API e2e 初始化超时 |
| `apps/api/src/modules/vendor-gateways/vendor-gateways.e2e.spec.ts` | `beforeAll` line 184 | Vendor gateways API e2e 初始化超时 |
已通过的测试文件包括:
- `apps/api/src/modules/active-calls/active-calls.service.spec.ts`
- `apps/api/src/modules/auth/auth.service.spec.ts`
- `apps/worker-recording/src/transfer.spec.ts`
- `packages/auth/src/index.spec.ts`
- `apps/api/src/modules/customer-gateway-policies/customer-gateway-policies.e2e.spec.ts`
- `apps/api/src/modules/customer-gateways/customer-gateways.e2e.spec.ts`
- `apps/api/src/modules/vendors/vendors.e2e.spec.ts`
- `apps/api/src/modules/users-roles-delete.e2e.spec.ts`
- `apps/api/src/modules/number-library/number-library.e2e.spec.ts`
- `apps/worker-cdr/src/rating.spec.ts`
- `packages/database/src/schema-contract.spec.ts`
- `apps/api/src/modules/dashboard/dashboard.service.spec.ts`
- `packages/redis/src/cdr-stream.spec.ts`
- `apps/api/src/modules/cdrs/cdrs.service.spec.ts`
- `apps/worker-config-publisher/src/publisher.spec.ts`
- `apps/api/src/modules/recordings/recordings.service.spec.ts`
- `apps/api/src/modules/quality/sampling.spec.ts`
- `apps/api/src/modules/health/health.service.spec.ts`
初步判断:
- 失败集中在 API e2e `beforeAll` 初始化阶段,错误均为默认 10 秒 hook timeout。
- 结合历史执行记录,本项目 e2e 曾使用 `--hookTimeout=60000 --maxWorkers=1` 通过;本次按第 1 步基线命令执行裸 `pnpm test`,因此更可能是本地 e2e 初始化耗时或并发资源争用导致的基线命令超时,而不是业务断言失败。
- 仍需在下一轮复测中用扩展 hook timeout 和单 worker 复跑,确认是否存在真实数据库/Redis/API 初始化问题。
### 2.4 Build
命令:
```powershell
corepack pnpm@10.33.0 build
```
结果:通过。
摘要:
- `packages/auth``packages/contracts``packages/database``packages/domain``packages/observability``packages/redis` 构建通过。
- `apps/api``apps/worker-cdr``apps/worker-config-publisher``apps/worker-recording` 构建通过。
- `apps/web` Vite 构建通过,生成产物:
- `dist/index.html`
- `dist/assets/index-B2uYBtS3.css`
- `dist/assets/index-BK00zN_M.js`
### 2.5 Prisma Validate
命令:
```powershell
corepack pnpm@10.33.0 prisma:validate
```
结果:通过。
摘要:
- Prisma config`prisma.config.ts`
- Schema`prisma/schema.prisma`
- 结果:schema valid。
## 3. 当前风险
- 首次 `pnpm test` 失败集中在 e2e 初始化超时,不应直接按业务缺陷处理。
- 已通过配置层修复验证:`vitest.config.ts` 增加 `hookTimeout: 60000` 后,`pnpm test` 通过。
- 若后续在低性能 CI 或数据库连接较慢环境中再次出现初始化超时,可再考虑降低 e2e 并发,例如使用 `--maxWorkers=1`
## 4. 复测记录
执行时间:2026-06-28 18:53:16 +08:00
变更:
```typescript
// vitest.config.ts
hookTimeout: 60000
```
复测命令:
```powershell
corepack pnpm@10.33.0 test
```
复测结果:
- Test Files25 passed,共 25。
- Tests88 passed,共 88。
- Duration12.56s。
## 5. 建议下一步
1. 保留 `vitest.config.ts` 中的 `hookTimeout: 60000`
2. 如要继续第 1 步完整闭环,可再次执行 `lint``typecheck``test``build``prisma:validate` 全套命令并更新最终状态。
3. 进入第 2 步定向单元/API e2e 回归时,可直接使用当前 Vitest 配置。