feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
This commit is contained in:
+169
@@ -0,0 +1,169 @@
|
||||
#!/bin/bash
|
||||
|
||||
# E2E测试执行脚本
|
||||
# 使用方法: ./run_tests.sh [选项]
|
||||
|
||||
set -e
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 默认配置
|
||||
TEST_ENV="dev"
|
||||
TEST_MARKERS=""
|
||||
TEST_PATH=""
|
||||
BROWSER="chromium"
|
||||
HEADED="--headed"
|
||||
VERBOSE="-v"
|
||||
HTML_REPORT="--html=reports/html/test_report.html --self-contained-html"
|
||||
ALLURE_REPORT="--alluredir=reports/allure-results"
|
||||
|
||||
# 显示帮助信息
|
||||
show_help() {
|
||||
echo -e "${BLUE}E2E测试执行脚本${NC}"
|
||||
echo ""
|
||||
echo "用法: ./run_tests.sh [选项]"
|
||||
echo ""
|
||||
echo "选项:"
|
||||
echo " -e, --env <env> 测试环境 (dev/test/prod), 默认: dev"
|
||||
echo " -m, --markers <markers> 测试标记 (smoke/regression/admin/uniapp)"
|
||||
echo " -p, --path <path> 测试路径 (tests/web tests/uniapp)"
|
||||
echo " -b, --browser <browser> 浏览器 (chromium/firefox/webkit), 默认: chromium"
|
||||
echo " --headless 无头模式运行"
|
||||
echo " --html 生成HTML报告"
|
||||
echo " --allure 生成Allure报告"
|
||||
echo " -h, --help 显示帮助信息"
|
||||
echo ""
|
||||
echo "示例:"
|
||||
echo " ./run_tests.sh # 运行所有测试"
|
||||
echo " ./run_tests.sh -m smoke # 运行冒烟测试"
|
||||
echo " ./run_tests.sh -m admin # 运行Admin端测试"
|
||||
echo " ./run_tests.sh -m uniapp # 运行Uniapp端测试"
|
||||
echo " ./run_tests.sh -p tests/web/test_auth.py # 运行指定测试文件"
|
||||
echo " ./run_tests.sh --headless --html --allure # 无头模式并生成报告"
|
||||
}
|
||||
|
||||
# 解析命令行参数
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-e|--env)
|
||||
TEST_ENV="$2"
|
||||
shift 2
|
||||
;;
|
||||
-m|--markers)
|
||||
TEST_MARKERS="-m $2"
|
||||
shift 2
|
||||
;;
|
||||
-p|--path)
|
||||
TEST_PATH="$2"
|
||||
shift 2
|
||||
;;
|
||||
-b|--browser)
|
||||
BROWSER="$2"
|
||||
shift 2
|
||||
;;
|
||||
--headless)
|
||||
HEADED=""
|
||||
shift
|
||||
;;
|
||||
--html)
|
||||
HTML_REPORT="--html=reports/html/test_report_$(date +%Y%m%d_%H%M%S).html --self-contained-html"
|
||||
shift
|
||||
;;
|
||||
--allure)
|
||||
ALLURE_REPORT="--alluredir=reports/allure-results"
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}错误: 未知选项 $1${NC}"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# 显示执行信息
|
||||
echo -e "${BLUE}================================${NC}"
|
||||
echo -e "${BLUE} E2E测试执行${NC}"
|
||||
echo -e "${BLUE}================================${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}环境:${NC} $TEST_ENV"
|
||||
echo -e "${YELLOW}浏览器:${NC} $BROWSER"
|
||||
echo -e "${YELLOW}标记:${NC} ${TEST_MARKERS:-无}"
|
||||
echo -e "${YELLOW}路径:${NC} ${TEST_PATH:-全部}"
|
||||
echo ""
|
||||
|
||||
# 设置环境变量
|
||||
export TEST_ENV=$TEST_ENV
|
||||
export TEST_BROWSER=$BROWSER
|
||||
|
||||
# 创建报告目录
|
||||
mkdir -p reports/html
|
||||
mkdir -p reports/allure-results
|
||||
mkdir -p reports/screenshots
|
||||
mkdir -p logs
|
||||
|
||||
# 安装依赖(如果需要)
|
||||
echo -e "${BLUE}检查依赖...${NC}"
|
||||
pip install -q -r requirements.txt 2>/dev/null || true
|
||||
|
||||
# 安装Playwright浏览器(如果需要)
|
||||
echo -e "${BLUE}检查Playwright浏览器...${NC}"
|
||||
python -m playwright install $BROWSER 2>/dev/null || true
|
||||
|
||||
# 构建测试命令
|
||||
TEST_CMD="pytest"
|
||||
|
||||
if [ -n "$TEST_PATH" ]; then
|
||||
TEST_CMD="$TEST_CMD $TEST_PATH"
|
||||
else
|
||||
TEST_CMD="$TEST_CMD tests"
|
||||
fi
|
||||
|
||||
TEST_CMD="$TEST_CMD $VERBOSE"
|
||||
TEST_CMD="$TEST_CMD --browser=$BROWSER"
|
||||
TEST_CMD="$TEST_CMD $HEADED"
|
||||
TEST_CMD="$TEST_CMD $TEST_MARKERS"
|
||||
TEST_CMD="$TEST_CMD $HTML_REPORT"
|
||||
TEST_CMD="$TEST_CMD $ALLURE_REPORT"
|
||||
|
||||
# 执行测试
|
||||
echo -e "${BLUE}执行测试...${NC}"
|
||||
echo -e "${YELLOW}命令:${NC} $TEST_CMD"
|
||||
echo ""
|
||||
|
||||
if $TEST_CMD; then
|
||||
echo ""
|
||||
echo -e "${GREEN}================================${NC}"
|
||||
echo -e "${GREEN} 测试执行完成${NC}"
|
||||
echo -e "${GREEN}================================${NC}"
|
||||
|
||||
# 生成Allure报告(如果需要)
|
||||
if [[ "$ALLURE_REPORT" == *"alluredir"* ]]; then
|
||||
echo ""
|
||||
echo -e "${BLUE}生成Allure报告...${NC}"
|
||||
if command -v allure &> /dev/null; then
|
||||
allure generate reports/allure-results -o reports/allure-report --clean
|
||||
echo -e "${GREEN}Allure报告已生成: reports/allure-report${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}Allure命令未找到,跳过报告生成${NC}"
|
||||
echo -e "${YELLOW}可以使用 'pip install allure-pytest' 安装${NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
else
|
||||
echo ""
|
||||
echo -e "${RED}================================${NC}"
|
||||
echo -e "${RED} 测试执行失败${NC}"
|
||||
echo -e "${RED}================================${NC}"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user