Files

33 lines
1.8 KiB
Markdown
Raw Permalink 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.
# PROGRESS — E-03 · 每日一题 + 全站正确率
- 状态:done
> 日期 2026-09-13 · 范围:只改 `english-drill` 目录(后端 core + 前端组件 + tests/e2e)
## 现状 vs 差距(接手时)
- 已有:`DailyChallengeView`(sha256(日期)%题数确定性选题、幂等、实时聚合)、
`DailyChallengeCard`(参与数展示)、`ChallengeAttempt(user,date)` 唯一约束。
- 缺口:E2E 零覆盖;前端提交后不展示全站正确率(“答完看看全站正确率”是空话)。
## 改动(全部在 `C:/Users/12914/Desktop/english-drill/` 内)
1. `tests/e2e/cases_challenge.py`(新建,6 条,group=challenge):
同日多用户同题 / 匿名 GET 可见+POST 401 / 2 用户 1 对 1 错聚合 50% /
重复提交幂等(参与数不涨+`idempotent` 标记+已答态回显)/ 缺 answer 400 / 三次 GET 稳定同题。
2. `tests/e2e/run_e2e.py`:注册 `cases_challenge`。
3. `frontend/src/components/DailyChallengeCard.tsx`:提交后用返回的
`participants_today/correct_rate` 刷新头部与结果区(“全站正确率 X%”)。
## 验证
```bash
python "C:/.../english-drill/tests/e2e/run_e2e.py" -k challenge
# 合计 6 用例 | 通过 6 | 断言失败 0 | 异常 0
python "C:/.../english-drill/tests/e2e/run_e2e.py"
# 合计 124 用例 | 通过 124 | 断言失败 0 | 异常 0(含本轮新增 13)
tsc --noEmit -p frontend/tsconfig.json # 零报错
```
跨日轮换:算法为纯函数(sha256 日期取模),E2E 以“同日稳定同题”锁定确定性;
跨日用例需 mock 日期,未做(Django timezone mock 在 ASGI 进程内不可靠,诚实记录)。
## 状态
done。遗留:跨日轮换 mock 用例;推送/提醒(任务卡明确本轮不做)。