Skip to content

test: cover Fix_News_Dependencies_Integration - #23463

Open
faisalahammad wants to merge 3 commits into
Yoast:trunkfrom
faisalahammad:23462-replace-editor-recursion
Open

test: cover Fix_News_Dependencies_Integration#23463
faisalahammad wants to merge 3 commits into
Yoast:trunkfrom
faisalahammad:23462-replace-editor-recursion

Conversation

@faisalahammad

@faisalahammad faisalahammad commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Context

The replace_editor recursion fix this PR originally carried has already landed on trunk in 6ef9a30, where the block editor check was moved into Current_Page_Helper::is_block_editor() and made null-safe with get_current_screen(). After merging trunk, the three source files this PR touched (admin/metabox/class-metabox.php, src/integrations/admin/fix-news-dependencies-integration.php, src/integrations/third-party/elementor.php) are identical to trunk, so no production code changes remain here.

What is left is the part trunk does not have: unit test coverage for Fix_News_Dependencies_Integration. That class had no test file at all. This PR keeps only that coverage, so it is now a test-only, non-user-facing change.

Requested changelog label: changelog: non-user-facing.

Summary

This PR can be summarized in the following changelog entry:

  • Adds unit test coverage for Fix_News_Dependencies_Integration.

Relevant technical choices:

  • register_hooks() is covered for both post edit pages (post.php, post-new.php) and for a screen where the enqueue hook must not be registered.
  • add_news_script_dependency() is covered for the block editor handle, the classic editor handle, and the bail when the wpseo-news-editor script is not registered.
  • The block editor state is taken from a mocked Current_Page_Helper, so the tests follow the constructor injection the class already uses and do not touch WP_Screen or globals other than $pagenow.

Test instructions

Test instructions for the acceptance test before the PR gets merged

Not applicable. This PR only adds unit tests and changes no production code. CI runs the suite; locally it is composer test -- --filter Fix_News_Dependencies_Integration_Test.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Not applicable. There is no user-facing behaviour to verify.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • Nothing. Test-only change, no production code touched.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.
  • I have run grunt build:images and committed the results, if my PR introduces or edits images or SVGs.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Refs #23462

Use get_current_screen() instead of WP_Screen::get() when detecting
the block editor during asset enqueue. WP_Screen::get() re-applies the
replace_editor filter and double-renders custom editors that include
admin-header.php.

Fixes Yoast#23462
@github-actions

This comment has been minimized.

…or-recursion

# Conflicts:
#	admin/metabox/class-metabox.php
#	src/integrations/admin/fix-news-dependencies-integration.php
#	src/integrations/third-party/elementor.php
Add cases for the post edit pages and for a screen where the enqueue
hook must not be registered.

Refs Yoast#23462
@faisalahammad faisalahammad changed the title fix: avoid re-firing replace_editor via WP_Screen::get test: cover Fix_News_Dependencies_Integration Sep 2, 2026
@faisalahammad

Copy link
Copy Markdown
Contributor Author

Update on this PR, plus a note on the two red checks.

The source fix is already on trunk. Commit 6ef9a30 moved the block editor check into Current_Page_Helper::is_block_editor() and made it use get_current_screen() instead of WP_Screen::get(). That is the same fix this PR proposed, in a better shape, since all three call sites now share one helper. When I merged trunk, the conflicts in admin/metabox/class-metabox.php, src/integrations/admin/fix-news-dependencies-integration.php and src/integrations/third-party/elementor.php resolved to the trunk version, so this PR has no production code changes left.

I kept the part trunk does not have: unit tests for Fix_News_Dependencies_Integration, which had no test file. I also added coverage for register_hooks() in the latest commit. The PR title and description now describe it as a test-only change. Happy to close it instead if you prefer not to take the tests on their own.

Two checks fail for reasons outside this branch:

  1. Finish coveralls build fails with Missing Repo Token. The workflow passes secrets.COVERALLS_TOKEN, and GitHub does not give repository secrets to pull_request runs from forks, so the value is empty. This happens on every community PR and no change in this branch can fix it.
  2. Validate PR Labels & Milestone fails because there is no changelog: label. Could a maintainer add changelog: non-user-facing? I only have read access, so I cannot add labels or set the milestone myself.

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.

2 participants