Jelajahi Sumber

📝 docs(story): update travel service implementation plan

- add database migration and seed data tasks
  - create migration files for activity and route tables
  - add sample activity and route seed data
  - verify migration and seed data correctness
- expand testing requirements with detailed test cases
  - add specific test locations for unit, integration and E2E tests
  - define test scenarios for route and activity API testing
  - add frontend component and query integration test requirements
- add security requirements section
  - API authentication using authMiddleware
  - data validation with Zod schema
  - sensitive information desensitization
  - permission control and input sanitization
- update change log with version 1.5 changes
yourname 4 bulan lalu
induk
melakukan
e3293a61d6
1 mengubah file dengan 43 tambahan dan 11 penghapusan
  1. 43 11
      docs/stories/005.001.story.md

+ 43 - 11
docs/stories/005.001.story.md

@@ -36,6 +36,10 @@ Draft
   - [ ] 在 `src/server/modules/routes/` 创建 `route.entity.ts`
   - [ ] 在 `src/server/modules/activities/` 创建 `activity.entity.ts`
   - [ ] 在 `src/share/` 创建相关类型定义
+- [ ] 数据库迁移和种子数据 (AC: 1, 2, 3, 4)
+  - [ ] 创建数据库迁移文件,添加活动、路线相关表结构
+  - [ ] 创建种子数据,添加示例活动和路线数据
+  - [ ] 验证数据库迁移和种子数据正确性
 - [ ] 实现路线查询API使用通用CRUD (AC: 1, 3, 4)
   - [ ] 在 `src/server/api/routes/index.ts` 使用 `createCrudRoutes` 创建通用CRUD路由
   - [ ] 配置搜索字段:startPoint, endPoint, vehicleType
@@ -54,10 +58,12 @@ Draft
 - [ ] 实现前端活动筛选组件 (AC: 2)
   - [ ] 在 `src/client/home/components/` 创建 `ActivityFilter.tsx` 组件
   - [ ] 支持活动类型筛选
-- [ ] 编写单元测试和集成测试 (AC: 1, 2, 3, 4)
-  - [ ] 为所有新实体编写单元测试
-  - [ ] 为通用CRUD路由编写集成测试
-  - [ ] 为前端组件编写单元测试
+- [ ] 编写单元测试、集成测试和E2E测试 (AC: 1, 2, 3, 4)
+  - [ ] 为所有新实体编写单元测试 (`tests/unit/server/`)
+  - [ ] 为通用CRUD路由编写集成测试 (`tests/integration/server/`)
+  - [ ] 为前端组件编写单元测试 (`tests/unit/client/`)
+  - [ ] 为查询功能编写集成测试 (`tests/integration/client/`)
+  - [ ] 编写完整出行流程的E2E测试 (`tests/e2e/travel-flow/`)
 
 ## Dev Notes
 
@@ -105,6 +111,13 @@ Draft
 - **认证中间件**: 使用 `authMiddleware` 保护路由 [Source: src/server/api/users/index.ts#L17]
 - **前端调用**: 使用React Query调用通用CRUD API,支持分页、搜索、排序
 
+### 安全要求
+- **API认证**: 所有路线和活动查询API必须使用 `authMiddleware` 进行认证保护
+- **数据验证**: 所有输入数据必须通过Zod schema验证 [Source: architecture.md#后端安全]
+- **敏感信息处理**: 司机电话等敏感信息在响应中应适当脱敏
+- **权限控制**: 确保用户只能访问授权的数据 [Source: architecture.md#认证授权]
+- **输入清理**: 防止SQL注入和XSS攻击 [Source: architecture.md#后端安全]
+
 ### mini-demo迁移指导
 - **迁移来源**: 所有页面迁移基于 `mini-demo/pages/` 目录下的对应页面 [Source: docs/prd/epic-005-travel-service-core.md#mini-demo页面分析]
 - **技术栈转换**: 将mini-demo原生小程序代码转换为Taro + React技术栈
@@ -132,20 +145,39 @@ Draft
 
 ### Testing
 **测试要求**:
-- **单元测试位置**: `__tests__/` 文件夹与源码并列 [Source: architecture/testing-strategy.md#单元测试]
-- **集成测试位置**: `__integration_tests__/` 目录 [Source: architecture/testing-strategy.md#集成测试]
-- **测试框架**: Vitest + Testing Library + hono/testing [Source: architecture/testing-strategy.md#测试框架]
+- **单元测试位置**: `tests/unit/` 目录 [Source: architecture/testing-strategy.md#单元测试]
+- **集成测试位置**: `tests/integration/` 目录 [Source: architecture/testing-strategy.md#集成测试]
+- **E2E测试位置**: `tests/e2e/` 目录 [Source: architecture/testing-strategy.md#e2e测试]
+- **测试框架**: Vitest + Testing Library + hono/testing + Playwright [Source: architecture/testing-strategy.md#测试框架]
 - **覆盖率目标**: 核心业务逻辑 > 80% [Source: architecture/testing-strategy.md#覆盖率目标]
 
 **具体测试要求**:
-- 路线查询API的单元测试和集成测试
-- 活动查询API的单元测试和集成测试
-- 前端组件的单元测试
-- 查询功能的集成测试
+- 路线查询API的单元测试 (`tests/unit/server/routes/`) 和集成测试 (`tests/integration/server/routes/`)
+  - 正常查询场景:按出发地、目的地、日期查询
+  - 边界条件:空查询结果、日期范围查询、分页查询
+  - 排序功能:按价格、出发时间排序
+  - 错误场景:无效参数、认证失败、权限不足
+- 活动查询API的单元测试 (`tests/unit/server/activities/`) 和集成测试 (`tests/integration/server/activities/`)
+  - 正常筛选场景:按活动类型(去程/返程)筛选
+  - 边界条件:无活动数据、活动状态筛选
+  - 关联查询:活动关联的路线数据
+  - 错误场景:无效类型参数、认证失败
+- 前端组件的单元测试 (`tests/unit/client/home/`)
+  - 组件渲染:首页、活动选择、班次列表页面
+  - 用户交互:查询表单提交、筛选条件变更
+  - 状态管理:查询结果展示、加载状态处理
+- 查询功能的集成测试 (`tests/integration/client/home/`)
+  - 完整查询流程:首页查询 → 活动筛选 → 班次列表
+  - 数据一致性:前端展示与后端数据一致
+  - 错误处理:网络错误、API错误处理
+- 完整出行流程的E2E测试 (`tests/e2e/travel-flow/`)
+  - 用户登录 → 路线查询 → 活动筛选 → 查看班次列表
+  - 边界场景:无数据、大量数据、并发查询
 
 ## Change Log
 | Date | Version | Description | Author |
 |------|---------|-------------|--------|
+| 2025-10-15 | 1.5 | 修复测试位置与测试策略文档不一致问题,添加安全要求和数据库迁移任务 | Bob (Scrum Master) |
 | 2025-10-15 | 1.4 | 补充MVP文档中标识为暂时不要的页面元素 | Bob (Scrum Master) |
 | 2025-10-15 | 1.3 | 明确迁移来源为mini-demo并添加页面结构分析 | Bob (Scrum Master) |
 | 2025-10-15 | 1.2 | 添加页面迁移任务和具体页面实现 | Bob (Scrum Master) |