Files
mindfulness/spec_kit/Text Wrap/modules/golden-tests/plan.md
2026-02-10 11:39:33 +08:00

58 lines
2.1 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.
# golden-tests技术计划
## 1. 计划目标
建立可持续回归体系,覆盖:
- **Golden Cases**:固定输入 → 固定输出lines/wrappedText/meta作为“可治理基线”
- **性质测试property tests**
- 确定性:同输入多次调用输出一致
- 近似单调性availableWidth 变小不会让任一行变得更宽(同测量口径下)
- maxLines 不变差maxLines 增加时至少不从可解变 overflow
本模块产出测试数据与测试规则,不产出业务功能。
## 2. 约束与策略
### 2.1 测量可控
- APP使用稳定的测量 mock例如 `width = text.length`)保证 CI 可运行
- WIDGET使用固定 profile 或 `widthMode=APPROX`(单位为 tokenCount/graphemeCount
### 2.2 Golden 的组织方式
- 采用 TS fixture便于类型校验与可读性
- Golden case 至少包含:
- `text/lang/context/availableWidth/maxLines/overflowMode/lineMode/configVersion`
- 期望:`expected.lines/expected.wrappedText`(可选 meta 断言)
### 2.3 覆盖面(首版)
首版优先覆盖“易回归且高价值”的样例集:
- EN/TC 各若干条:短/长、含标点/无标点、含 emoji、含 shift/accum/self、极窄宽度
> 说明:文档建议每种语言 20 条;首版先落最小可运行集合,后续迭代扩充但保持可解释与版本化。
## 3. 测试实现结构(客户端)
- `client/src/features/textWrap/golden/fixtures.ts`Golden cases
- `client/src/features/textWrap/golden/__tests__/golden.test.ts`
- Golden 断言lines/wrappedText
- 性质测试determinism/monotonic/maxLines
测试内暂时使用“测试版 wrapTextHarness”把已实现模块串起来
- normalize/tokenizeEN=tokenizeENTC=segmentGraphemes
- generateBreakpoints
- search-engine-app / search-engine-widget
待 integration 模块产出正式 `wrapText()` 后,再把测试入口切到正式函数(不改变期望数据)。
## 4. 完成定义DoD
- Golden fixtures + 测试可在 CI 一键运行
- 至少包含 EN/TC 的基础样例与 3 类性质测试
- overview 更新记录变更文件