-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-networking.sh
More file actions
104 lines (88 loc) · 3.31 KB
/
Copy pathfix-networking.sh
File metadata and controls
104 lines (88 loc) · 3.31 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
#!/bin/bash
# Network Fix Script for Playwright + Docker on macOS
# This script attempts to resolve Docker networking issues for Playwright
echo "🔧 Fixing Playwright + Docker Networking Issues"
echo "==============================================="
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_status() {
echo -e "${BLUE}ℹ️ $1${NC}"
}
print_success() {
echo -e "${GREEN}✅ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}❌ $1${NC}"
}
# Method 1: Restart Docker with different networking
print_status "Method 1: Restarting Docker containers with fresh networking..."
docker-compose down
sleep 2
docker-compose up -d
# Wait for services to be ready
print_status "Waiting for services to be ready..."
sleep 10
# Method 2: Test connectivity
print_status "Method 2: Testing connectivity options..."
# Test localhost
if curl -s --connect-timeout 5 http://localhost:8080 >/dev/null; then
print_success "localhost:8080 is accessible"
WORDPRESS_URL="http://localhost:8080"
elif curl -s --connect-timeout 5 http://127.0.0.1:8080 >/dev/null; then
print_success "127.0.0.1:8080 is accessible"
WORDPRESS_URL="http://127.0.0.1:8080"
elif curl -s --connect-timeout 5 http://0.0.0.0:8080 >/dev/null; then
print_success "0.0.0.0:8080 is accessible"
WORDPRESS_URL="http://0.0.0.0:8080"
else
print_error "No WordPress URL is accessible"
exit 1
fi
# Method 3: Update Playwright config with working URL
print_status "Method 3: Updating Playwright configuration..."
if [ "$WORDPRESS_URL" != "http://127.0.0.1:8080" ]; then
print_status "Updating baseURL to: $WORDPRESS_URL"
# Create a backup
cp playwright.config.ts playwright.config.ts.backup
# Update the baseURL
sed -i '' "s|baseURL: 'http://127.0.0.1:8080'|baseURL: '$WORDPRESS_URL'|g" playwright.config.ts
print_success "Playwright config updated"
fi
# Method 4: Test with simple Playwright command
print_status "Method 4: Testing Playwright with a simple command..."
if npx playwright test --list >/dev/null 2>&1; then
print_success "Playwright can load test files"
else
print_error "Playwright has configuration issues"
fi
# Method 5: Add hosts file entry (requires sudo)
print_status "Method 5: Checking if we need to add hosts entry..."
if ! grep -q "127.0.0.1 wordpress.local" /etc/hosts 2>/dev/null; then
print_warning "Consider adding this to /etc/hosts: 127.0.0.1 wordpress.local"
print_warning "Run: echo '127.0.0.1 wordpress.local' | sudo tee -a /etc/hosts"
fi
# Final test
print_status "Running final connectivity test..."
if curl -s "$WORDPRESS_URL" | grep -q "BackWPUp E2E Test Site"; then
print_success "WordPress is accessible and working!"
echo ""
echo "🎯 Next Steps:"
echo "1. Try running: npx playwright test src/specs/wordpress-basic.spec.ts --timeout=60000"
echo "2. If still failing, try using the working URL: $WORDPRESS_URL"
echo "3. Consider running tests with --headed flag to see what's happening"
echo ""
echo "Alternative testing:"
echo "- Use ./alternative-test.sh for curl-based testing"
echo "- Use manual testing at: $WORDPRESS_URL/wp-admin"
else
print_error "WordPress is not responding correctly"
fi
echo ""
print_status "Network fix script completed!"