Răsfoiți Sursa

📝 docs(story): 修正006.001故事中的测试策略引用

- 更新测试位置引用:从 `__tests__` 改为 `tests/` 目录结构
- 修正测试命令:细化单元测试、集成测试和覆盖率检查
- 更新测试策略引用:指向最新的测试策略文档v2.8
- 添加测试结构验证步骤
- 更新项目结构信息和变更日志

🤖 Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 2 luni în urmă
părinte
comite
2207d8dce3

+ 131 - 0
docs/stories/006.001.create-core-module-and-update-config.story.md

@@ -0,0 +1,131 @@
+# Story 006.001: 创建 core-module 并更新配置
+
+## Status
+Draft
+
+## Story
+**As a** 开发者,
+**I want** 将现有的 `packages/core-module-mt` 复制为 `packages/core-module`,并更新所有配置以移除 "-mt" 后缀,
+**so that** 我们有一个非多租户版本的核心模块聚合包,用于统一导出和管理核心业务模块。
+
+## Acceptance Criteria
+1. [ ] packages/core-module 目录成功创建
+2. [ ] package.json 配置正确更新,名称和导出路径无误
+3. [ ] 所有模块目录重命名完成(移除 "-mt" 后缀)
+4. [ ] 类型定义和导出路径正确
+5. [ ] 现有测试通过,功能正常
+6. [ ] TypeScript 类型检查无错误
+
+## Tasks / Subtasks
+- [ ] 任务 1: 复制目录结构 (AC: 1)
+  - [ ] 执行 `cp -r packages/core-module-mt packages/core-module`
+  - [ ] 验证新目录创建成功
+- [ ] 任务 2: 更新 package.json 配置 (AC: 2)
+  - [ ] 将名称从 `@d8d/core-module-mt` 改为 `@d8d/core-module`
+  - [ ] 更新所有导出路径中的 `-mt` 后缀
+  - [ ] 更新 `main` 和 `types` 字段中的路径
+  - [ ] 更新 `files` 字段中的目录名称
+- [ ] 任务 3: 重命名模块目录 (AC: 3)
+  - [ ] `user-module-mt` → `user-module`
+  - [ ] `auth-module-mt` → `auth-module`
+  - [ ] `file-module-mt` → `file-module`
+  - [ ] `system-config-module-mt` → `system-config-module`
+- [ ] 任务 4: 检查并更新导出文件 (AC: 4)
+  - [ ] 检查各模块中的 `index.mt.ts` 文件,确保导出路径正确
+  - [ ] 根据需要重命名文件(如 `index.mt.ts` → `index.ts`)
+- [ ] 任务 5: 验证步骤 (AC: 5, 6)
+  - [ ] 运行 `pnpm typecheck` 检查类型错误
+  - [ ] 运行 `pnpm test:unit` 确保单元测试通过
+  - [ ] 运行 `pnpm test:integration` 确保集成测试通过
+  - [ ] 运行 `pnpm test:coverage` 检查覆盖率是否达标
+  - [ ] 检查 server package 能否正确导入
+  - [ ] 验证测试文件位于正确的 `tests/` 目录结构中
+
+## Dev Notes
+
+### 项目结构信息
+- **项目结构**: 采用 monorepo 模式,包含小程序(mini)、Web应用(web)和模块化包架构 [Source: architecture/source-tree.md#集成指南]
+- **包管理**: 使用 pnpm workspace 管理多包依赖关系 [Source: architecture/source-tree.md#集成指南]
+- **包架构层次**:
+  - **基础设施层**: shared-types → shared-utils → shared-crud
+  - **测试基础设施**: shared-test-util
+  - **业务模块层**: user-module → auth-module → file-module → geo-areas
+  - **应用层**: server (重构后) [Source: architecture/source-tree.md#集成指南]
+- **文件位置**:
+  - 源目录: `packages/core-module-mt/`
+  - 目标目录: `packages/core-module/`
+  - 模块目录: `user-module-mt/`, `auth-module-mt/`, `file-module-mt/`, `system-config-module-mt/`
+- **测试结构**:
+  - 单元测试: `tests/unit/` 目录
+  - 集成测试: `tests/integration/` 目录
+  - 测试工具: `tests/utils/` 目录 [Source: architecture/testing-strategy.md#测试金字塔策略]
+
+### 技术栈信息
+- **运行时**: Node.js 20.18.3 [Source: architecture/tech-stack.md#现有技术栈维护]
+- **框架**: Hono 4.8.5 [Source: architecture/tech-stack.md#现有技术栈维护]
+- **数据库**: PostgreSQL 17 + TypeORM 0.3.25 [Source: architecture/tech-stack.md#现有技术栈维护]
+- **包管理**: pnpm workspace [Source: architecture/source-tree.md#集成指南]
+
+### 需要更新的 package.json 字段
+基于当前 `packages/core-module-mt/package.json` 分析:
+1. **name**: `@d8d/core-module-mt` → `@d8d/core-module`
+2. **main**: `user-module-mt/src/index.mt.ts` → `user-module/src/index.ts`
+3. **types**: `user-module-mt/src/index.mt.ts` → `user-module/src/index.ts`
+4. **exports**: 所有导出路径中的 `-mt` 后缀需要移除
+5. **files**: 更新目录名称,移除 `-mt` 后缀
+
+### 文件重命名规则
+- 目录重命名:`*-module-mt` → `*-module`
+- 文件重命名:`*.mt.ts` → `*.ts`(如 `index.mt.ts` → `index.ts`)
+- 注意:`file-module-mt` 中的文件可能没有 `.mt.ts` 后缀,需要检查
+
+### 测试
+- **测试框架**: Vitest [Source: architecture/testing-strategy.md#单元测试]
+- **测试位置**: `tests/` 目录结构(单元测试:`tests/unit/`,集成测试:`tests/integration/`)[Source: architecture/testing-strategy.md#测试金字塔策略]
+- **测试类型**: 单元测试、集成测试、E2E测试 [Source: architecture/testing-strategy.md#测试金字塔策略]
+- **覆盖率目标**: 单元测试 ≥ 80%,集成测试 ≥ 60% [Source: architecture/testing-strategy.md#测试覆盖率标准]
+
+### 关键注意事项
+1. **兼容性**: 现有功能保持不变,仅进行名称和路径调整
+2. **数据库 schema**: 保持不变,不影响现有数据
+3. **性能**: 无影响,仅进行文件复制和重命名
+4. **依赖关系**: core-module 作为聚合包使用,支持按需导入
+
+## Testing
+### 测试标准
+- **测试框架**: 使用 Vitest [Source: architecture/testing-strategy.md#单元测试]
+- **测试位置**: `tests/` 目录结构(单元测试:`tests/unit/`,集成测试:`tests/integration/`)[Source: architecture/testing-strategy.md#测试金字塔策略]
+- **测试类型**: 单元测试、集成测试、E2E测试 [Source: architecture/testing-strategy.md#测试金字塔策略]
+- **覆盖率要求**: 单元测试 ≥ 80%,集成测试 ≥ 60% [Source: architecture/testing-strategy.md#测试覆盖率标准]
+
+### 本故事特定测试要求
+1. **类型检查**: 运行 `pnpm typecheck` 确保无类型错误
+2. **单元测试**: 运行 `pnpm test:unit` 确保所有单元测试通过
+3. **集成测试**: 运行 `pnpm test:integration` 验证模块间导入和导出功能正常
+4. **测试覆盖率**: 运行 `pnpm test:coverage` 检查覆盖率是否达标
+5. **导入验证**: 检查 server package 能否正确导入新的 core-module
+6. **测试结构验证**: 确保测试文件位于正确的 `tests/` 目录结构中
+
+## Change Log
+| Date | Version | Description | Author |
+|------|---------|-------------|--------|
+| 2025-12-01 | 1.1 | 根据架构文档和测试策略文档修正测试相关内容 | John (Product Manager) |
+| 2025-12-01 | 1.0 | 初始故事创建 | Bob (Scrum Master) |
+
+## Dev Agent Record
+*此部分由开发代理在实现过程中填写*
+
+### Agent Model Used
+*待填写*
+
+### Debug Log References
+*待填写*
+
+### Completion Notes List
+*待填写*
+
+### File List
+*待填写*
+
+## QA Results
+*此部分由 QA 代理在审查完成后填写*