Browse Source

📝 docs(story): add story for service layer unit test migration

- create story document for migrating service layer unit tests
- define acceptance criteria for UserService, FileService, MinioService and AuthService migration
- outline tasks and subtasks for test migration process
- add technical stack information and project structure details
- document migration strategy and change log
yourname 4 weeks ago
parent
commit
fc0948f4a8
1 changed files with 90 additions and 0 deletions
  1. 90 0
      docs/stories/005.002.service-layer-unit-tests.md

+ 90 - 0
docs/stories/005.002.service-layer-unit-tests.md

@@ -0,0 +1,90 @@
+# Story 005.002: 迁移服务层单元测试
+
+**父史诗**: 史诗005 - Server测试迁移优化
+[docs/prd/epic-005-server-test-migration.md](docs/prd/epic-005-server-test-migration.md)
+
+## Status
+Draft
+
+## Story
+**As a** 开发工程师
+**I want** 将服务层单元测试从web目录迁移到packages/server目录
+**so that** 服务层测试与对应的服务代码在同一包中,实现更好的代码组织和测试架构
+
+## Acceptance Criteria
+1. UserService相关测试成功迁移
+2. FileService相关测试成功迁移
+3. MinioService相关测试成功迁移
+4. AuthService相关测试成功迁移
+5. 验证迁移后测试正常运行
+
+## Tasks / Subtasks
+- [ ] 迁移UserService相关测试
+  - [ ] 查找web目录中的UserService测试文件
+  - [ ] 迁移测试文件到packages/server/tests/unit/
+  - [ ] 更新导入路径和依赖
+  - [ ] 验证测试正常运行
+- [ ] 迁移FileService相关测试
+  - [ ] 查找web目录中的FileService测试文件
+  - [ ] 迁移测试文件到packages/server/tests/unit/
+  - [ ] 更新导入路径和依赖
+  - [ ] 验证测试正常运行
+- [ ] 迁移MinioService相关测试
+  - [ ] 查找web目录中的MinioService测试文件
+  - [ ] 迁移测试文件到packages/server/tests/unit/
+  - [ ] 更新导入路径和依赖
+  - [ ] 验证测试正常运行
+- [ ] 迁移AuthService相关测试
+  - [ ] 查找web目录中的AuthService测试文件
+  - [ ] 迁移测试文件到packages/server/tests/unit/
+  - [ ] 更新导入路径和依赖
+  - [ ] 验证测试正常运行
+- [ ] 验证迁移后测试正常运行
+  - [ ] 运行所有迁移的单元测试
+  - [ ] 验证测试通过率
+  - [ ] 检查测试覆盖率
+
+## Dev Notes
+
+### 技术栈信息
+- **测试框架**: Vitest 3.2.4 [Source: architecture/tech-stack.md#新技术添加]
+- **Node.js版本**: 20.18.3 [Source: architecture/tech-stack.md#现有技术栈维护]
+- **TypeScript**: 5.8.3 [Source: architecture/tech-stack.md#现有技术栈维护]
+
+### 项目结构信息
+- **packages/server位置**: `/packages/server/` [Source: architecture/source-tree.md#实际项目结构]
+- **web测试目录**: `/web/tests/` [Source: architecture/source-tree.md#实际项目结构]
+- **目标测试目录**: `/packages/server/tests/unit/` [Source: 005.001.server-test-environment.md]
+
+### 编码标准和测试策略
+- **测试文件位置**: `__tests__` 文件夹与源码并列 [Source: architecture/coding-standards.md#增强特定标准]
+- **测试类型**: 单元测试、集成测试、E2E测试 [Source: architecture/coding-standards.md#增强特定标准]
+- **覆盖率目标**: 核心业务逻辑 > 80% [Source: architecture/coding-standards.md#增强特定标准]
+
+### 服务模块位置
+- **UserService**: `packages/server/src/modules/users/user.service.ts`
+- **FileService**: `packages/server/src/modules/files/file.service.ts`
+- **MinioService**: `packages/server/src/modules/files/minio.service.ts`
+- **AuthService**: `packages/server/src/modules/auth/auth.service.ts`
+
+### 迁移策略
+- 查找web/tests目录中针对上述服务的单元测试
+- 将测试文件迁移到packages/server/tests/unit/对应目录
+- 更新导入路径,使用相对路径或别名
+- 确保测试依赖项正确配置
+- 验证迁移后测试正常运行
+
+## Change Log
+| Date | Version | Description | Author |
+|------|---------|-------------|--------|
+| 2025-11-09 | 1.0 | 初始故事创建 | James (Developer) |
+
+## Dev Agent Record
+
+### Agent Model Used
+
+### Debug Log References
+
+### Completion Notes List
+
+### File List