Skip to content

Add regression test for the Debug Bar ElasticPress asset dependencies - #600

Open
wisyhambolu wants to merge 1 commit into
masterfrom
test/2269-debug-bar-asset-deps
Open

Add regression test for the Debug Bar ElasticPress asset dependencies#600
wisyhambolu wants to merge 1 commit into
masterfrom
test/2269-debug-bar-asset-deps

Conversation

@wisyhambolu

Copy link
Copy Markdown
Contributor
  • Fix unregistered query monitor dependency debug-bar-elasticpress#9 muat be merged first and 1.6.4 tag must be added also before merging this.
  • 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

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
Copilot AI lite review requested due to automatic review settings September 1, 2026 18:00

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.

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 DebugBarAssetDepsTest integration tests covering dependency presence/absence and printing assets without notices.
  • Adds a Codeception integration suite 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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants