Skip to content

Tests: Cover wp_enqueue_editor() default asset enqueue - #16236

Open
shail-mehta wants to merge 6 commits into
WordPress:trunkfrom
shail-mehta:tests/66757-wp-enqueue-editor
Open

shail-mehta wants to merge 6 commits into
WordPress:trunkfrom
shail-mehta:tests/66757-wp-enqueue-editor

Conversation

@shail-mehta

@shail-mehta shail-mehta commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What

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

Adds a unit test for wp_enqueue_editor() that checks:

  • editor script is enqueued
  • editor-buttons style is enqueued
  • force_uncompressed_tinymce hooked on wp_print_footer_scripts at priority 1
  • print_default_editor_scripts hooked on wp_print_footer_scripts at priority 45

Why

wp_enqueue_editor() had no dedicated coverage. Removing the editor-buttons enqueue or the footer add_action calls left existing tests green.

How

Calls wp_enqueue_editor() once and asserts enqueue / has_action state directly (front-end branch; PHPUnit is not in admin by default).

Testing

  • npm run test:php -- --filter Tests_General_WpEnqueueEditor — 1 test passes
  • Remove wp_enqueue_style( 'editor-buttons' ) → style assertion fails
  • Remove the footer add_action calls → has_action assertions fail
  • PHPCS clean

Use of AI Tools

  • Cursor

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test fails to isolate and restore $wp_scripts and $wp_styles, allowing pre-existing queues to cause false-positive assertions and leftover assets to affect subsequent tests.

1 open issue
What changed in this PR

Adds dedicated regression coverage for wp_enqueue_editor() in WordPress’s PHPUnit suite, addressing Trac #66757 without changing production code.

Changes:

  • Checks that the editor script and editor-buttons style are enqueued.
  • Verifies front-end footer hooks for TinyMCE setup and default editor scripts at priorities 1 and 45.
File Description
tests/​phpunit/​tests/​general/​wpEnqueueEditor.php Adds a test for default editor assets and footer hook priorities.

Review effort: Balanced

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for this test-only addition covering default editor assets and footer hooks.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review November 25, 2026 14:33
@github-actions

github-actions Bot commented Nov 25, 2026 •

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.

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

Props shailu25, mukesh27, lancewillett.

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the editor-buttons enqueue and the new test failed on that assertion. Restoring the line passed the randomized General suite in both modes. The fresh asset registries make the check meaningful even when an earlier test has already queued the editor. Short messages on the two footer hook assertions would make failures easier to diagnose.

Before landing, please link a ticket in the component that owns the code under test, per the 7.3 ticket guidance. Related coverage can share a component ticket.

AI review · gpt-6.2-astra

@shail-mehta

Copy link
Copy Markdown
Member Author

Thanks for the review and for creating #66822! I've updated the @ticket annotation to 66822 (the PR description already links it), and added short failure messages to the two wp_print_footer_scripts assertions.

@shail-mehta shail-mehta self-assigned this Nov 26, 2026

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the test checks both footer hook priorities and now identifies each callback if an assertion fails. The revised test passed on single-site and multisite.

AI review · gpt-6.2-astra

@lancewillett

Copy link
Copy Markdown
Member

@afercia Could you take a look at this test from the component side? It passed the focused PHPUnit run on both single-site and multisite.

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The admin-footer case catches a real regression: moving the callback to the front-end hook failed the new assertion. Please drop the one redundant screen reset before landing.

AI review · gpt-6.2-astra

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The revised tests passed in single-site and multisite, including admin first and front end second. Moving only the admin print callback to the front-end footer hook failed the admin test in both modes. Inherited teardown covers the removed screen reset.

The Editor component review remains with Andrea before landing.

AI review · gpt-6.2-sol

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

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants