Skip to content

Repair wp/6.3 branch Actions: Fix theme-activation navigation race in activate-theme.js - #536

Closed
desrosj wants to merge 1 commit into
fix-actions-6.3/fix-playwright-noble-installfrom
fix-actions-6.3/fix-activate-theme-navigation-race
Closed

desrosj wants to merge 1 commit into
fix-actions-6.3/fix-playwright-noble-installfrom
fix-actions-6.3/fix-activate-theme-navigation-race

Conversation

@desrosj

@desrosj desrosj commented Sep 28, 2026

Copy link
Copy Markdown
Owner

What?

Fixes a theme-activation navigation race in packages/e2e-test-utils/src/activate-theme.js's activateTheme() helper, used by the Puppeteer end-to-end suite (including the shared config/setup-test-framework.js setup, which activates a theme before each spec file).

activateTheme() clicks the "Activate" link on wp-admin/themes.php, then immediately calls page.waitForSelector() with Puppeteer's default 30s timeout to confirm the theme became active. This PR wraps the click in Promise.all() with page.waitForNavigation( { waitUntil: 'networkidle0' } ), and gives the final waitForSelector() an explicit 45s timeout.

Why?

The "Activate" link is a plain link: clicking it triggers a real, full-page navigation (switch_theme() on the server, then a redirect back to themes.php). Without waiting for that navigation, the single waitForSelector() that follows has to cover the whole click → theme switch → redirect → page reload chain by itself, which can time out with:

TimeoutError: waiting for selector `div[data-slug="..."].active` failed: timeout 30000ms exceeded

On wp/6.5 and wp/6.4 this race failed the Puppeteer suite in CI repeatedly (on wp/6.4, 20 of 114 failed end-to-end runs without the fix hit it; 0 of 49 with it), and it is fixed there by WordPress#83002 and #328. This branch has the same race in an older form of the helper, but it has not been seen to fail here: none of the 20 most recent failed end-to-end runs on this branch's stack hit it. It is included proactively, so the helper behaves the same across branches and a future failure here does not have to be investigated from scratch. (An earlier review on 2026-09-13 decided not to include it on the branches where it had not failed; that decision has been reversed for consistency.)

The code is the same as on wp/6.5 and wp/6.4, including waitUntil: 'networkidle0'. This branch's login-user.js waits for its own submit navigation with a plain page.waitForNavigation(); the same form as the other branches' fix is used here so the helper is identical everywhere. The "theme is already active" early return is unchanged.

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.

🤖 Generated with Claude Code

@desrosj desrosj self-assigned this Sep 28, 2026
@desrosj
desrosj changed the base branch from wp/6.3 to fix-actions-6.3/fix-playwright-noble-install September 28, 2026 14:32
@desrosj
desrosj added this pull request to stack #537 September 28, 2026 14:32
@desrosj
desrosj removed this pull request from stack #537 September 28, 2026 15:24
@desrosj
desrosj added this pull request to stack #552 September 28, 2026 15:25
@desrosj
desrosj removed this pull request from stack #552 September 28, 2026 18:41
@desrosj
desrosj changed the base branch from fix-actions-6.3/fix-playwright-noble-install to wp/6.3 September 28, 2026 18:43
@desrosj
desrosj force-pushed the fix-actions-6.3/fix-activate-theme-navigation-race branch from d1f80c3 to a6351fd Compare September 28, 2026 18:45
@desrosj
desrosj changed the base branch from wp/6.3 to fix-actions-6.3/fix-playwright-noble-install September 28, 2026 18:46
@desrosj
desrosj added this pull request to stack #563 September 28, 2026 18:46
WordPress core's "Activate" link on wp-admin/themes.php is a plain
<a href>: clicking it causes a real, full-page, server-driven navigation
(switch_theme(), then a redirect back to themes.php). activateTheme()
clicked that link without waiting for the navigation, so the single,
bare 30s page.waitForSelector() immediately afterward had to cover the
entire click -> switch_theme() -> redirect -> admin page reload chain
by itself.

Wrap the click in Promise.all() with page.waitForNavigation( {
waitUntil: 'networkidle0' } ), so the final page.waitForSelector() only
runs once the navigation has finished, and give that wait an explicit
45s timeout instead of Puppeteer's 30s default, as headroom for the
page's own post-navigation render.

The "no activate button found" branch (the theme is already active)
returns before the click and is unchanged.

This is the same change as the equivalent fixes on wp/6.5
(WordPress#83002) and wp/6.4 (#328), where
this race failed the Puppeteer suite in CI. It has not been seen to fail
on this branch; it is included so the helper behaves the same across
branches and a future failure here does not need to be rediscovered.
@desrosj
desrosj removed this pull request from stack #563 September 28, 2026 19:03
@desrosj
desrosj changed the base branch from fix-actions-6.3/fix-playwright-noble-install to wp/6.3 September 28, 2026 19:03
@desrosj
desrosj force-pushed the fix-actions-6.3/fix-activate-theme-navigation-race branch from a6351fd to 88fdb60 Compare September 28, 2026 19:03
@desrosj
desrosj changed the base branch from wp/6.3 to fix-actions-6.3/fix-playwright-noble-install September 28, 2026 19:04
@desrosj
desrosj added this pull request to stack #566 September 28, 2026 19:04
@desrosj
desrosj marked this pull request as ready for review September 28, 2026 19:18
@desrosj

desrosj commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

Moved to WordPress#83713. The branch is left in place.

@desrosj desrosj closed this Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant