Files
Geoff TaylorandGitHub 460b101b47 fix: HPOS order mutation data loss, COT cursor pagination, email tests, checkout auth (#1003)
* devops: WC email template tests, COT cursor HPOS fix, checkout account auth

WC Email Template Tests:
- Add WooCommerceEmailTemplatesTest verifying WC email templates are used
  for registerCustomer, checkout with account creation, and password reset
- Use MockPHPMailer to capture emails and verify HTML content type
- Disable deferred transactional emails during tests via GRAPHQL_TESTING flag

COT Cursor HPOS Fix:
- Fix COT_Cursor::compare_with to resolve orderby aliases and legacy meta
  keys (_order_total, _date_completed, etc.) to COT column names
- Add resolve_orderby_alias() mapping short aliases and meta keys to columns
- Add DB_Hooks::clean_query_vars to translate post_* and meta_key orderby
  to COT-compatible equivalents via woocommerce_order_query_args filter

Checkout Account Authentication:
- Add authenticate field to CreateAccountInput type
- Gate wc_set_customer_auth_cookie() behind authenticate flag in checkout
  mutation so account creation doesn't auto-authenticate by default

Closes #882

* devops: codeception.dist.yml updated

* fix: Functional test cleanup and CI coverage condition

Test fixes:
- Enable authorizing URL fields in ProtectedRouterCest and
  DownloadableItemAuthCest via setWooGraphQLSetting
- Add stale data cleanup (sessions, users, products, orders) to
  GraphQLE2E _setupStore/getCatalog/setupStoreAndUsers
- Fix CartTransactionQueueCest and CartQueriesTest for test isolation

CI:
- Only run coverage job when at least one upstream job succeeds

* chore: Linter compliances met

* fix: HPOS order mutation data loss and CI coverage condition

Refactor order create/update mutations to set all props on a single
WC_Order instance before saving, mirroring the WC REST API pattern.
Previously, separate add_order_meta() and add_items() calls each loaded
their own order instance and saved independently, causing HPOS data loss
for payment method, addresses, and other fields.

Also fix CI coverage job to only run when all upstream jobs succeed,
and correct test assertions for RAW format line item totals.

Closes #591

* chore: Linter compliances met

* chore: Remove dead code from Order_Mutation after prepare_order refactor

Removes add_items() and update_address() which are no longer called
after the prepare_order() consolidation.

* chore: Remove dead code add_order_meta and update_item_meta_data
2026-03-30 21:42:00 -04:00

291 lines
9.7 KiB
YAML

name: Automated-Testing
on:
schedule:
- cron: '0 4 * * 5'
push:
branches:
- develop
- master
pull_request:
branches:
- develop
paths:
- '**.php'
- '!docs/**'
jobs:
acceptance:
env:
STRIPE_API_PUBLISHABLE_KEY: ${{ secrets.STRIPE_API_PUBLISHABLE_KEY }}
STRIPE_API_SECRET_KEY: ${{ secrets.STRIPE_API_SECRET_KEY }}
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.3', '8.1']
wordpress: ['6.8', '6.7', '6.3']
include:
- php: '8.3'
wordpress: '6.8'
coverage: true
xdebug: 1
hpos: 1
- php: '8.1'
wordpress: '6.3'
debug: '--debug'
- wordpress: '6.3'
hpos: 1
fail-fast: false
name: Acceptance in WP v${{ matrix.wordpress }} on PHP${{ matrix.php }}${{ matrix.hpos == 1 && ' HPOS' || '' }}${{ matrix.debug == '--debug' && ' Debug' || '' }}${{ matrix.coverage == true && ' +Coverage' || '' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, mbstring
tools: composer
- name: Install dependencies
run: |
cp .env.testing .env
rm -rf composer.lock
composer install
WP_VERSION=${{ matrix.wordpress }} SKIP_DB_CREATE=true SKIP_WP_SETUP=true composer installTestEnv
- name: Run Acceptance Tests
id: tests
continue-on-error: true
env:
USING_XDEBUG: ${{ matrix.xdebug }}
WP_VERSION: ${{ matrix.wordpress }}
PHP_VERSION: ${{ matrix.php }}
run: |
HPOS="${{ matrix.hpos }}" FILTER="acceptance --fail-fast ${{ matrix.coverage == true && '--coverage=acceptance.cov' || '' }} ${{ matrix.debug }}" composer dRunTestStandalone
- name: Retry on failure
id: retry
if: ${{ steps.tests.outcome == 'failure' }}
env:
USING_XDEBUG: ${{ matrix.xdebug }}
WP_VERSION: ${{ matrix.wordpress }}
PHP_VERSION: ${{ matrix.php }}
run: |
HPOS="${{ matrix.hpos }}" FILTER="acceptance ${{ matrix.coverage == true && '--coverage=acceptance.cov' || '' }} ${{ matrix.debug }}" composer dRunTestStandalone
- name: Fail if both attempts failed
if: ${{ steps.tests.outcome == 'failure' && steps.retry.outcome == 'failure' }}
run: exit 1
- name: Upload coverage artifact
if: ${{ matrix.coverage == true && always() }}
uses: actions/upload-artifact@v4
with:
name: coverage-acceptance
path: tests/_output/acceptance.cov
if-no-files-found: ignore
functional:
env:
STRIPE_API_PUBLISHABLE_KEY: ${{ secrets.STRIPE_API_PUBLISHABLE_KEY }}
STRIPE_API_SECRET_KEY: ${{ secrets.STRIPE_API_SECRET_KEY }}
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.3', '8.1']
wordpress: ['6.8', '6.7', '6.3']
include:
- php: '8.3'
wordpress: '6.8'
coverage: true
xdebug: 1
hpos: 1
- php: '8.1'
wordpress: '6.3'
debug: '--debug'
- wordpress: '6.3'
hpos: 1
fail-fast: false
name: Functional in WP v${{ matrix.wordpress }} on PHP${{ matrix.php }}${{ matrix.hpos == 1 && ' HPOS' || '' }}${{ matrix.debug == '--debug' && ' Debug' || '' }}${{ matrix.coverage == true && ' +Coverage' || '' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, mbstring
tools: composer
- name: Install dependencies
run: |
cp .env.testing .env
rm -rf composer.lock
composer install
WP_VERSION=${{ matrix.wordpress }} SKIP_DB_CREATE=true SKIP_WP_SETUP=true composer installTestEnv
- name: Run Functional Tests
id: tests
continue-on-error: true
env:
USING_XDEBUG: ${{ matrix.xdebug }}
WP_VERSION: ${{ matrix.wordpress }}
PHP_VERSION: ${{ matrix.php }}
run: |
HPOS="${{ matrix.hpos }}" FILTER="functional --fail-fast ${{ matrix.coverage == true && '--coverage=functional.cov' || '' }} ${{ matrix.debug }}" composer dRunTestStandalone
- name: Retry on failure
id: retry
if: ${{ steps.tests.outcome == 'failure' }}
env:
USING_XDEBUG: ${{ matrix.xdebug }}
WP_VERSION: ${{ matrix.wordpress }}
PHP_VERSION: ${{ matrix.php }}
run: |
HPOS="${{ matrix.hpos }}" FILTER="functional ${{ matrix.coverage == true && '--coverage=functional.cov' || '' }} ${{ matrix.debug }}" composer dRunTestStandalone
- name: Fail if both attempts failed
if: ${{ steps.tests.outcome == 'failure' && steps.retry.outcome == 'failure' }}
run: exit 1
- name: Upload coverage artifact
if: ${{ matrix.coverage == true && always() }}
uses: actions/upload-artifact@v4
with:
name: coverage-functional
path: tests/_output/functional.cov
if-no-files-found: ignore
wpunit:
env:
STRIPE_API_PUBLISHABLE_KEY: ${{ secrets.STRIPE_API_PUBLISHABLE_KEY }}
STRIPE_API_SECRET_KEY: ${{ secrets.STRIPE_API_SECRET_KEY }}
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.3', '8.1']
wordpress: ['6.8', '6.7', '6.3']
include:
- php: '8.3'
wordpress: '6.8'
coverage: true
xdebug: 1
hpos: 1
- php: '8.1'
wordpress: '6.3'
debug: '--debug'
- wordpress: '6.3'
hpos: 1
fail-fast: false
name: WPUnit in WP v${{ matrix.wordpress }} on PHP${{ matrix.php }}${{ matrix.hpos == 1 && ' HPOS' || '' }}${{ matrix.debug == '--debug' && ' Debug' || '' }}${{ matrix.coverage == true && ' +Coverage' || '' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, mbstring
tools: composer
- name: Install dependencies
run: |
cp .env.testing .env
rm -rf composer.lock
composer install
WP_VERSION=${{ matrix.wordpress }} SKIP_DB_CREATE=true SKIP_WP_SETUP=true composer installTestEnv
- name: Run WPUnit Tests
id: tests
continue-on-error: true
env:
USING_XDEBUG: ${{ matrix.xdebug }}
WP_VERSION: ${{ matrix.wordpress }}
PHP_VERSION: ${{ matrix.php }}
run: |
HPOS="${{ matrix.hpos }}" FILTER="wpunit --fail-fast ${{ matrix.coverage == true && '--coverage=wpunit.cov' || '' }} ${{ matrix.debug }}" composer dRunTestStandalone
- name: Retry on failure
id: retry
if: ${{ steps.tests.outcome == 'failure' }}
env:
USING_XDEBUG: ${{ matrix.xdebug }}
WP_VERSION: ${{ matrix.wordpress }}
PHP_VERSION: ${{ matrix.php }}
run: |
HPOS="${{ matrix.hpos }}" FILTER="wpunit ${{ matrix.coverage == true && '--coverage=wpunit.cov' || '' }} ${{ matrix.debug }}" composer dRunTestStandalone
- name: Fail if both attempts failed
if: ${{ steps.tests.outcome == 'failure' && steps.retry.outcome == 'failure' }}
run: exit 1
- name: Upload coverage artifact
if: ${{ matrix.coverage == true && always() }}
uses: actions/upload-artifact@v4
with:
name: coverage-wpunit
path: tests/_output/wpunit.cov
if-no-files-found: ignore
coverage:
needs: [acceptance, functional, wpunit]
if: ${{ needs.acceptance.result == 'success' && needs.functional.result == 'success' && needs.wpunit.result == 'success' }}
runs-on: ubuntu-latest
name: Aggregate Coverage & Push to Coveralls
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: json, mbstring
tools: composer
- name: Install dependencies
run: |
composer global require phpunit/phpcov:^8 phpunit/php-code-coverage:^9 php-coveralls/php-coveralls
- name: Download coverage artifacts
uses: actions/download-artifact@v4
with:
path: coverage-files
pattern: coverage-*
merge-multiple: true
- name: Merge coverage reports
run: |
mkdir -p tests/_output
echo "Coverage files structure:"
find coverage-files/ -name "*.cov" -type f 2>/dev/null || echo "No coverage files found"
if find coverage-files/ -name "*.cov" -type f | grep -q .; then
# Symlink Docker container path to CI checkout so phpcov can read source files.
sudo mkdir -p /var/www/html/wp-content/plugins
sudo ln -s "$GITHUB_WORKSPACE" /var/www/html/wp-content/plugins/wp-graphql-woocommerce
phpcov merge --clover=tests/_output/coverage.xml coverage-files
else
echo "No serialized coverage files to merge"
exit 0
fi
- name: Push Codecoverage to Coveralls.io
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
php-coveralls -v
- name: Upload coverage debug artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: coverage-debug
path: |
tests/_output/coverage.xml
tests/_output/coverage.json
if-no-files-found: ignore