Skip to content

Commit 3ff6b89

Browse files
authored
Merge pull request #24 from leeguooooo/finish-todo
test(helpers): update tests to use real helpers and document removal of test tech debt
2 parents cd6e708 + fe6d72c commit 3ff6b89

File tree

3 files changed

+238
-116
lines changed

3 files changed

+238
-116
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
- background/index 使用安全日志助手,输出超过 10KB 时自动截断并提示
1515
- 避免 content-script 控制台被巨型响应体切割,便于调试
1616
- 新增单元测试覆盖截断逻辑,防止回归
17+
- **测试质量** - helpers 与生产代码保持一致
18+
- `tests/helpers.test.js` 直接导入 `response-handler`,覆盖 `processBackgroundResponse``buildYapiCallbackParams`
19+
- 移除遗留提醒注释,防止测试与生产代码脱节
1720

1821
## [4.5.0] - 2025-10-17
1922

@@ -90,12 +93,13 @@
9093
- **增强 buildQueryString**: 支持数组(`ids=[1,2,3]``ids=1&ids=2&ids=3`)和嵌套对象(JSON 序列化)
9194
- **测试覆盖**: 新增 29 个测试(总计 68 个),覆盖大小写、数组、对象等场景
9295

93-
### 已知限制
96+
### 已知限制(历史)
9497

9598
- 测试使用 mock helper 实现而非真实代码(技术债,计划 v4.5.0 修复)
9699
- 原因:index.js 使用 IIFE 模式,不支持 export
97100
- 风险:如果 index.js 退化,测试可能仍然通过
98-
- 缓解:在测试文件顶部有明确的 TODO 注释
101+
- ~~缓解:在测试文件顶部标注风险提示(已移除)~~
102+
- ✅ 已在 v4.5.x 中解决:helpers 模块化,测试直接导入真实代码(含 response-handler 覆盖)
99103

100104
## [4.4.13] - 2025-10-17
101105

FIXES.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,23 @@ extension.zip
5050
**影响**: 真实代码回归时测试不会失败
5151
**根本原因**: index.js 使用 IIFE 模式,不导出函数
5252

53-
**修复**: ✅ 在测试文件中添加详细说明和 TODO
53+
**修复**: ✅ 在测试文件中记录模块化现状并导入真实 helper 代码
5454
```javascript
5555
/**
56-
* NOTE: Currently these tests re-implement the helper logic
57-
* instead of importing from index.js because index.js uses
58-
* an IIFE pattern that doesn't export functions.
59-
*
60-
* TODO (v4.5.0): Refactor index.js to extract helpers into
61-
* a separate module (helpers/body-parser.js) that can be
62-
* imported by both production code and tests. See ROADMAP.md
63-
* for the modularization plan.
56+
* Tests for helper functions
57+
*
58+
* These tests focus on critical bug fixes:
59+
* - v4.4.13: Falsy-value handling
60+
* - v4.4.14: GET request parameter handling (Issue #20)
61+
* - v4.5.x: Modularization - tests import REAL production code
62+
*
63+
* ✅ Helpers extracted to src/helpers/, tests import real code (no re-implementations)
64+
* ✅ Response handler helper covered by unit tests to prevent regressions
65+
* This eliminates the "false green" risk where tests pass but production breaks.
6466
*/
6567
```
6668

67-
**长期解决方案**: 在 v4.5.0 模块化重构中解决(见 ROADMAP.md)
69+
**长期解决方案**: 在 v4.5.0 模块化重构中解决(见 ROADMAP.md),并在 v4.5.x 进一步覆盖 response-handler 逻辑
6870

6971
## ✅ 修复后状态
7072

@@ -73,7 +75,7 @@ extension.zip
7375
- ✅ CHANGELOG.md - 移除不存在文件引用
7476
- ✅ .gitignore - 添加安全忽略项
7577
- ✅ package.json - 修正 Jest 版本
76-
-__tests__/helpers.test.js - 添加说明和 TODO
78+
-tests/helpers.test.js - 更新说明并导入真实 helper 代码
7779

7880
### 验证结果
7981
```bash
@@ -100,7 +102,7 @@ $ npm run lint
100102
| CHANGELOG 链接不存在的文件 | High | 移除引用 ||
101103
| .gitignore 缺失 .pem/.crx | High | 添加忽略项 ||
102104
| Jest 版本不匹配 | Medium | 降级到 29.7.0 ||
103-
| 测试不导入真实代码 | Medium | 添加说明+TODO ||
105+
| 测试不导入真实代码 | Medium | 模块化 helpers 并更新测试覆盖真实代码 ||
104106

105107
## 🎯 关键教训
106108

0 commit comments

Comments
 (0)