#!/bin/bash # Script to disable Breeze cache for testing environments # This creates an mu-plugin that sets DONOTCACHEPAGE constant SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" # Source environment variables if [ -f "$PROJECT_ROOT/.env" ]; then source "$PROJECT_ROOT/.env" fi # Check for required environment variables if [ -z "$UPSKILL_STAGING_SSH_USER" ] || [ -z "$UPSKILL_STAGING_PASS" ] || [ -z "$UPSKILL_STAGING_IP" ] || [ -z "$UPSKILL_STAGING_PATH" ]; then echo "Error: Missing required environment variables." echo "Please ensure the following are set in your .env file:" echo " - UPSKILL_STAGING_SSH_USER" echo " - UPSKILL_STAGING_PASS" echo " - UPSKILL_STAGING_IP" echo " - UPSKILL_STAGING_PATH" exit 1 fi echo "Creating mu-plugin to disable Breeze cache for testing..." # Create the mu-plugin content MU_PLUGIN_CONTENT=' wp-content/mu-plugins/disable-breeze-for-tests.php << 'EOF' $MU_PLUGIN_CONTENT EOF" # Verify the file was created echo "Verifying mu-plugin creation..." FILE_EXISTS=$(sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ "cd ${UPSKILL_STAGING_PATH} && [ -f wp-content/mu-plugins/disable-breeze-for-tests.php ] && echo 'exists' || echo 'not found'") if [ "$FILE_EXISTS" = "exists" ]; then echo "✅ Successfully created mu-plugin to disable Breeze cache for testing" echo "The following conditions will disable cache:" echo " - WP_ENV environment variable is set to 'testing'" echo " - WP_TESTS_DOMAIN constant is defined" echo " - User agent contains 'Playwright'" echo " - URL has 'no_cache_test' query parameter" echo " - URL contains '/manage-event/'" else echo "❌ Failed to create mu-plugin" exit 1 fi # Clear existing cache echo "Clearing existing Breeze cache..." $SCRIPT_DIR/clear-breeze-cache.sh echo "✅ Breeze cache setup for testing complete"