Repository navigation
Repair wp/6.4 branch Actions: Fix theme-activation navigation race in activate-theme.js - #83686
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Size Change: 0 B Total Size: 1.63 MB ℹ️ View Unchanged
|
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
3df818a to
0713cca
Compare
0713cca to
37d1e80
Compare
37d1e80 to
da2167d
Compare
da2167d to
22d6eb3
Compare
22d6eb3 to
c54127c
Compare
c54127c to
a13e5de
Compare
Part of #82929.
What?
Fixes a race condition in
packages/e2e-test-utils/src/activate-theme.js'sactivateTheme()helper, responsible for theme-activation failures in thePuppeteerjob with:thrown from
packages/e2e-test-utils/src/activate-theme.js:31.activateTheme()clicks the "Activate" link onwp-admin/themes.php, then immediately callspage.waitForSelector()(bare 30s Puppeteer default) to confirm the click took effect. The click itself is never wrapped in apage.waitForNavigation(). This PR wraps it in one, mirroring the existing, already-correct pattern already used bypackages/e2e-test-utils/src/login-user.js, and gives the trailingwaitForSelector()its own explicit 45s timeout.Why?
WordPress core's "Activate" link (
wp-admin/js/theme.js) is a plain, unhandled<a href>— clicking it triggers a real, full-page, server-driven navigation (switch_theme(), then a redirect back tothemes.php), not a client-side/JS-intercepted action. Without an explicitpage.waitForNavigation()around the click, the single, bare 30swaitForSelector()that follows has to cover the entire click → serverswitch_theme()→ redirect → full admin-page reload chain by itself. That's a genuine race, and the sharedbeforeAllhook inconfig/setup-test-framework.jscallsactivateTheme()once per test file — so any file unlucky enough to hit a slow tail on that one click loses the race and fails outright.login-user.jsalready solves the identical problem correctly for its own submit-button click:This PR applies the same pattern to
activateTheme()'s click, so the existingisCurrentURL()/fallback-revisit logic and the finalwaitForSelector()only ever run once navigation has genuinely finished. The trailingwaitForSelector()also gets an explicit 45s timeout (up from Puppeteer's bare 30s default) — some headroom for the page's own post-navigation render tail, without silently masking a real future regression by setting it unreasonably high.The existing "theme has no activate button" branch (meaning the theme is already active) is untouched: it returns immediately after
switchUserToTest(), before the click/navigation code is ever reached, so it's unaffected by this change and never triggers a navigation wait.This is the same change as #83002 on
wp/6.5.Use of AI Tools
This PR was created by Claude Code under my supervision. All code should be treated as AI-produced and not yet reviewed by a human until this PR is marked Ready for Review.