Add regression test for the Debug Bar ElasticPress asset dependencies - #600
Open
wisyhambolu wants to merge 1 commit into
Open
Add regression test for the Debug Bar ElasticPress asset dependencies#600wisyhambolu wants to merge 1 commit into
wisyhambolu wants to merge 1 commit into
Conversation
Covers humanmade/debug-bar-elasticpress 1.6.4: the panel must only
declare a `query-monitor` dependency when Query Monitor has actually
registered that handle, otherwise WordPress 6.9.1+ raises
Function WP_Styles::add was called incorrectly. The style with the
handle "debug-bar-elasticpress" was enqueued with dependencies that
are not registered: query-monitor.
Asserts on the registered deps array rather than on notice emission:
WP_Dependencies dedupes that notice per handle per instance, so a shared
$wp_styles would let a later test pass for the wrong reason. set_up()
gives each test a fresh WP_Styles/WP_Scripts for the same reason.
The second case asserts the dependency IS declared when query-monitor is
registered, so we don't over-correct and break the load order.
Addresses humanmade/product-dev#2269
There was a problem hiding this comment.
Pull request overview
Adds a WordPress integration regression test to ensure the Debug Bar ElasticPress panel conditionally declares the query-monitor asset dependency (avoiding WordPress 6.9.1+ missing-dependency _doing_it_wrong() notices) while still preserving correct load order when Query Monitor is present.
Changes:
- Introduces
DebugBarAssetDepsTestintegration tests covering dependency presence/absence and printing assets without notices. - Adds a Codeception
integrationsuite configuration to run WP-backed integration tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/integration/debug-bar/DebugBarAssetDepsTest.php | New integration regression tests asserting debug-bar-elasticpress deps behavior with/without query-monitor and ensuring no _doing_it_wrong() during asset printing. |
| tests/integration.suite.yml | New Codeception suite definition enabling WP-backed integration tests via WPLoader. |
Suppressed comments (1)
tests/integration/debug-bar/DebugBarAssetDepsTest.php:87
- Same direct indexing issue here: add a handle-exists assertion before reading ->deps so failures report the missing registration clearly instead of producing PHP warnings.
$this->get_panel()->enqueue_scripts_styles();
$this->assertContains( 'query-monitor', wp_styles()->registered['debug-bar-elasticpress']->deps );
$this->assertContains( 'query-monitor', wp_scripts()->registered['debug-bar-elasticpress']->deps );
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+36
to
+46
| public function set_up() { | ||
| parent::set_up(); | ||
|
|
||
| if ( ! class_exists( 'Debug_Bar_Panel' ) ) { | ||
| $this->markTestSkipped( 'Requires the dev-tools module with Query Monitor enabled.' ); | ||
| } | ||
|
|
||
| $GLOBALS['wp_styles'] = new \WP_Styles(); | ||
| $GLOBALS['wp_scripts'] = new \WP_Scripts(); | ||
| } | ||
|
|
Comment on lines
+66
to
+69
| $this->get_panel()->enqueue_scripts_styles(); | ||
|
|
||
| $this->assertNotContains( 'query-monitor', wp_styles()->registered['debug-bar-elasticpress']->deps ); | ||
| $this->assertNotContains( 'query-monitor', wp_scripts()->registered['debug-bar-elasticpress']->deps ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses humanmade/product-dev#2269