expo-popcore-app/task_plan.md

88 lines
2.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.

# Task Plan: 生成记录页面删除作品功能
## Goal
实现 `app/generationRecord.tsx` 页面的删除作品功能,包括单个删除和批量删除,严格遵循 TDD 规范,测试覆盖率 > 80%
## Current Phase
Phase 5: 测试验证
## Phases
### Phase 1: 需求分析与代码调研
- [x] 分析现有页面代码结构
- [x] 了解现有 hooks 和控制器
- [x] 确认 API 接口
- [x] 了解测试框架配置
- **Status:** complete
### Phase 2: 创建测试文件TDD - 先写测试)
- [x] 创建 `tests/hooks/use-template-generation-actions.test.ts`
- [x] 编写单个删除成功场景测试
- [x] 编写单个删除失败场景测试
- [x] 编写批量删除成功场景测试(可选)
- [x] Mock SDK 控制器
- **Status:** complete
### Phase 3: 实现 HookTDD - 后写实现)
- [x] 创建 `hooks/use-template-generation-actions.ts`
- [x] 实现 `useDeleteGeneration` hook
- [x] 实现 `useBatchDeleteGenerations` hook可选
- [x] 导出 hooks
- **Status:** complete
### Phase 4: 更新页面组件
- [x] 更新 `hooks/index.ts` 导出新 hooks
- [x] 修改 `app/generationRecord.tsx` 集成删除功能
- [x] 添加删除确认对话框
- [x] 添加删除成功后刷新列表
- [x] 添加删除失败错误提示
- [x] 添加删除中加载状态
- **Status:** complete
### Phase 5: 测试验证
- [ ] 运行单元测试 `npm test -- use-template-generation-actions`
- [ ] 检查测试覆盖率 > 80%
- [ ] 运行 ESLint 检查
- [ ] 手动测试删除功能
- **Status:** in_progress
### Phase 6: 交付
- [ ] 确认所有功能正常工作
- [ ] 生成最终报告
- **Status:** pending
## Key Questions
1. 如何使用 `@tanstack/react-query``useMutation`? - 已确认项目未使用,将使用自定义实现
2. SDK 控制器的 delete 和 batchDelete 接口是什么? - 已确认:需要 `{ id: string }``{ ids: string[] }`
3. 如何正确处理错误和加载状态? - 使用现有的 `handleError` 模式
4. 测试框架是什么? - Jest + @testing-library/react-native
## Decisions Made
| Decision | Rationale |
|----------|-----------|
| 不使用 @tanstack/react-query | 项目未安装此依赖,使用现有自定义 hooks 模式 |
| 遵循现有代码风格 | 保持与 `use-template-actions.ts` 一致的实现方式 |
| 先实现单个删除 | 主要需求,批量删除可选 |
| 使用现有的 DeleteConfirmDialog | 页面已集成,无需额外组件 |
## Errors Encountered
| Error | Attempt | Resolution |
|-------|---------|------------|
| | 1 | |
## Notes
- 严格遵循 TDD先写测试后写实现
- 使用 test-driven-development skill
- 每个子任务使用 subagent 完成
- 根据 subagent 汇报更新 plan 文件
## 文件结构
```
hooks/
use-template-generation-actions.ts (新建)
index.ts (修改)
tests/hooks/
use-template-generation-actions.test.ts (新建)
app/generationRecord.tsx (修改)
```