增加 后端,后台管理系统,uniapp会员端的自动化测试。

This commit is contained in:
2026-07-21 18:09:29 +08:00
parent df0e68469b
commit 6b60b3b4da
64 changed files with 13095 additions and 376 deletions
@@ -0,0 +1,68 @@
#!/bin/sh
# 小程序冒烟测试 —— 预提交钩子
#
# 安装方式(二选一):
#
# 1. 使用 Husky(推荐):
# npx husky add .husky/pre-commit "sh scripts/pre-commit-miniapp-test.sh"
#
# 2. 手动复制到 .git/hooks/
# cp scripts/pre-commit-miniapp-test.sh .git/hooks/pre-commit
# chmod +x .git/hooks/pre-commit
#
# 注意:此钩子会在本地 IDE 已开启时运行冒烟测试。
# 未检测到 IDE 运行时自动跳过(不会阻塞提交)。
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
echo ""
echo " 🔍 小程序冒烟测试 (Pre-commit)"
echo " ─────────────────────────────"
# 仅检查小程序相关文件的变更
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E "^gym-manage-uniapp/(pages|e2e)/" || true)
if [ -z "$CHANGED_FILES" ]; then
echo " ⏭ 无小程序页面/测试文件变更,跳过测试"
exit 0
fi
echo " 📝 检测到小程序相关变更:"
echo "$CHANGED_FILES" | while read -r f; do echo "$f"; done
echo ""
# 检查 IDE 是否运行
IDE_RUNNING=$(powershell.exe -Command "
try {
\$(Get-Process -Name '微信开发者工具' -ErrorAction Stop).Count;
Write-Output 'yes'
} catch {
Write-Output 'no'
}
" 2>/dev/null || echo "no")
if [ "$IDE_RUNNING" != "yes" ]; then
echo " ⚠ 微信开发者工具未运行,跳过小程序测试"
echo " 快测方式(IDE 已运行时):npm test"
exit 0
fi
echo " 🚀 运行冒烟测试..."
# 切换到 uniapp 目录运行
cd "$PROJECT_DIR"
npm run test:quick:smoke 2>&1
if [ $? -eq 0 ]; then
echo ""
echo " ✅ 冒烟测试通过"
exit 0
else
echo ""
echo " ❌ 冒烟测试失败!"
echo " 请修复后再提交,或使用 git commit --no-verify 跳过"
exit 1
fi