Skip to content

Commit 96db8f0

Browse files
authored
Stabilize WordPress E2E tests (#459)
## What changed This PR removes two sources of flakiness from the WordPress E2E test environment. Both changes are confined to test code and configuration; they do not affect the distributed plugin. - **Query Monitor activation:** Reload the plugins screen after activation so Query Monitor is loaded from the beginning of the request before its admin-bar output is inspected. - **Runtime configuration changes:** Disable the PHP OPcache revalidation delay so changes that E2E tests make to `wp-config.php` become visible immediately. ## Why The activation response is generated by a request that began before Query Monitor was active, so its interface is not guaranteed to exist on that page. Separately, OPcache can continue executing a cached `wp-config.php` after a test changes it. These timing differences make otherwise valid E2E assertions depend on request and cache state.
1 parent 095da59 commit 96db8f0

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎tests/e2e/specs/query-monitor-plugin.test.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ test.describe( 'Query Monitor plugin', () => {
2525
await admin.visitAdminPage( '/plugins.php' );
2626
await page.getByLabel( 'Activate Query Monitor', { exact: true } ).click();
2727
await page.getByText( 'Plugin activated.', { exact: true } ).waitFor();
28+
await page.reload();
2829

2930
// Skip this test if QM 4.0+ is not active (no shadow DOM container).
3031
const hasContainer = await page.locator( '#query-monitor-container' ).count();
@@ -168,6 +169,7 @@ test.describe( 'Query Monitor plugin', () => {
168169
await admin.visitAdminPage( '/plugins.php' );
169170
await page.getByLabel( 'Activate Query Monitor', { exact: true } ).click();
170171
await page.getByText( 'Plugin activated.', { exact: true } ).waitFor();
172+
await page.reload();
171173

172174
// Skip this test if QM 3.x is not active (has shadow DOM container = QM 4.0+).
173175
const hasContainer = await page.locator( '#query-monitor-container' ).count();

‎wp-setup.sh‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ sed -i.bak "s#{SQLITE_PLUGIN}#sqlite-database-integration/load.php#g" "$WP_DIR"/
6161
echo "Rewriting helper class 'WpdbExposedMethodsForTesting' to extend WP_SQLite_DB..."
6262
sed -i.bak "s#class WpdbExposedMethodsForTesting extends wpdb {#class WpdbExposedMethodsForTesting extends WP_SQLite_DB {#g" "$WP_DIR"/tests/phpunit/includes/utils.php
6363

64-
# 6. Install dependencies.
64+
# 6. Make wp-config.php changes immediately visible to E2E tests.
65+
echo "Disabling the PHP OPcache revalidation delay..."
66+
printf '\nopcache.revalidate_freq = 0\n' >> "$WP_DIR/tools/local-env/php-config.ini"
67+
68+
# 7. Install dependencies.
6569
echo "Installing dependencies..."
6670
npm --prefix "$WP_DIR" install
6771
npm --prefix "$WP_DIR" run build:dev

0 commit comments

Comments
 (0)