Skip to content

Repair wp/6.7 branch Actions: Fix wrong TinyMCE editor-tab selector in the meta box E2E test - #137

Closed
desrosj wants to merge 2 commits into
fix-actions-6.7/disable-flaky-test-issue-reportingfrom
fix-actions-6.7/fix-flaky-metabox-tinymce-race
Closed

desrosj wants to merge 2 commits into
fix-actions-6.7/disable-flaky-test-issue-reportingfrom
fix-actions-6.7/fix-flaky-metabox-tinymce-race

Conversation

@desrosj

@desrosj desrosj commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

What?

Fixes a consistently-failing (not intermittent) E2E test on wp/6.7: test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js, "Should save the changes". The test was clicking a button labeled "Code" that doesn't exist in this branch's bundled WordPress core — here, that button is labeled "Text".

Why?

The failure initially looked like the TinyMCE-initialization race trunk fixed in WordPress#78631 ("WP Editor Meta Box e2e: wait for TinyMCE init"), so that fix was ported first. Verified against real CI, it didn't resolve the failure — the test still timed out on the same role=button[name="Code"i] click, now occurring after TinyMCE had already finished initializing, proving that wasn't the blocking factor.

The actual cause: this branch's wp-env config pins WordPress Core to WordPress/WordPress#6.7-branch, which still renders the classic-editor tab as "Text" (wp-includes/class-wp-editor.php). Core only renamed that string to "Code" on its master branch, after 6.7-branch was cut, and Gutenberg trunk followed suit in WordPress#68872/WordPress#68886 (Jan 2025) — a rename that doesn't apply here, since this branch's wp-env is intentionally pinned to match its own core version (fix-actions-6.7/pin-wp-env-core-version, earlier in this stack). This also explains why the failure was 100% reproducible rather than intermittent: a hardcoded wrong locator fails every time, a genuine initialization race wouldn't.

The fix reverts the ineffective TinyMCE-init wait and restores the test's original structure, changing only the button-name selector from "Code"i back to "Text"i. Verified against real CI: the previously-failing shard now passes, with no new failures introduced elsewhere.

Trunk's current version of this test also clicks a "Meta Boxes" pane-toggle button, added by WordPress#71623. That toggle only renders under a narrow-height media query this branch's CI viewport doesn't trigger, so porting that unrelated UI feature to a frozen maintenance branch is out of scope for this fix.

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.

@desrosj desrosj changed the title Repair wp/6.7 branch Actions: Fix flaky TinyMCE-initialization race in the meta box E2E test Repair wp/6.7 branch Actions: Fix wrong TinyMCE editor-tab selector in the meta box E2E test Aug 31, 2026
@desrosj
desrosj removed this pull request from stack #90 September 10, 2026 19:33
@desrosj
desrosj force-pushed the fix-actions-6.7/fix-flaky-metabox-tinymce-race branch from 1387eaf to 5d1423f Compare September 10, 2026 19:36
@desrosj
desrosj added this pull request to stack #185 September 10, 2026 19:36
@desrosj
desrosj force-pushed the fix-actions-6.7/fix-flaky-metabox-tinymce-race branch from 5d1423f to 3578619 Compare September 10, 2026 23:58
@desrosj
desrosj force-pushed the fix-actions-6.7/fix-flaky-metabox-tinymce-race branch from 3578619 to e4b5a66 Compare September 11, 2026 00:29
@desrosj
desrosj force-pushed the fix-actions-6.7/fix-flaky-metabox-tinymce-race branch from e4b5a66 to 156121c Compare September 11, 2026 01:15
@desrosj
desrosj force-pushed the fix-actions-6.7/fix-flaky-metabox-tinymce-race branch from 156121c to 009b252 Compare September 11, 2026 02:20
@desrosj
desrosj force-pushed the fix-actions-6.7/fix-flaky-metabox-tinymce-race branch from 009b252 to 610a079 Compare September 11, 2026 16:10
@desrosj
desrosj force-pushed the fix-actions-6.7/fix-flaky-metabox-tinymce-race branch from 610a079 to eddd734 Compare September 14, 2026 01:49
@desrosj
desrosj force-pushed the fix-actions-6.7/fix-flaky-metabox-tinymce-race branch from eddd734 to d490ac5 Compare September 14, 2026 17:38
`test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js` waited only
for the TinyMCE iframe (`#test_tinymce_id_ifr`) to exist before clicking
the "Code" toggle button. The iframe element can exist in the DOM before
TinyMCE has actually finished initializing inside it, so the "Code"
button (rendered by TinyMCE itself once ready) isn't reliably present
yet, and the click times out with
`TimeoutError: locator.click: Timeout 10000ms exceeded` waiting for
`role=button[name="Code"i]`. This reproduces consistently, not
intermittently: every attempt fails at the exact same point.

Trunk fixed this same race in
`WordPress#78631` ("WP Editor Meta Box e2e: wait for TinyMCE
init"), which replaces the iframe-existence wait with
`page.waitForFunction(() => window.tinyMCE?.get('test_tinymce_id')?.initialized)`,
both when switching to Visual mode initially and when switching back to
Visual mode after typing in Code mode. That trunk commit is test-file
only, with no product-code changes, so it ports directly.

Trunk's *current* copy of this test also includes a step (added by
`WordPress#71623`, "Add ability to toggle meta box pane open
and closed") that clicks a "Meta Boxes" pane-toggle button before
interacting with TinyMCE. That toggle button doesn't exist on `wp/6.7`:
`WordPress#71623` restructured `packages/edit-post/src/components/layout/index.js`
so the toggle renders unconditionally as part of the resizable pane's
handle. On `wp/6.7`, the toggle only renders when `isShort` (a
`(max-height: 549px)` media query) is true; otherwise the pane is a
bare `ResizableBox` with a drag handle and no toggle button at all. CI
runs the browser under `xvfb` at `1280x960` (see
`.github/workflows/end2end-test.yml`), so `isShort` is false there and
no such button exists to click. Porting `WordPress#71623`'s pane-toggle feature
to fix an unrelated race would be a large, out-of-scope UI change for a
frozen branch, so this commit adopts only `WordPress#78631`'s TinyMCE-wait fix
and omits the pane-toggle step entirely.
…on-name selector.

The previous commit ported `WordPress#78631`'s TinyMCE
initialization wait, on the assumption the failure was a race between
the meta box's TinyMCE iframe appearing and the editor finishing
initialization. Verified against real CI, that fix did not resolve the
failure: it still timed out at the same
`role=button[name="Code"i]` click, now after the added
`waitForFunction` had already resolved successfully.

The actual cause is a button-label mismatch, unrelated to any timing
race. The "Code"/"Text" toggle is rendered by WordPress Core's
`wp_editor()` (`wp-includes/class-wp-editor.php`), and `wp-env`'s
pinned core for this branch, `WordPress/WordPress#6.7-branch`, still
ships the string `_x( 'Text', 'Name for the Text editor tab (formerly
HTML)' )`. Core renamed this label to "Code" only on its own `master`
branch (`_x( 'Code', 'Name for the Code editor tab (formerly Text)' )`)
after `6.7-branch` was cut, and never backported the wording change to
the maintenance branch. Screenshots from every failed run (the original
cited run and the one testing the previous, ineffective commit) confirm
the rendered button reads "Text", not "Code". The underlying behavior
is identical either way, so using the correct label is a like-for-like
change, not a weakened assertion.

The Gutenberg plugin's own trunk renamed this locator from "Text" to
"Code" in `WordPress#68872`/`WordPress#68886` (Jan 2025), correctly
following its own trunk's newer bundled/tested core. That rename
doesn't apply on `wp/6.7`, whose `wp-env` config intentionally pins to
the matching `6.7-branch` core, so this reverts the locator back to
"Text" for this branch and drops the TinyMCE-`waitForFunction` addition
along with it, since the original iframe-existence wait was never the
actual problem: the failure was 100% reproducible, not intermittent,
which is what a hard-coded wrong locator produces and a genuine race
condition would not.
@desrosj
desrosj force-pushed the fix-actions-6.7/fix-flaky-metabox-tinymce-race branch from d490ac5 to 0c51a15 Compare September 14, 2026 19:17
@desrosj
desrosj marked this pull request as ready for review September 14, 2026 19:34
@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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: desrosj <desrosj@git.wordpress.org>

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

@desrosj

desrosj commented Sep 15, 2026

Copy link
Copy Markdown
Owner Author

Migrated to real upstream: WordPress#82905. Closing this fork PR.

@desrosj desrosj closed this Sep 15, 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