Skip to content

Build/Test Tools: Fix install.test.js leaving behind wp_e2e_ tables that break subsequent test runs - #13302

Open
anamwp wants to merge 2 commits into
WordPress:trunkfrom
anamwp:fix/65982-install-test-e2e-flake
Open

Build/Test Tools: Fix install.test.js leaving behind wp_e2e_ tables that break subsequent test runs#13302
anamwp wants to merge 2 commits into
WordPress:trunkfrom
anamwp:fix/65982-install-test-e2e-flake

Conversation

@anamwp

@anamwp anamwp commented Aug 28, 2026

Copy link
Copy Markdown

afterEach in tests/e2e/specs/install.test.js reverted wp-config.php's table prefix but never dropped the wp_e2e_* tables the test's own install wizard creates. As a result:

  • The first run against a clean database passes, but leaves a fully-installed wp_e2e_options, wp_e2e_users, etc. behind.
  • Every run after that flips the prefix to wp_e2e_ again, WordPress finds those tables already present, and the test never reaches /wp-admin/install.php — it fails deterministically on every subsequent run until someone manually drops the tables.

This PR:

  • Drops the wp_e2e_* tables in afterEach via wp eval, routed through WP's own $wpdb/mysqli connection rather than wp-cli's db query, which shells out to the mysql binary and can hit unrelated SSL/client issues on some hosts.
  • Wraps the initial navigation + redirect assertion in expect(...).toPass() so the navigation itself retries, not just the URL check. A single page.goto('/') right after the config swap can occasionally observe a not-yet-updated wp-config.php on some hosts (consistent with Docker bind-mount write propagation lag).

Testing

Isolation data — three consecutive runs of each variant, with wp_e2e_* tables dropped before each:


trunk (unpatched)          1 passed / 2 failed
retry navigation only      0 passed / 3 failed
table drop only            2 passed / 1 failed
both changes                3 passed / 0 failed

Both changes are independently necessary — neither one alone is sufficient to make the test reliably repeatable.

Trac ticket: https://core.trac.wordpress.org/ticket/65982

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5
Used for: Diagnosing the root cause (including tracing a Playwright network trace and DB state to rule out a false lead), drafting the fix, and building the A/B isolation harness used to produce the testing data above. I reviewed the diagnosis, ran and verified the fix and the isolation tests myself, and take responsibility for the change.

…es that break subsequent test runs.

`afterEach` reverted `wp-config.php`'s table prefix but never dropped the
`wp_e2e_*` tables the test's own install wizard creates, so any run after
the first found a pre-existing install and never reached the installer.
Also retries the initial navigation itself, since a single `page.goto('/')`
right after the config swap can occasionally observe a stale config on
some hosts.

See https://core.trac.wordpress.org/ticket/65982
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props theanamhossain.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

…stant.

Per review feedback on the Trac ticket, avoid repeating the `wp_e2e_`
literal in both the config rewrite and the cleanup query — use one
`TEST_TABLE_PREFIX` constant instead so the two can't drift out of sync.

See https://core.trac.wordpress.org/ticket/65982
@anamwp

anamwp commented Aug 29, 2026

Copy link
Copy Markdown
Author

Pushed a follow-up commit extracting wp_e2e_ into a single TEST_TABLE_PREFIX constant. Discussion continues on the Trac ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant