docs: capture P3-17 plan and close storage provider task

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-02-04 18:33:36 +08:00
parent 27fe1b3ae3
commit 8f7000dc8d
3 changed files with 133 additions and 88 deletions

View File

@@ -1,69 +1,88 @@
# Implementation Plan: Portal Payment Page Hardening
# Implementation Plan: backend-test-coverage
**Branch**: `main` | **Date**: 2026-02-04 | **Spec**: `docs/seed_verification.md`
**Input**: 前端支付页仍含 DEV 模拟逻辑,支付错误提示/加载与轮询节流不足,金额/商品信息展示不完整。
**Branch**: `[test-coverage-t3-t4]` | **Date**: 2026-02-04 | **Spec**: N/A
**Input**: Continuation of test coverage tasks (T3/T4) from prior session; no feature spec.
## Summary
清理支付页 DEV 模拟逻辑,增强支付失败与加载态提示,补全金额/商品信息展示,并对状态轮询做节流,确保真实支付链路稳定可用。
Complete backend service test coverage for content access policies (T3) and superadmin write operations (T4), ensuring existing behavior is validated without altering production logic.
## Technical Context
**Language/Version**: Vue 3 (Vite)
**Primary Dependencies**: Pinia, Vue Router, PrimeVue
**Storage**: PostgreSQL(后端服务已就绪)
**Testing**: 前端页面流验证;后端 `go test ./...`(规则要求前端改动需二者并行)
**Target Platform**: local/staging
**Project Type**: Web application
**Performance Goals**: 减少轮询负载,提升用户反馈
**Constraints**: 遵循 `backend/llm.txt`、前端接口涉及需跑页面流 + go test不手改生成文件
**Scale/Scope**: 仅 Portal 支付页PaymentView.vue及相关 API/状态展示
**Language/Version**: Go 1.x (project standard)
**Primary Dependencies**: Fiber, GORM-Gen, Testify
**Storage**: PostgreSQL (via GORM)
**Testing**: `go test` (service tests under `backend/app/services/*_test.go`)
**Target Platform**: Linux server
**Project Type**: Web application (frontend + backend)
**Performance Goals**: N/A (test-only changes)
**Constraints**: No changes to generated files; keep tests aligned with existing service patterns
**Scale/Scope**: Backend service tests only (no frontend scope)
## Constitution Check
- 所有前端接口相关改动需完成页面流验证和后端 `go test ./...` 方可归档。
- 禁止保留 DEV-only 模拟逻辑于生产代码。
- Follow `backend/llm.txt` for backend conventions.
- Keep controllers thin; service tests only (no controller edits).
- Avoid editing generated files (`routes.gen.go`, `docs.go`).
- Run `go test` for impacted service packages.
## Project Structure
- `frontend/portal/src/views/order/PaymentView.vue`
- `frontend/portal/src/api/order.js`(若需补充错误/数据处理)
- `frontend/portal/src/utils/request.js`(如需请求拦截/错误提示,视需要)
### Documentation (this feature)
**Structure Decision**: 仅修改支付页与关联 API避免全局侵入。
```text
specs/[###-feature]/
└── (not used for this task)
```
### Source Code (repository root)
```text
backend/
├── app/
│ ├── services/
│ │ ├── content_test.go
│ │ └── super_test.go
└── app/http/v1/dto/
└── content.go
```
**Structure Decision**: Web application structure; scope is backend service tests in `backend/app/services`.
## Plan Phases
- Phase 1: 行为清理 —— 移除/隔离 DEV 模拟支付逻辑,确保真实 pay 调用。
- Phase 2: 体验增强 —— 添加支付中/loading/错误提示;补全金额、商品标题展示;轮询节流与完成后停止。
- Phase 3: 验证 —— 前端页面流支付冒烟 + 后端 `go test ./...`
1. Inspect DTO definitions used by content tests to fix T3 assertions.
2. Implement remaining content access policy tests (T3) and verify via `go test`.
3. Implement superadmin write operation tests (T4) and verify via `go test`.
## Tasks
- [x] T101 移除或显式守护 DEV 模拟支付按钮(生产隐藏/剔除),确保真实 pay 请求。
- [x] T102 支付提交/轮询的加载与错误提示:提交中禁用按钮,失败 toast/提示,并在错误时停止 loading。
- [x] T103 订单金额/商品信息展示:优先用 status 返回的 `amount_paid/amount_original``content_title`,保持 0 元也可显示。
- [x] T104 轮询节流与完成停止:调整轮询间隔/次数,支付成功即停止,避免过度请求。
- [x] T201 前端页面流验证支付登录→Checkout→Pay→Status paid
- [x] T202 后端回归测试 `go test ./...`(与 T201 同时满足)。
1. Read `backend/app/http/v1/dto/content.go` and update T3 test assertions to match actual DTO fields.
2. Extend `backend/app/services/content_test.go` with missing content access policy cases and run targeted tests.
3. Extend `backend/app/services/super_test.go` for superadmin write operations; run service test suite.
4. Verify all added tests pass without modifying production logic.
## Dependencies
- T101 完成后执行 T102~T104。
- T104 完成后执行 T201T201/T202 完成后归档。
- Task 1 must complete before Task 2 (DTO fields drive assertions).
- Task 2 should complete before Task 3 to isolate failures.
## Acceptance Criteria
- 支付页无 DEV-only 模拟逻辑暴露;“立即支付”触发真实 `/pay`,状态能更新为 `paid`
- 支付/轮询有明显 loading/错误反馈;轮询成功后自动停;按钮在提交中禁用。
- 金额与商品标题在支付页正确显示(含 0 元订单)。
- 前端页面流验证通过(登录→下单→支付→订单状态 paid后端 `go test ./...` 通过。
- `backend/app/services/content_test.go` has passing T3 coverage for unauthenticated access constraints.
- `backend/app/services/super_test.go` includes T4 coverage for create-tenant side effects and superadmin write operations.
- `go test ./backend/app/services/...` passes.
- No generated files modified.
## Risks
- 轮询过度或停止条件遗漏导致请求风暴;通过节流与成功后清理计时器规避。
- 错误提示未覆盖网络异常;需在提交与轮询 catch 中统一处理。
- DTO field changes may require adjusting test assertions; mitigate by verifying struct definitions.
- Service behavior may differ from assumptions in prior session; mitigate by aligning with existing tests.
## Complexity Tracking
暂无。
> **Fill ONLY if Constitution Check has violations that must be justified**
| Violation | Why Needed | Simpler Alternative Rejected Because |
|-----------|------------|-------------------------------------|
| N/A | N/A | N/A |