Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/product-creation-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Product Creation E2E Tests
name: Product Creation E2E Tests (Set 1)

on:
# make this workflow reusable and take in marketplace version as input
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
WORDPRESS_URL: http://localhost:8080
WP_USERNAME: admin
WP_PASSWORD: admin
run: npm run test:e2e
run: npm run test:e2e:set1

- name: Check for PHP errors
if: always()
Expand Down
251 changes: 251 additions & 0 deletions .github/workflows/product-modification-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
name: Product Modification 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 ]

jobs:
e2e-tests:
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, imagick, fileinfo, mbstring

- name: Create WordPress test environment
run: |
# Create WordPress directory
mkdir -p /tmp/wordpress
cd /tmp/wordpress

# 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);

// 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: Start PHP server
run: |
cd /tmp/wordpress
php -S localhost:8080 -t . &
echo $! > /tmp/php-server.pid
sleep 5

- 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 /tmp/wordpress
wp core install \
--url=http://localhost:8080 \
--title="E2E Test Site" \
--admin_user=admin \
--admin_password=admin \
[email protected] \
--allow-root

- name: Install WooCommerce
run: |
cd /tmp/wordpress
wp plugin install woocommerce --activate --allow-root

# Basic WooCommerce setup
wp option update woocommerce_store_address "123 Test Street" --allow-root
wp option update woocommerce_store_city "Test City" --allow-root
wp option update woocommerce_default_country "US:CA" --allow-root
wp option update woocommerce_store_postcode "12345" --allow-root
wp option update woocommerce_currency "USD" --allow-root

- name: Install Facebook for WooCommerce plugin
run: |
cd /tmp/wordpress

# 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 wp-content/plugins/facebook-for-woocommerce
if [ -f composer.json ]; then
composer install --no-dev --optimize-autoloader
fi
cd /tmp/wordpress
fi

# Configure Facebook connection before activation
wp option update wc_facebook_access_token "${{ secrets.FB_ACCESS_TOKEN }}" --allow-root
wp option update wc_facebook_merchant_access_token "${{ secrets.FB_ACCESS_TOKEN }}" --allow-root
wp option update wc_facebook_business_manager_id "${{ secrets.FB_BUSINESS_MANAGER_ID }}" --allow-root
wp option update wc_facebook_external_business_id "${{ secrets.FB_EXTERNAL_BUSINESS_ID }}" --allow-root
wp option update wc_facebook_product_catalog_id "${{ secrets.FB_PRODUCT_CATALOG_ID }}" --allow-root
wp option update wc_facebook_pixel_id "${{ secrets.FB_PIXEL_ID }}" --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
wp option update wc_facebook_page_id "${{ secrets.FB_PAGE_ID }}" --allow-root
# Activate the plugin (this triggers automatic sync)
wp plugin activate facebook-for-woocommerce --allow-root


- name: Verify WordPress setup
run: |
cd /tmp/wordpress
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://localhost:8080 || exit 1

- name: Verify Facebook for WooCommerce setup
run: |
cd /tmp/wordpress
echo "=== Facebook for WooCommerce Info ==="
wp eval "
if (function_exists('facebook_for_woocommerce')) {
\$connection = facebook_for_woocommerce()->get_connection_handler();
echo 'Connected: ' . (\$connection->is_connected() ? 'YES' : 'NO') . 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;
} else {
echo 'Facebook plugin not loaded properly';
}" --allow-root

- name: Install Playwright
run: |
npm install
npx playwright install chromium

- name: Run E2E tests
env:
WORDPRESS_URL: http://localhost:8080
WP_USERNAME: admin
WP_PASSWORD: admin
run: npm run test:e2e:set2

- name: Check for PHP errors
if: always()
run: |
cd /tmp/wordpress
if [ -f wp-content/debug.log ]; then
echo "=== PHP Debug Log ==="
cat wp-content/debug.log
if grep -i "fatal\|error\|warning" wp-content/debug.log; then
echo "❌ PHP errors detected"
exit 1
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-modification
path: playwright-report/
retention-days: 7

- name: Upload PHP logs
uses: actions/upload-artifact@v4
if: always()
with:
name: php-debug-logs-modification
path: /tmp/wordpress/wp-content/debug.log
retention-days: 7

- name: Upload test videos/screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-failures-modification
path: test-results/
retention-days: 7
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"test:php": "composer test-unit",
"test:js": "jest",
"test:e2e": "playwright test",
"test:e2e:set1": "playwright test product-creation.spec.js --grep-invert \"deactivation and reactivation\"",
"test:e2e:set2": "playwright test product-modification.spec.js product-creation.spec.js --grep \"deactivation and reactivation\"",
"test:e2e:ui": "playwright test --ui",
"test:e2e:debug": "playwright test --debug"
},
Expand Down
Loading