-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_admin_tests.sh
More file actions
executable file
·145 lines (122 loc) · 4.71 KB
/
run_admin_tests.sh
File metadata and controls
executable file
·145 lines (122 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# EchoForge Admin Dashboard Test Runner Script
# This script runs tests for the admin dashboard
set -e # Exit immediately if a command exits with a non-zero status
# Setup colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print header
echo -e "${BLUE}=========================================${NC}"
echo -e "${BLUE} EchoForge Admin Dashboard Test Suite ${NC}"
echo -e "${BLUE}=========================================${NC}"
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR"
# Setup environment for testing
export ECHOFORGE_TEST=true
# Create logs directory
mkdir -p "$SCRIPT_DIR/logs"
LOG_FILE="$SCRIPT_DIR/logs/admin_test_run_$(date +%Y%m%d_%H%M%S).log"
echo -e "${YELLOW}Test logs will be saved to:${NC} $LOG_FILE"
echo
# Function to run a test and check its exit code
run_test() {
TEST_NAME=$1
TEST_CMD=$2
echo -e "${YELLOW}Running ${TEST_NAME}...${NC}"
echo "Running $TEST_NAME with command: $TEST_CMD" >> "$LOG_FILE"
if eval "$TEST_CMD" >> "$LOG_FILE" 2>&1; then
echo -e "${GREEN}✓ ${TEST_NAME} passed${NC}"
return 0
else
echo -e "${RED}✗ ${TEST_NAME} failed${NC}"
echo -e "${YELLOW}See log file for details: ${LOG_FILE}${NC}"
return 1
fi
}
# Check if virtual environment exists
if [ ! -d ".venv" ]; then
echo -e "${YELLOW}Virtual environment not found. Setting up environment...${NC}"
./setup_env.sh
fi
# Activate virtual environment
echo -e "${YELLOW}Activating virtual environment...${NC}"
source .venv/bin/activate
# Install test dependencies if needed
echo -e "${YELLOW}Installing test dependencies...${NC}"
pip install pytest pytest-asyncio httpx pytest-cov
# Variable to track overall test status
TESTS_PASSED=true
# Run UI tests for admin routes
if run_test "Admin UI Routes Tests" "python -m pytest tests/ui/test_admin_routes.py -v"; then
UI_TESTS_PASSED=true
else
UI_TESTS_PASSED=false
TESTS_PASSED=false
fi
# Run API tests for admin endpoints
if run_test "Admin API Tests" "python -m pytest tests/api/test_admin_api.py -v"; then
API_TESTS_PASSED=true
else
API_TESTS_PASSED=false
TESTS_PASSED=false
fi
# Run integration tests for admin dashboard
if run_test "Admin Integration Tests" "python -m pytest tests/integration/test_admin_dashboard.py -v"; then
INTEGRATION_TESTS_PASSED=true
else
INTEGRATION_TESTS_PASSED=false
TESTS_PASSED=false
fi
# Run end-to-end tests for admin dashboard
if run_test "Admin E2E Tests" "python -m pytest tests/e2e/test_admin_e2e.py -v"; then
E2E_TESTS_PASSED=true
else
E2E_TESTS_PASSED=false
TESTS_PASSED=false
fi
# Run JavaScript tests for admin dashboard
if run_test "Admin JavaScript Tests" "python -m pytest tests/ui/test_admin_js.py -v"; then
JS_TESTS_PASSED=true
else
JS_TESTS_PASSED=false
TESTS_PASSED=false
fi
# Run authentication tests for admin dashboard
if run_test "Admin Authentication Tests" "python -m pytest tests/ui/test_admin_auth.py -v"; then
AUTH_TESTS_PASSED=true
else
AUTH_TESTS_PASSED=false
TESTS_PASSED=false
fi
# Run error handling tests for admin dashboard
if run_test "Admin Error Handling Tests" "python -m pytest tests/ui/test_admin_errors.py -v"; then
ERROR_TESTS_PASSED=true
else
ERROR_TESTS_PASSED=false
TESTS_PASSED=false
fi
# Print summary
echo
echo -e "${BLUE}=================================${NC}"
echo -e "${BLUE} Test Summary ${NC}"
echo -e "${BLUE}=================================${NC}"
echo -e "Admin UI Routes Tests: $(if $UI_TESTS_PASSED; then echo -e "${GREEN}PASSED${NC}"; else echo -e "${RED}FAILED${NC}"; fi)"
echo -e "Admin API Tests: $(if $API_TESTS_PASSED; then echo -e "${GREEN}PASSED${NC}"; else echo -e "${RED}FAILED${NC}"; fi)"
echo -e "Admin Integration Tests: $(if $INTEGRATION_TESTS_PASSED; then echo -e "${GREEN}PASSED${NC}"; else echo -e "${RED}FAILED${NC}"; fi)"
echo -e "Admin E2E Tests: $(if $E2E_TESTS_PASSED; then echo -e "${GREEN}PASSED${NC}"; else echo -e "${RED}FAILED${NC}"; fi)"
echo -e "Admin JavaScript Tests: $(if $JS_TESTS_PASSED; then echo -e "${GREEN}PASSED${NC}"; else echo -e "${RED}FAILED${NC}"; fi)"
echo -e "Admin Authentication Tests: $(if $AUTH_TESTS_PASSED; then echo -e "${GREEN}PASSED${NC}"; else echo -e "${RED}FAILED${NC}"; fi)"
echo -e "Admin Error Handling Tests: $(if $ERROR_TESTS_PASSED; then echo -e "${GREEN}PASSED${NC}"; else echo -e "${RED}FAILED${NC}"; fi)"
echo
if $TESTS_PASSED; then
echo -e "${GREEN}All admin dashboard tests passed successfully!${NC}"
exit 0
else
echo -e "${RED}Some admin dashboard tests failed. Check the log file for details:${NC}"
echo -e "${YELLOW}$LOG_FILE${NC}"
exit 1
fi