Skip to content

Bump lodash from 4.17.21 to 4.17.23 #1470

Bump lodash from 4.17.21 to 4.17.23

Bump lodash from 4.17.21 to 4.17.23 #1470

name: E2E Tests
on:
# make this workflow reusable and take in marketplace version as input
workflow_call:
inputs:
use-marketplace-version:
description: 'Should this use marketplace version of the plugin'
required: false
type: boolean
default: false
workflow_dispatch:
inputs:
use-marketplace-version:
description: 'Should this use marketplace version of the plugin'
required: false
type: boolean
default: false
pull_request:
branches: [ main, master, develop ]
schedule:
# Run daily at 8am UTC (only runs when required secrets are configured)
- cron: '0 8 * * *'
env:
# Test environment configuration
TEST_SITE_HOST: ${{ secrets.TEST_SITE_HOST }}
WORDPRESS_PATH: '/tmp/wordpress'
WP_DEBUG_LOG: '/tmp/wordpress/wp-content/debug.log'
WC_LOG_PATH: '/tmp/wordpress/wp-content/uploads/wc-logs/'
PLUGIN_PATH: '/tmp/wordpress/wp-content/plugins/facebook-for-woocommerce'
FB_E2E_TEST_COOKIE_NAME: 'facebook_test_id'
FB_E2E_LOGGER_PATH: '/tests/e2e/lib/Logger.php'
FB_E2E_CAPTURED_EVENTS_DIR: '/tests/e2e/captured-events'
WP_CUSTOMER_USERNAME: customer
WP_CUSTOMER_PASSWORD: Password@54321
WORDPRESS_URL: http://${{ secrets.TEST_SITE_HOST }}:8080
TEST_PRODUCT_URL: '/product/testp/'
TEST_CATEGORY_URL: '/product-category/uncategorized/'
TEST_FBCLID: 'IwAR123TestClickId456'
WP_USERNAME: admin
WP_PASSWORD: admin
PIXEL_EVENT_TIMEOUT: 30000
PAGE_LOAD_TIMEOUT: 120000
# Customer Billing/Shipping Address
WP_CUSTOMER_EMAIL: 'customer@test.com'
TEST_USER_FIRST_NAME: Test
TEST_USER_LAST_NAME: Customer
TEST_USER_ADDRESS_1: '123 Test Street'
TEST_USER_ADDRESS_2: ''
TEST_USER_CITY: 'San Francisco'
TEST_USER_STATE: CA
TEST_USER_POSTCODE: '94102'
TEST_USER_COUNTRY: US
TEST_USER_PHONE: '4155551234'
# Store Configuration
STORE_ADDRESS: '123 Test Street'
STORE_CITY: 'Test City'
STORE_COUNTRY: 'US:CA'
STORE_POSTCODE: '12345'
STORE_CURRENCY: USD
# Error Whitelist (pipe-separated list of allowed non-critical errors)
ERROR_WHITELIST: 'WC_Facebook_Google_Product_Category_Fields is not defined'
jobs:
# Job to check if secrets are configured and emit warning if not
check-secrets:
runs-on: ubuntu-latest
outputs:
secrets-configured: ${{ steps.check.outputs.configured }}
steps:
- name: Check if required secrets are configured
id: check
env:
TEST_SITE_HOST: ${{ secrets.TEST_SITE_HOST }}
FB_TEST_META_BUSINESS_ASSETS: ${{ secrets.FB_TEST_META_BUSINESS_ASSETS }}
EVENT_NAME: ${{ github.event_name }}
REPO_OWNER: ${{ github.repository_owner }}
run: |
if [ -n "$TEST_SITE_HOST" ] && [ -n "$FB_TEST_META_BUSINESS_ASSETS" ]; then
echo "configured=true" >> $GITHUB_OUTPUT
echo "✅ Required secrets are configured"
else
echo "configured=false" >> $GITHUB_OUTPUT
# Fail if this is a scheduled run on the facebook repository
if [ "$EVENT_NAME" = "schedule" ] && [ "$REPO_OWNER" = "facebook" ]; then
echo "::error title=E2E Tests Failed::Scheduled run on facebook repository but required secrets (TEST_SITE_HOST, FB_TEST_META_BUSINESS_ASSETS) are not configured."
exit 1
fi
echo "::warning title=E2E Tests Skipped::E2E tests require TEST_SITE_HOST and FB_TEST_META_BUSINESS_ASSETS secrets to be configured. After merge, E2E tests will run daily to validate functionality."
fi
e2e-tests:
needs: check-secrets
if: ${{ needs.check-secrets.outputs.secrets-configured == 'true' }}
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'npm'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mysqli, zip, gd, curl, dom, fileinfo, mbstring
ini-values: |
date.timezone=UTC
memory_limit=1024M
max_execution_time=300
- name: Configure hostname
run: |
# Add hosts entry for custom domain
echo "127.0.0.1 ${{ env.TEST_SITE_HOST }}" | sudo tee -a /etc/hosts
echo "✅ Added hosts entry for ${{ env.TEST_SITE_HOST }}"
- name: Create WordPress test environment
run: |
# Create WordPress directory
mkdir -p ${{ env.WORDPRESS_PATH }}
cd ${{ env.WORDPRESS_PATH }}
# Download WordPress
curl -O https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz --strip-components=1
# Create wp-config.php
cp wp-config-sample.php wp-config.php
sed -i "s/database_name_here/wordpress/" wp-config.php
sed -i "s/username_here/wordpress/" wp-config.php
sed -i "s/password_here/wordpress/" wp-config.php
sed -i "s/localhost/127.0.0.1/" wp-config.php
# Add debug and security settings
cat >> wp-config.php << 'EOF'
// Debug settings
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('error_log', '${{ env.WP_DEBUG_LOG }}');
@ini_set('log_errors', 'On');
// Security keys (for testing only)
define('AUTH_KEY', 'testing-key-1');
define('SECURE_AUTH_KEY', 'testing-key-2');
define('LOGGED_IN_KEY', 'testing-key-3');
define('NONCE_KEY', 'testing-key-4');
define('AUTH_SALT', 'testing-salt-1');
define('SECURE_AUTH_SALT', 'testing-salt-2');
define('LOGGED_IN_SALT', 'testing-salt-3');
define('NONCE_SALT', 'testing-salt-4');
EOF
- name: Wordpress debug log file setup
run: |
# Create debug.log file and make it writable
touch ${{ env.WP_DEBUG_LOG }}
chmod 777 ${{ env.WP_DEBUG_LOG }}
echo "✅ debug.log created and writable"
- name: WooCommerce logs directory setup
run: |
# Create WooCommerce logs directory and make it writable
mkdir -p ${{ env.WORDPRESS_PATH }}/wp-content/uploads/wc-logs
chmod 777 ${{ env.WORDPRESS_PATH }}/wp-content/uploads/wc-logs
echo "✅ wc-logs directory created and writable"
- name: Start PHP server
run: |
cd ${{ env.WORDPRESS_PATH }}
php -S 127.0.0.1:8080 -t . &
echo $! > /tmp/php-server.pid
sleep 5
echo "✅ PHP server started on port 8080"
- name: Install WP-CLI
run: |
echo "=== Installing WP-CLI ==="
curl -L -o wp-cli.phar https://github.com/wp-cli/wp-cli/releases/download/v2.10.0/wp-cli-2.10.0.phar
if head -1 wp-cli.phar | grep -q "#!/usr/bin/env php"; then
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
echo "✅ WP-CLI installed successfully"
else
echo "❌ Downloaded file is not valid PHP"
exit 1
fi
wp --version
- name: Install WordPress
run: |
cd ${{ env.WORDPRESS_PATH }}
wp core install \
--url=http://${{ env.TEST_SITE_HOST }}:8080 \
--title="E2E Test Site" \
--admin_user=admin \
--admin_password=admin \
--admin_email=test@example.com \
--allow-root
- name: Install WooCommerce
run: |
cd ${{ env.WORDPRESS_PATH }}
# Install Storefront theme (official WooCommerce theme with all hooks)
wp theme install storefront --activate --allow-root
echo "✅ Storefront theme installed and activated"
wp plugin install woocommerce --activate --allow-root
# Basic WooCommerce setup
wp option update woocommerce_store_address "${{ env.STORE_ADDRESS }}" --allow-root
wp option update woocommerce_store_city "${{ env.STORE_CITY }}" --allow-root
wp option update woocommerce_default_country "${{ env.STORE_COUNTRY }}" --allow-root
wp option update woocommerce_store_postcode "${{ env.STORE_POSTCODE }}" --allow-root
wp option update woocommerce_currency "${{ env.STORE_CURRENCY }}" --allow-root
# Make site live (disable "Coming Soon" mode)
wp option update woocommerce_coming_soon "no" --allow-root
wp option update woocommerce_store_pages_only "no" --allow-root
echo "✅ WooCommerce site set to LIVE mode"
# Enable Cash on Delivery payment gateway
wp option update woocommerce_cod_settings '{"enabled":"yes","title":"Cash on delivery","description":"Pay with cash upon delivery."}' --format=json --allow-root
echo "✅ Cash on Delivery payment gateway enabled"
- name: Verify WooCommerce setup
run: |
cd ${{ env.WORDPRESS_PATH }}
# Check if WooCommerce is active
if ! wp plugin list --status=active --allow-root | grep -q "woocommerce"; then
echo "❌ WooCommerce is not active"
exit 1
fi
echo "✅ WooCommerce is active"
# Verify WooCommerce endpoints
for endpoint in shop cart checkout; do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "http://${{ env.TEST_SITE_HOST }}:8080/$endpoint")
if [ "$STATUS" -lt 400 ]; then
echo "✅ /$endpoint endpoint exists (status: $STATUS)"
else
echo "❌ /$endpoint endpoint not found (status: $STATUS)"
fi
done
- name: Create wp non admin user
run: |
cd ${{ env.WORDPRESS_PATH }}
# Create a customer (non-admin) user for testing
# Pixel tracking excludes admin users by default!
# Note: customer role is created by WooCommerce, so this step must run AFTER WooCommerce installation
wp user create ${{ env.WP_CUSTOMER_USERNAME}} ${{ env.WP_CUSTOMER_EMAIL }} --role=customer --user_pass=${{ env.WP_CUSTOMER_PASSWORD }} --allow-root || echo "Customer user already exists"
# Grant read capability to customer role (for viewing products/categories)
# This ensures customer can see shop pages, products, and categories
wp cap add customer read --allow-root
# Get customer user ID once and store it
CUSTOMER_ID=$(wp user get ${{ env.WP_CUSTOMER_EMAIL }} --field=ID --allow-root)
echo "Customer User ID: $CUSTOMER_ID"
# Add billing address to customer user for comprehensive event testing
# This ensures address fields (ct, zp, country) are captured in Pixel/CAPI events
wp user meta update $CUSTOMER_ID billing_first_name "${{ env.TEST_USER_FIRST_NAME }}" --allow-root
wp user meta update $CUSTOMER_ID billing_last_name "${{ env.TEST_USER_LAST_NAME }}" --allow-root
wp user meta update $CUSTOMER_ID billing_company "" --allow-root
wp user meta update $CUSTOMER_ID billing_address_1 "${{ env.TEST_USER_ADDRESS_1 }}" --allow-root
wp user meta update $CUSTOMER_ID billing_address_2 "${{ env.TEST_USER_ADDRESS_2 }}" --allow-root
wp user meta update $CUSTOMER_ID billing_city "${{ env.TEST_USER_CITY }}" --allow-root
wp user meta update $CUSTOMER_ID billing_state "${{ env.TEST_USER_STATE }}" --allow-root
wp user meta update $CUSTOMER_ID billing_postcode "${{ env.TEST_USER_POSTCODE }}" --allow-root
wp user meta update $CUSTOMER_ID billing_country "${{ env.TEST_USER_COUNTRY }}" --allow-root
wp user meta update $CUSTOMER_ID billing_email "${{ env.WP_CUSTOMER_EMAIL }}" --allow-root
wp user meta update $CUSTOMER_ID billing_phone "${{ env.TEST_USER_PHONE }}" --allow-root
# Set shipping address same as billing (WooCommerce stores them separately)
wp user meta update $CUSTOMER_ID shipping_first_name "${{ env.TEST_USER_FIRST_NAME }}" --allow-root
wp user meta update $CUSTOMER_ID shipping_last_name "${{ env.TEST_USER_LAST_NAME }}" --allow-root
wp user meta update $CUSTOMER_ID shipping_company "" --allow-root
wp user meta update $CUSTOMER_ID shipping_address_1 "${{ env.TEST_USER_ADDRESS_1 }}" --allow-root
wp user meta update $CUSTOMER_ID shipping_address_2 "${{ env.TEST_USER_ADDRESS_2 }}" --allow-root
wp user meta update $CUSTOMER_ID shipping_city "${{ env.TEST_USER_CITY }}" --allow-root
wp user meta update $CUSTOMER_ID shipping_state "${{ env.TEST_USER_STATE }}" --allow-root
wp user meta update $CUSTOMER_ID shipping_postcode "${{ env.TEST_USER_POSTCODE }}" --allow-root
wp user meta update $CUSTOMER_ID shipping_country "${{ env.TEST_USER_COUNTRY }}" --allow-root
echo "✅ Customer user created with billing and shipping address"
# Verify billing address was set correctly
echo "=== Verifying Billing Address ==="
echo "City: $(wp user meta get $CUSTOMER_ID billing_city --allow-root)"
echo "State: $(wp user meta get $CUSTOMER_ID billing_state --allow-root)"
echo "Postcode: $(wp user meta get $CUSTOMER_ID billing_postcode --allow-root)"
echo "Country: $(wp user meta get $CUSTOMER_ID billing_country --allow-root)"
echo "Email: $(wp user meta get $CUSTOMER_ID billing_email --allow-root)"
- name: Install WPC Composite Products plugin
run: |
cd ${{ env.WORDPRESS_PATH }}
wp plugin install wpc-composite-products --activate --allow-root
- name: Check logs baseline (before plugin activation)
run: |
TODAY=$(date +%Y-%m-%d)
# Find WC log file
WC_LOG_FILE=$(find "${{ env.WORDPRESS_PATH }}/wp-content/uploads/wc-logs/" -name "facebook_for_woocommerce-${TODAY}*.log" -type f 2>/dev/null | head -1)
# Check WC log if exists
if [ -n "$WC_LOG_FILE" ]; then
echo "🔍 Checking WC log: $WC_LOG_FILE for errors..."
NON_200=$(grep "code: " "$WC_LOG_FILE" | grep -v "code: 200" || true)
if [ -n "$NON_200" ]; then
echo "❌ FAIL: Found non-200 codes in $WC_LOG_FILE:"
echo "$NON_200"
exit 1
fi
fi
# Check debug.log
echo "🔍 Checking debug.log: ${{ env.WP_DEBUG_LOG }} for errors..."
ERRORS=$(grep -i "fatal\|error" "${{ env.WP_DEBUG_LOG }}" | grep -v "Cron reschedule event error" || true)
if [ -n "$ERRORS" ]; then
echo "❌ FAIL: Found errors in ${{ env.WP_DEBUG_LOG }}:"
echo "$ERRORS"
exit 1
fi
echo "✅ PASS: No errors found in logs"
- name: Select Meta Business Assets
run: |
# Parse the JSON array of business assets
ASSETS='${{ secrets.FB_TEST_META_BUSINESS_ASSETS }}'
# Get the array length
ARRAY_LENGTH=$(echo "$ASSETS" | jq 'length')
echo "Total available business asset sets: $ARRAY_LENGTH"
# Use run_number as selector - it's sequential (1, 2, 3, ...) across all workflow runs
# This ensures each concurrent run gets a different business asset set
SELECTOR="${{ github.run_number }}"
echo "Using GitHub Run Number as selector: $SELECTOR"
# Calculate index using modulo
INDEX=$((SELECTOR % ARRAY_LENGTH))
echo "Selected asset set index: $INDEX"
# Extract the selected asset set
SELECTED_ASSET=$(echo "$ASSETS" | jq -c ".[$INDEX]")
# Extract values into variables
ACCESS_TOKEN=$(echo "$SELECTED_ASSET" | jq -r '.wc_facebook_access_token')
BUSINESS_MANAGER_ID=$(echo "$SELECTED_ASSET" | jq -r '.wc_facebook_business_manager_id')
EXTERNAL_BUSINESS_ID=$(echo "$SELECTED_ASSET" | jq -r '.wc_facebook_external_business_id')
PRODUCT_CATALOG_ID=$(echo "$SELECTED_ASSET" | jq -r '.wc_facebook_product_catalog_id')
PIXEL_ID=$(echo "$SELECTED_ASSET" | jq -r '.wc_facebook_pixel_id')
PAGE_ID=$(echo "$SELECTED_ASSET" | jq -r '.wc_facebook_page_id')
# Mask all sensitive values to prevent them from appearing in logs
echo "::add-mask::$ACCESS_TOKEN"
echo "::add-mask::$BUSINESS_MANAGER_ID"
echo "::add-mask::$EXTERNAL_BUSINESS_ID"
echo "::add-mask::$PRODUCT_CATALOG_ID"
echo "::add-mask::$PIXEL_ID"
echo "::add-mask::$PAGE_ID"
# Set environment variables for subsequent steps
echo "FB_ACCESS_TOKEN=$ACCESS_TOKEN" >> $GITHUB_ENV
echo "FB_BUSINESS_MANAGER_ID=$BUSINESS_MANAGER_ID" >> $GITHUB_ENV
echo "FB_EXTERNAL_BUSINESS_ID=$EXTERNAL_BUSINESS_ID" >> $GITHUB_ENV
echo "FB_PRODUCT_CATALOG_ID=$PRODUCT_CATALOG_ID" >> $GITHUB_ENV
echo "FB_PIXEL_ID=$PIXEL_ID" >> $GITHUB_ENV
echo "FB_PAGE_ID=$PAGE_ID" >> $GITHUB_ENV
echo "✅ Selected business asset set $INDEX for this run"
- name: Install Facebook for WooCommerce plugin
run: |
cd ${{ env.WORDPRESS_PATH }}
# Use marketplace version if flag is true
if [ "${{ inputs.use-marketplace-version }}" = "true" ]; then
echo "Installing Facebook for WooCommerce from wordpress.org marketplace"
wp plugin install facebook-for-woocommerce --version=dev --allow-root
else
echo "Installing Facebook for WooCommerce from local workspace"
# Copy plugin files from the checked out repository root
cp -r ${{ github.workspace }} wp-content/plugins/facebook-for-woocommerce/
# Install Composer dependencies for the plugin
cd ${{ env.PLUGIN_PATH }}
if [ -f composer.json ]; then
composer install --no-dev --optimize-autoloader
fi
cd ${{ env.WORDPRESS_PATH }}
fi
# Configure Facebook connection before activation using selected business assets
wp option update wc_facebook_access_token "${{ env.FB_ACCESS_TOKEN }}" --allow-root
wp option update wc_facebook_merchant_access_token "${{ env.FB_ACCESS_TOKEN }}" --allow-root
wp option update wc_facebook_business_manager_id "${{ env.FB_BUSINESS_MANAGER_ID }}" --allow-root
wp option update wc_facebook_external_business_id "${{ env.FB_EXTERNAL_BUSINESS_ID }}" --allow-root
wp option update wc_facebook_product_catalog_id "${{ env.FB_PRODUCT_CATALOG_ID }}" --allow-root
wp option update wc_facebook_pixel_id "${{ env.FB_PIXEL_ID }}" --allow-root
wp option update wc_facebook_page_id "${{ env.FB_PAGE_ID }}" --allow-root
wp option update wc_facebook_enable_server_to_server "yes" --allow-root
wp option update wc_facebook_enable_pixel "yes" --allow-root
wp option update wc_facebook_enable_advanced_matching "yes" --allow-root
wp option update wc_facebook_debug_mode yes --allow-root
wp option update wc_facebook_enable_debug_mode yes --allow-root
wp option update wc_facebook_has_connected_fbe_2 "yes" --allow-root
wp option update wc_facebook_has_authorized_pages_read_engagement "yes" --allow-root
wp option update wc_facebook_enable_product_sync "yes" --allow-root
# Activate the plugin (this triggers automatic sync)
wp plugin activate facebook-for-woocommerce --allow-root
- name: Verify no new errors after plugin activation
run: |
TODAY=$(date +%Y-%m-%d)
# Find WC log file
WC_LOG_FILE=$(find "${{ env.WORDPRESS_PATH }}/wp-content/uploads/wc-logs/" -name "facebook_for_woocommerce-${TODAY}*.log" -type f 2>/dev/null | head -1)
# Check WC log if exists
if [ -n "$WC_LOG_FILE" ]; then
echo "🔍 Checking WC log: $WC_LOG_FILE for errors..."
NON_200=$(grep "code: " "$WC_LOG_FILE" | grep -v "code: 200" || true)
if [ -n "$NON_200" ]; then
echo "❌ FAIL: Found non-200 codes in $WC_LOG_FILE:"
echo "$NON_200"
exit 1
fi
fi
# Check debug.log
echo "🔍 Checking debug.log: ${{ env.WP_DEBUG_LOG }} for errors..."
ERRORS=$(grep -i "fatal\|error" "${{ env.WP_DEBUG_LOG }}" | grep -v "Cron reschedule event error" || true)
if [ -n "$ERRORS" ]; then
echo "❌ FAIL: Found errors in ${{ env.WP_DEBUG_LOG }}:"
echo "$ERRORS"
exit 1
fi
echo "✅ PASS: No errors found in logs"
- name: Initialize rollout switches for E2E tests
run: |
cd ${{ env.WORDPRESS_PATH }}
# Force initialize rollout switches - this would normally happen on heartbeat
wp eval "
if (function_exists('facebook_for_woocommerce')) {
\$plugin = facebook_for_woocommerce();
\$rollout_switches = \$plugin->get_rollout_switches();
\$rollout_switches->init();
echo '✅ Rollout switches initialized' . PHP_EOL;
}" --allow-root
# Manually enable CAPI event logging for E2E tests
# This is required for test event capture to work
wp eval "
\$switches = get_option('wc_facebook_for_woocommerce_rollout_switches', []);
\$switches['enable_woocommerce_capi_event_logging'] = 'yes';
update_option('wc_facebook_for_woocommerce_rollout_switches', \$switches);
echo '✅ CAPI event logging enabled for E2E tests' . PHP_EOL;
" --allow-root
- name: Verify WordPress setup
run: |
cd ${{ env.WORDPRESS_PATH }}
echo "=== WordPress Info ==="
wp core version --allow-root
echo "=== Active Plugins ==="
wp plugin list --status=active --allow-root
echo "=== Site URL ==="
wp option get siteurl --allow-root
# Test if site is accessible
curl -f http://${{ env.TEST_SITE_HOST }}:8080 || exit 1
- name: Verify Facebook for WooCommerce setup
run: |
cd ${{ env.WORDPRESS_PATH }}
echo "=== Facebook for WooCommerce Info ==="
wp eval "
if (function_exists('facebook_for_woocommerce')) {
\$connection = facebook_for_woocommerce()->get_connection_handler();
if (!\$connection->is_connected()) {
echo '❌ Facebook plugin is NOT connected' . PHP_EOL;
exit(1);
}
echo 'Connected: YES' . PHP_EOL;
echo 'Access Token: ' . (\$connection->get_access_token() ? 'Present' : 'Missing') . PHP_EOL;
echo 'External Business ID: ' . \$connection->get_external_business_id() . PHP_EOL;
echo 'Business Manager ID: ' . \$connection->get_business_manager_id() . PHP_EOL;
echo 'Pixel ID: ' . get_option('wc_facebook_pixel_id') . PHP_EOL;
echo 'Pixel Enabled: ' . get_option('wc_facebook_enable_pixel') . PHP_EOL;
echo 'S2S Enabled: ' . get_option('wc_facebook_enable_server_to_server') . PHP_EOL;
echo 'Debug Mode: ' . get_option('wc_facebook_debug_mode') . PHP_EOL;
} else {
echo '❌ Facebook plugin not loaded properly' . PHP_EOL;
exit(1);
}" --allow-root
# VERIFY wp-config.php has debug settings
echo "=== Verifying wp-config.php Debug Settings ==="
if grep -q "WP_DEBUG.*true" wp-config.php; then
echo "✅ WP_DEBUG is enabled"
else
echo "❌ WP_DEBUG is NOT enabled!"
exit 1
fi
- name: Install Playwright
run: |
# Install in the WordPress plugin directory (where we'll run tests from)
cd ${{ env.PLUGIN_PATH }}
npm install
npx playwright install chromium
npx playwright install-deps chromium
- name: Setup captured-events directory
run: |
mkdir -p ${{ env.PLUGIN_PATH }}/tests/e2e/captured-events
chmod 777 ${{ env.PLUGIN_PATH }}/tests/e2e/captured-events
- name: Create test product for CAPI Pixel E2E tests
run: |
cd ${{ env.WORDPRESS_PATH }}
# Create test product for ViewContent/AddToCart tests
PRODUCT_ID=$(wp eval "
\$product = new WC_Product_Simple();
\$product->set_name('TestP');
\$product->set_slug('testp');
\$product->set_regular_price('19.99');
\$product->set_description('Test product for E2E tests');
\$product->set_status('publish');
\$product->set_catalog_visibility('visible');
\$product->set_stock_status('instock');
\$product->set_manage_stock(false);
\$product_id = \$product->save();
wp_set_object_terms(\$product_id, 'uncategorized', 'product_cat');
echo \$product_id;
" --allow-root)
echo "TEST_PRODUCT_ID=$PRODUCT_ID" >> $GITHUB_ENV
echo "✅ Test product created. ID: $PRODUCT_ID"
- name: Install Xvfb for headed browser
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- name: Run Plugin level tests (sequential)
run: |
cd ${{ env.PLUGIN_PATH }}
npx playwright test plugin-level-tests.spec.js --project=chromium-wp-admin --workers=1
- name: Run CAPI Pixel E2E tests (sequential)
run: |
cd ${{ env.PLUGIN_PATH }}
xvfb-run --auto-servernum npx playwright test events-test.spec.js --headed --project=chromium-wp-customer --workers=1
- name: Cleanup test product
if: always()
run: |
cd ${{ env.WORDPRESS_PATH }}
if [ -n "${{ env.TEST_PRODUCT_ID }}" ]; then
wp post delete ${{ env.TEST_PRODUCT_ID }} --force --allow-root
echo "✅ Test product ${{ env.TEST_PRODUCT_ID }} deleted"
else
echo "ℹ️ No test product to delete"
fi
- name: Run Product CRUD tests (parallel)
run: |
cd ${{ env.PLUGIN_PATH }}
npx playwright test "product-(creation|modification|deletion).spec.js" --project=chromium-wp-admin --workers=2
- name: Run Product Batch tests (sequential)
run: |
cd ${{ env.PLUGIN_PATH }}
npx playwright test product-batch.spec.js --project=chromium-wp-admin --workers=1
- name: Run Product Category tests (sequential)
run: |
cd ${{ env.PLUGIN_PATH }}
npx playwright test product-category.spec.js --project=chromium-wp-admin --workers=1
- name: Disconnect from catalog
if: always()
run: |
cd ${{ env.WORDPRESS_PATH }}
wp eval "
if (function_exists('facebook_for_woocommerce')) {
\$connection = facebook_for_woocommerce()->get_connection_handler();
if (\$connection->is_connected()) {
\$connection->disconnect();
echo '✅ Disconnected from catalog' . PHP_EOL;
} else {
echo 'ℹ️ Already disconnected' . PHP_EOL;
}
}" --allow-root
- name: Verify disconnection
if: always()
run: |
cd ${{ env.WORDPRESS_PATH }}
wp eval "
if (function_exists('facebook_for_woocommerce')) {
\$connection = facebook_for_woocommerce()->get_connection_handler();
if (\$connection->is_connected()) {
echo '❌ Still connected' . PHP_EOL;
exit(1);
}
echo '✅ Verified disconnected' . PHP_EOL;
}" --allow-root
- name: Check for PHP errors, and dump debug log
if: always()
run: |
if [ -f ${{ env.WP_DEBUG_LOG }} ]; then
# Capture PHP errors in a variable (excluding WordPress cron warnings)
PHP_ERRORS=$(grep -i "fatal\|error" ${{ env.WP_DEBUG_LOG }} | grep -v "Cron reschedule event error for hook: facebook_for_woocommerce_5_minute_heartbeat_cron" || true)
if [ -n "$PHP_ERRORS" ]; then
echo "❌ PHP errors detected:"
echo "$PHP_ERRORS"
exit 1
else
echo "✅ No critical PHP errors found"
fi
else
echo "✅ No debug log found - no PHP errors"
fi
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: ${{ env.PLUGIN_PATH }}/playwright-report/
retention-days: 7
- name: Upload captured events
uses: actions/upload-artifact@v4
if: always()
with:
name: CAPI Pixel Captured events
path: ${{ env.PLUGIN_PATH }}${{ env.FB_E2E_CAPTURED_EVENTS_DIR }}
retention-days: 7
- name: Cleanup captured events directory
if: always()
run: |
TARGET_DIR="${{ env.PLUGIN_PATH }}${{ env.FB_E2E_CAPTURED_EVENTS_DIR }}"
if [ -d "$TARGET_DIR" ]; then
rm -rf "$TARGET_DIR"
echo "✅ Deleted captured events directory: $TARGET_DIR"
else
echo "ℹ️ Captured events directory not found: $TARGET_DIR"
fi
- name: Upload PHP logs
uses: actions/upload-artifact@v4
if: always()
with:
name: php-debug-logs
path: ${{ env.WP_DEBUG_LOG }}
retention-days: 7
- name: Upload WooCommerce logs
uses: actions/upload-artifact@v4
if: always()
with:
name: woocommerce-logs
path: ${{ env.WORDPRESS_PATH }}/wp-content/uploads/wc-logs/facebook_for_woocommerce-*.log
retention-days: 7
- name: Upload test videos/screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-failures
path: ${{ env.PLUGIN_PATH }}/test-results/
retention-days: 7