1+ #! /bin/bash
2+
3+ # Navigation E2E Test Runner Script
4+ # Usage: ./scripts/test-navigation.sh [options]
5+
6+ set -e
7+
8+ # Colors for output
9+ RED=' \033[0;31m'
10+ GREEN=' \033[0;32m'
11+ YELLOW=' \033[1;33m'
12+ NC=' \033[0m' # No Color
13+
14+ # Default values
15+ HEADED=false
16+ DEBUG=false
17+ REPORTER=" list"
18+ GREP=" "
19+ BROWSER=" chromium"
20+
21+ # Function to display usage
22+ usage () {
23+ echo " Usage: $0 [OPTIONS]"
24+ echo " "
25+ echo " Options:"
26+ echo " -h, --headed Run tests in headed mode (show browser)"
27+ echo " -d, --debug Run tests in debug mode"
28+ echo " -r, --reporter TYPE Test reporter (list, html, json, junit)"
29+ echo " -g, --grep PATTERN Run only tests matching pattern"
30+ echo " -b, --browser NAME Browser to use (chromium, firefox, webkit)"
31+ echo " --help Show this help message"
32+ echo " "
33+ echo " Examples:"
34+ echo " $0 # Run all navigation tests"
35+ echo " $0 --headed # Run with browser UI visible"
36+ echo " $0 --grep \" Primary Navigation\" # Run only primary navigation tests"
37+ echo " $0 --reporter html # Generate HTML report"
38+ echo " $0 --debug --grep \" dropdown\" # Debug dropdown tests"
39+ }
40+
41+ # Parse command line arguments
42+ while [[ $# -gt 0 ]]; do
43+ case $1 in
44+ -h|--headed)
45+ HEADED=true
46+ shift
47+ ;;
48+ -d|--debug)
49+ DEBUG=true
50+ shift
51+ ;;
52+ -r|--reporter)
53+ REPORTER=" $2 "
54+ shift 2
55+ ;;
56+ -g|--grep)
57+ GREP=" $2 "
58+ shift 2
59+ ;;
60+ -b|--browser)
61+ BROWSER=" $2 "
62+ shift 2
63+ ;;
64+ --help)
65+ usage
66+ exit 0
67+ ;;
68+ * )
69+ echo -e " ${RED} Unknown option: $1 ${NC} "
70+ usage
71+ exit 1
72+ ;;
73+ esac
74+ done
75+
76+ # Build the playwright command
77+ PLAYWRIGHT_CMD=" npx playwright test --project=navigation"
78+
79+ if [ " $HEADED " = true ]; then
80+ PLAYWRIGHT_CMD=" $PLAYWRIGHT_CMD --headed"
81+ fi
82+
83+ if [ " $DEBUG " = true ]; then
84+ PLAYWRIGHT_CMD=" $PLAYWRIGHT_CMD --debug"
85+ fi
86+
87+ if [ -n " $GREP " ]; then
88+ PLAYWRIGHT_CMD=" $PLAYWRIGHT_CMD --grep \" $GREP \" "
89+ fi
90+
91+ if [ " $REPORTER " != " list" ]; then
92+ PLAYWRIGHT_CMD=" $PLAYWRIGHT_CMD --reporter=$REPORTER "
93+ fi
94+
95+ # Add browser selection
96+ PLAYWRIGHT_CMD=" $PLAYWRIGHT_CMD --browser=$BROWSER "
97+
98+ echo -e " ${YELLOW} Running Navigation E2E Tests...${NC} "
99+ echo -e " ${YELLOW} Command: $PLAYWRIGHT_CMD ${NC} "
100+ echo " "
101+
102+ # Check if the server is running
103+ if ! curl -s http://localhost:8002 > /dev/null 2>&1 ; then
104+ echo -e " ${RED} Warning: Development server not detected at http://localhost:8002${NC} "
105+ echo -e " ${YELLOW} Make sure to start the development server before running tests:${NC} "
106+ echo " python3 app.py"
107+ echo " "
108+ fi
109+
110+ # Run the tests
111+ eval $PLAYWRIGHT_CMD
112+
113+ # Check exit code
114+ if [ $? -eq 0 ]; then
115+ echo -e " ${GREEN} ✅ Navigation tests completed successfully!${NC} "
116+
117+ if [ " $REPORTER " = " html" ]; then
118+ echo -e " ${YELLOW} 📊 HTML report generated. Open playwright-report/index.html to view results.${NC} "
119+ fi
120+ else
121+ echo -e " ${RED} ❌ Navigation tests failed!${NC} "
122+ exit 1
123+ fi
0 commit comments