Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
- background/index 使用安全日志助手,输出超过 10KB 时自动截断并提示
- 避免 content-script 控制台被巨型响应体切割,便于调试
- 新增单元测试覆盖截断逻辑,防止回归
- **测试质量** - helpers 与生产代码保持一致
- `tests/helpers.test.js` 直接导入 `response-handler`,覆盖 `processBackgroundResponse` 和 `buildYapiCallbackParams`
- 移除遗留提醒注释,防止测试与生产代码脱节

## [4.5.0] - 2025-10-17

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

### 已知限制
### 已知限制(历史)

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

## [4.4.13] - 2025-10-17

Expand Down
26 changes: 14 additions & 12 deletions FIXES.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,23 @@ extension.zip
**影响**: 真实代码回归时测试不会失败
**根本原因**: index.js 使用 IIFE 模式,不导出函数

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

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

## ✅ 修复后状态

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

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

## 🎯 关键教训

Expand Down
Loading
Loading