feat: 为高频变更 JS 文件补充 smoke test 并建立 js-test-gate Rule

新增测试:
- api.test.js: 28 个用例覆盖 VpsFmt 纯工具函数(OAuth 归一化、倒计时文案、费用文案、徽章样式)
- app.test.js: 15 个用例覆盖 NAVS/VIEW_MAP/VALID_VIEWS 常量和 _viewFromHash 路由解析
- modals.test.js: 3 个用例验证 9 个模态框组件定义完整性

规则与钩子:
- 新建 .qoder/rules/js-test-gate.md:编辑 static/js/ 下 JS 文件后运行 vitest
- 更新 post-edit-check.sh:JS 编辑后 node --check + vitest(排除 vendored 文件)

部署闸门 check_js_tests(update.sh)已有 vitest run 步骤,现在测试覆盖从 1/7 文件提升到 4/7
This commit is contained in:
gouki
2026-10-15 21:20:52 +00:00
parent 90695c82fd
commit a63fcb786f
5 changed files with 539 additions and 2 deletions
+10 -2
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# Post-edit hook: 自动验证编辑后的文件
# - Python 文件 → 运行 pytest
# - JavaScript 文件 → 运行 node --check
# - JavaScript 文件 → node --check 语法检查 + vitest 单元测试
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path')
@@ -17,7 +17,15 @@ case "$rel_path" in
;;
static/js/*.js)
echo "🔍 检测到 JavaScript 文件变更: $rel_path" >&2
node --check "$file_path"
node --check "$file_path" || exit 1
# 语法通过后运行 vitest(排除 vendored 文件)
case "$rel_path" in
*/vue.global.prod.js|*/tailwind.js|*/chart.umd.js) ;;
*)
cd "$QODER_PROJECT_DIR" || exit 0
npx vitest run
;;
esac
;;
esac