Skip to content
Merged
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
1 change: 1 addition & 0 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ composer lint:fix # PHPCS auto-fix
yarn wp-env:e2e start # Start dedicated E2E environment (port 8702)
yarn test:e2e # Run all Playwright tests (headless)
yarn test:e2e:debug # Open Playwright UI for interactive debugging
yarn test:e2e:multisite # Run tests/playwright/multisite/ on its own Multisite wp-env (port 8704), started by the command
```

E2E tests live in `tests/playwright/` and run against a single wp-env instance on port 8702, in one Playwright invocation with every test in parallel (`fullyParallel`, 4 workers). The `setup-core` project (`tools/playwright/global-setup.ts`) logs in and puts the site on `/%postname%/` permalinks, then:
Expand Down
30 changes: 18 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,18 @@ jobs:
signature: ":robot: PHPUnit coverage report"

e2e-playwright:
name: Playwright E2E Tests (shard ${{ matrix.shard }}/${{ strategy.job-total }})
name: Playwright E2E Tests (${{ matrix.name }})
needs: prebuild
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [ 1, 2, 3, 4 ]
include:
- { id: '1', name: 'shard 1/4', env: 'wp-env:e2e', config: 'e2e', test: 'test:e2e -- --shard=1/4' }
- { id: '2', name: 'shard 2/4', env: 'wp-env:e2e', config: 'e2e', test: 'test:e2e -- --shard=2/4' }
- { id: '3', name: 'shard 3/4', env: 'wp-env:e2e', config: 'e2e', test: 'test:e2e -- --shard=3/4' }
- { id: '4', name: 'shard 4/4', env: 'wp-env:e2e', config: 'e2e', test: 'test:e2e -- --shard=4/4' }
- { id: 'multisite', name: 'Multisite', env: 'wp-env:e2e-multisite', config: 'e2e-multisite', test: 'test:e2e:multisite' }

steps:
- name: Checkout repository
Expand All @@ -329,6 +334,7 @@ jobs:
uses: ./.github/actions/setup-e2e
with:
php-version: 7.4
wp-env-config: tools/wp-env/${{ matrix.config }}.json

- name: Log debug information
run: |
Expand All @@ -350,24 +356,24 @@ jobs:
path: |
~/wp-env
~/.wp-env
key: wp-env-e2e-v2-${{ runner.os }}-${{ hashFiles('tools/wp-env/e2e.json', 'composer.lock') }}
key: wp-env-${{ matrix.config }}-v2-${{ runner.os }}-${{ hashFiles(format('tools/wp-env/{0}.json', matrix.config), 'composer.lock') }}

- name: Install / Setup Gravity PDF + WordPress
run: yarn wp-env:e2e start
run: yarn ${{ matrix.env }} start

# wp-env's work-dir is cached but its MySQL volume isn't, so a restored work-dir can pair with a fresh empty DB.
# A bare `wp core install` leaves the env half-configured (GF REST never enables), so run wp-env's full reset.
- name: Ensure WordPress is installed (wp-env cache fallback)
run: |
if yarn wp-env:e2e run cli wp core is-installed >/dev/null 2>&1; then
if yarn ${{ matrix.env }} run cli wp core is-installed >/dev/null 2>&1; then
echo "WordPress already installed."
else
echo "wp-env work-dir cache hit a fresh DB volume — running wp-env reset for a full install."
yarn wp-env:e2e reset
yarn ${{ matrix.env }} reset
fi

- name: Run the tests
run: yarn test:e2e -- --shard=${{ matrix.shard }}/${{ strategy.job-total }}
run: yarn ${{ matrix.test }}
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true

Expand All @@ -376,24 +382,24 @@ jobs:
if: success()
run: |
mkdir -p tmp/visual/current
tar -C tmp/visual -cf "$RUNNER_TEMP/visual-shots-${{ matrix.shard }}.tar" current
tar -C tmp/visual -cf "$RUNNER_TEMP/visual-shots-${{ matrix.id }}.tar" current

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: success()
with:
name: visual-shots-${{ matrix.shard }}
path: ${{ runner.temp }}/visual-shots-${{ matrix.shard }}.tar
name: visual-shots-${{ matrix.id }}
path: ${{ runner.temp }}/visual-shots-${{ matrix.id }}.tar
compression-level: 0

- name: Dump log files on failure
if: failure()
run: yarn wp-env:e2e run wordpress "cp" "-r" "/var/www/html/wp-content/uploads/gravity_forms/logs/" "/var/www/html/wp-content/plugins/gravity-pdf/tmp/artifacts/logs"
run: yarn ${{ matrix.env }} run wordpress "cp" "-r" "/var/www/html/wp-content/uploads/gravity_forms/logs/" "/var/www/html/wp-content/plugins/gravity-pdf/tmp/artifacts/logs"

- name: Upload artifacts on failure
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: failure()
with:
name: failure-artifacts-shard-${{ matrix.shard }}
name: failure-artifacts-shard-${{ matrix.id }}
path: tmp/artifacts

addon-smoke:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ jobs:
tools/wp-env/development.json
tools/wp-env/integration.json
tools/wp-env/e2e.json
tools/wp-env/e2e-multisite.json
commit-message: "chore(deps): weekly bump of WordPress core + Gravity Forms"
title: "chore(deps): weekly bump of WordPress core + Gravity Forms"
body: ${{ steps.body.outputs.text }}
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@
"wp-env": "WP_ENV_PORT=8700 wp-env --config=./tools/wp-env/development.json",
"wp-env:integration": "WP_ENV_PORT=8701 wp-env --config=./tools/wp-env/integration.json",
"wp-env:e2e": "WP_ENV_PORT=8702 wp-env --config=./tools/wp-env/e2e.json",
"wp-env:e2e-multisite": "WP_ENV_PORT=8704 wp-env --config=./tools/wp-env/e2e-multisite.json",
"wp-env:addons": "WP_ENV_PORT=8703 wp-env --config=./tmp/addons/wp-env.json",
"test:php": "yarn wp-env:integration run wordpress env PHP_IDE_CONFIG=serverName=localhost /var/www/html/wp-content/plugins/gravity-pdf/vendor/bin/phpunit -- -c /var/www/html/wp-content/plugins/gravity-pdf/tools/phpunit/config.xml",
"test:php:snapshots": "yarn wp-env:integration run wordpress env GPDF_UPDATE_SNAPSHOTS=1 /var/www/html/wp-content/plugins/gravity-pdf/vendor/bin/phpunit -- -c /var/www/html/wp-content/plugins/gravity-pdf/tools/phpunit/config.xml --group snapshot",
"test:php:multisite": "yarn wp-env:integration run wordpress env PHP_IDE_CONFIG=serverName=localhost /var/www/html/wp-content/plugins/gravity-pdf/vendor/bin/phpunit -- -c /var/www/html/wp-content/plugins/gravity-pdf/tools/phpunit/config-multisite.xml",
"test:e2e": "wp-scripts test-playwright --config tools/playwright/config.ts",
"test:e2e:debug": "wp-scripts test-playwright --config tools/playwright/config.ts --ui",
"test:e2e:multisite": "wp-scripts test-playwright --config tools/playwright/config-multisite.ts",
"visual:compare": "LOST_PIXEL_CONFIG_DIR=tools/lost-pixel LOST_PIXEL_DISABLE_TELEMETRY=1 lost-pixel",
"visual:prune": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON tools/lost-pixel/prune-unchanged-baselines.mts",
"test:js": "jest --verbose",
Expand Down
1 change: 1 addition & 0 deletions src/Controller/Controller_Font_Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function init() {
*/
public function add_actions() {
add_action( Model_Font_Downloader::SYNC_EVENT, [ $this->model, 'sync' ] );
add_action( Model_Font_Downloader::CLEANUP_EVENT, [ $this->model, 'cleanup' ] );

add_action( 'gfpdf_plugin_installed', [ $this->model, 'schedule_sync' ] );
add_action( 'gfpdf_version_changed', [ $this->model, 'schedule_sync' ] );
Expand Down
21 changes: 7 additions & 14 deletions src/Controller/Controller_Upgrade_Routines.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@ public function maybe_run_upgrade( $old_version, $current_version ): void {

/* A site upgraded from before Arimo was the default keeps DejaVu Sans Condensed, even if it never saved one */
if ( $old_version !== '' && version_compare( $old_version, '6.19.0', '<' ) ) {
$this->save_unset_default_font( 'dejavusanscondensed' );
$this->save_unset_default_font( Model_Font_Downloader::PRE_6_19_DEFAULT_FONT );
$this->adopt_font_source_records();

/* After the default font save, so the font it saves is kept */
$this->remove_unneeded_core_fonts();
$this->schedule_core_font_cleanup();
}

if ( version_compare( $current_version, '7.0.0-beta1', '>=' ) && version_compare( $old_version, '7.0.0-beta1', '<' ) ) {
Expand Down Expand Up @@ -180,22 +179,16 @@ protected function adopt_font_source_records(): void {
}

/**
* Delete the core fonts a new install wouldn't have; any still needed download again on use. A network shares one
* fonts folder, so a Multisite prunes it once, for the site whose request runs the upgrade.
* Queue the removal of the core fonts a new install wouldn't have. It keeps the fonts every site needs and runs in
* the background, as every site on every network shares the fonts folder.
*
* @since 6.19.0
*/
protected function remove_unneeded_core_fonts(): void {
protected function schedule_core_font_cleanup(): void {
$downloader = \GPDFAPI::get_mvc_class( 'Model_Font_Downloader' );
if ( ! $downloader instanceof Model_Font_Downloader ) {
return;
if ( $downloader instanceof Model_Font_Downloader ) {
$downloader->schedule_cleanup();
}

if ( is_multisite() && ! add_site_option( Model_Font_Downloader::PRUNED, true ) ) {
return;
}

$downloader->prune();
}

/**
Expand Down
33 changes: 4 additions & 29 deletions src/Model/Model_Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ protected static function get_removed_methods(): array {
*/
const UNWRITABLE_FOLDER_DISMISSAL = 'unwritable_folder_';

/**
* The prefix each failed core font's dismissal is recorded under in `action_dismissal`
*
* @since 6.19.0
*/
const FAILED_CORE_FONT_DISMISSAL = 'failed_core_font_';

/**
* How long dismissing the unwritable folders notice hides a folder that keeps failing
*
Expand Down Expand Up @@ -296,22 +289,13 @@ protected function get_unwritable_folder_dismissal( string $dir ): string {
}

/**
* The core fonts that failed to download after their retry, less the ones dismissed since
* The core fonts that failed to download after their retry, less the ones dismissed
*
* @return string[]
* @since 6.19.0
*/
public function get_undismissed_failed_core_fonts(): array {
$files = [];

/* A dismissal covers only the failure it followed */
foreach ( $this->get_downloader()->get_failed_files() as $file => $gave_up ) {
if ( ! $this->is_notice_already_dismissed( $this->get_failed_core_font_dismissal( $file ), $gave_up ) ) {
$files[] = $file;
}
}

return $files;
return $this->get_downloader()->get_undismissed_failed_files();
}

/**
Expand All @@ -324,12 +308,12 @@ public function has_failed_core_fonts(): bool {
}

/**
* Dismiss each listed font; one that fails later raises the notice again
* Dismiss the listed fonts for every site, as they share the fonts folder; one that fails later raises it again
*
* @since 6.19.0
*/
public function dismiss_failed_core_fonts(): void {
$this->dismiss_notices( array_map( [ $this, 'get_failed_core_font_dismissal' ], $this->get_undismissed_failed_core_fonts() ) );
$this->get_downloader()->dismiss_failed_files();
}

/**
Expand All @@ -341,15 +325,6 @@ protected function get_downloader(): Model_Font_Downloader {
return $this->downloader ?? GPDFAPI::get_mvc_class( 'Model_Font_Downloader' );
}

/**
* The ID a failed core font's dismissal is recorded under in `action_dismissal`
*
* @since 6.19.0
*/
protected function get_failed_core_font_dismissal( string $file ): string {
return static::FAILED_CORE_FONT_DISMISSAL . md5( $file );
}

/**
* Send the user to the system report, which lists every detection behind the notice
*
Expand Down
Loading