????JFIF??x?x????'403WebShell
403Webshell
Server IP : 104.21.64.1  /  Your IP : 216.73.216.243
Web Server : LiteSpeed
System : Linux premium151.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : tempvsty ( 647)
PHP Version : 8.0.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/./././self/cwd/wp-content/plugins/elementor/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/./././self/cwd/wp-content/plugins/elementor/scripts/setup-testing.sh
#!/bin/bash

# Elementor Testing Environment Setup Script
# Usage: npm run setup:testing [--restart]

set -e  # Exit on any error

# Check if restart flag is provided
RESTART_MODE=false
if [[ "$1" == "--restart" ]]; then
    RESTART_MODE=true
    echo "๐Ÿ”„ Restarting Elementor Testing Environment..."
else
    echo "๐Ÿš€ Setting up Elementor Testing Environment..."
fi

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

# Function to print colored output
print_status() {
    echo -e "${GREEN}โœ… $1${NC}"
}

print_warning() {
    echo -e "${YELLOW}โš ๏ธ  $1${NC}"
}

print_error() {
    echo -e "${RED}โŒ $1${NC}"
}

# Check prerequisites
echo "๐Ÿ” Checking prerequisites..."

# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
    print_error "Docker is not running. Please start Docker Desktop and try again."
    exit 1
fi
print_status "Docker is running"

# Check if Node.js is installed
if ! command -v node > /dev/null 2>&1; then
    print_error "Node.js is not installed. Please install Node.js 16+ and try again."
    exit 1
fi
print_status "Node.js is installed ($(node --version))"

# Check if npm is installed
if ! command -v npm > /dev/null 2>&1; then
    print_error "npm is not installed. Please install npm and try again."
    exit 1
fi
print_status "npm is installed ($(npm --version))"

# Create .env file if it doesn't exist
echo "๐Ÿ“ Setting up environment configuration..."
if [ ! -f .env ]; then
    cat > .env << EOF
# WordPress Admin Credentials
USERNAME=admin
PASSWORD=password

# WordPress URLs for testing
BASE_URL=http://localhost:8888
ELEMENTS_REGRESSION_BASE_URL=http://localhost:8889

# Test Configuration
TEST_PARALLEL_INDEX=0

# Optional: Elementor Experiments (uncomment to enable)
# ELEMENTOR_SHOW_HIDDEN_EXPERIMENTS=true

# Optional: Debug Settings (uncomment to enable)
# SCRIPT_DEBUG=true
# WP_DEBUG=true
EOF
    print_status "Created .env file with default configuration"
else
    print_warning ".env file already exists, skipping creation"
fi

# Install npm dependencies
echo "๐Ÿ“ฆ Installing dependencies..."
npm install
print_status "Dependencies installed"

# Clean up any existing containers (always do this for both modes)
echo "๐Ÿงน Cleaning up existing containers..."
docker stop $(docker ps -q) 2>/dev/null || true
docker rm $(docker ps -aq) 2>/dev/null || true

# Clean storage state files if restarting
if [ "$RESTART_MODE" = true ]; then
    rm -f test-results/.storageState-*.json
    print_status "Cleaned up containers and storage"
else
    print_status "Cleaned up existing containers"
fi

# Start WordPress environment
echo "๐ŸŒ Starting WordPress environment..."
npm run start-local-server
print_status "WordPress environment started"

# Wait for WordPress to be ready
echo "โณ Waiting for WordPress to be ready..."
sleep 10

# Check if WordPress is accessible
max_attempts=30
attempt=1
while [ $attempt -le $max_attempts ]; do
    if curl -f http://localhost:8888 > /dev/null 2>&1; then
        break
    fi
    echo "Attempt $attempt/$max_attempts: WordPress not ready yet, waiting..."
    sleep 2
    attempt=$((attempt + 1))
done

if [ $attempt -gt $max_attempts ]; then
    print_error "WordPress failed to start after $max_attempts attempts"
    exit 1
fi

print_status "WordPress is accessible"

# Clean WordPress content
echo "๐Ÿงน Cleaning WordPress content..."
docker exec port8888-cli-1 wp post delete $(docker exec port8888-cli-1 wp post list --post_type=post --format=ids) --force 2>/dev/null || true
docker exec port8888-cli-1 wp post delete $(docker exec port8888-cli-1 wp post list --post_type=page --format=ids) --force 2>/dev/null || true
docker exec port8888-cli-1 wp comment delete $(docker exec port8888-cli-1 wp comment list --format=ids) --force 2>/dev/null || true

docker exec port8889-cli-1 wp post delete $(docker exec port8889-cli-1 wp post list --post_type=post --format=ids) --force 2>/dev/null || true
docker exec port8889-cli-1 wp post delete $(docker exec port8889-cli-1 wp post list --post_type=page --format=ids) --force 2>/dev/null || true
docker exec port8889-cli-1 wp comment delete $(docker exec port8889-cli-1 wp comment list --format=ids) --force 2>/dev/null || true

print_status "WordPress content cleaned"

# Install/Fix Elementor plugin
echo "๐Ÿ”Œ Setting up Elementor plugin..."

# Always try to fix mount issues by downloading stable version
print_warning "Ensuring Elementor is properly installed..."
curl -L -o /tmp/elementor.zip https://downloads.wordpress.org/plugin/elementor.latest-stable.zip
unzip -q /tmp/elementor.zip -d /tmp/
rm -rf build/*
cp -r /tmp/elementor/* build/
rm -rf /tmp/elementor.zip /tmp/elementor

# Activate the plugin
docker exec port8888-cli-1 wp plugin activate elementor 2>/dev/null || docker exec port8888-cli-1 wp plugin install elementor --activate
docker exec port8889-cli-1 wp plugin activate elementor 2>/dev/null || docker exec port8889-cli-1 wp plugin install elementor --activate

print_status "Elementor plugin installed and activated"

# Verify setup
echo "๐Ÿ” Verifying setup..."

# Check WordPress accessibility
if ! curl -f http://localhost:8888 > /dev/null 2>&1; then
    print_error "WordPress on port 8888 is not accessible"
    exit 1
fi

if ! curl -f http://localhost:8889 > /dev/null 2>&1; then
    print_error "WordPress on port 8889 is not accessible"
    exit 1
fi

# Check Elementor plugin
if ! docker exec port8888-cli-1 wp plugin list | grep -q "elementor.*active"; then
    print_error "Elementor plugin is not active on port 8888"
    exit 1
fi

if ! docker exec port8889-cli-1 wp plugin list | grep -q "elementor.*active"; then
    print_error "Elementor plugin is not active on port 8889"
    exit 1
fi

print_status "Setup verification completed successfully"

echo ""
echo "๐ŸŽ‰ Elementor Testing Environment Setup Complete!"
echo ""
echo "๐Ÿ“‹ What's been set up:"
echo "   โ€ข WordPress running on http://localhost:8888 and http://localhost:8889"
echo "   โ€ข Admin credentials: admin / password"
echo "   โ€ข Elementor plugin installed and activated"
echo "   โ€ข Environment configured for testing"
echo ""
echo "๐Ÿš€ Next steps:"
echo "   โ€ข Run tests: npm run test:elements-regression"
echo "   โ€ข Run Playwright tests: npm run test:playwright"
echo "   โ€ข View setup guide: cat TESTING_SETUP.md"
echo ""
echo "๐Ÿ› ๏ธ  Useful commands:"
echo "   โ€ข Clean restart: npm run restart:testing"
echo "   โ€ข Start environment: npm run start-local-server"
echo "   โ€ข View setup guide: cat TESTING_SETUP.md"
echo ""

Youez - 2016 - github.com/yon3zu
LinuXploit