Skip to content

Assert Altis QM panels from raw response, drop UI clicks for QM v4#1057

Merged
mikelittle merged 1 commit into
masterfrom
fix/qm-v4-panel-test-source-assertion
May 21, 2026
Merged

Assert Altis QM panels from raw response, drop UI clicks for QM v4#1057
mikelittle merged 1 commit into
masterfrom
fix/qm-v4-panel-test-source-assertion

Conversation

@mikelittle
Copy link
Copy Markdown
Contributor

Summary

  • Rewrite DevToolsCest::testQueryMonitor to assert against the raw server response rather than the live DOM, since Query Monitor v4 renders its UI client-side in a shadow DOM and Codeception can't reach it.
  • Narrow the scope to the three Altis-specific panel outputters: Altis Config, ElasticPress, and AWS X-Ray.
  • Drop the Hooks & Actions assertion — that's a built-in QM panel and not Altis dev-tools' responsibility to test.

Background

QM 4.0 changed how panels are rendered:

  1. The PHP outputters still emit their HTML, but into a hidden <div id="query-monitor-fallbacks"> block.
  2. A React app mounts inside <div id="query-monitor-container"> using a shadow root, then moves the fallback nodes into the shadow tree.

That broke the existing test in three different ways:

  • $I->see('Module', 'th') walks only the light DOM — by the time it runs, the <th> is in the shadow tree, so "no <th> found".
  • The data-qm-href tab buttons no longer exist (tabs are <button role="tab"> inside the shadow DOM with no data-qm-href attribute, and they're behind the shadow boundary anyway).
  • seeInPageSource() also won't work — WebDriver::getPageSource() returns the post-React serialized DOM, where the fallback nodes have already been moved out.

Caught by product-dev nightly CI (run 25669000209).

Approach

Use executeJS to run a synchronous XMLHttpRequest against the current URL inside the authenticated browser session. That gives us the raw server response (before any React mutation), which is what we actually want to verify — the three Altis-specific panel PHP outputters are wired up and emitting the expected markup. QM owns its own client-side rendering and is tested upstream.

Synchronous XHR is technically deprecated but still works in Chrome and avoids needing to thread session cookies into a separate PHP HTTP client.

Test plan

  • composer dev-tools codecept run -p vendor/altis/dev-tools/tests/ -- acceptance DevToolsCest passes locally — 6 assertions across the three panels.

🤖 Generated with Claude Code

Query Monitor v4.0 rewrote its UI into a React app inside a shadow
DOM (#query-monitor-container) and moves the server-rendered panel
HTML from <div id="query-monitor-fallbacks"> into the shadow tree
once React boots. Codeception's see() only walks the light DOM and
seeInPageSource() reads the post-React serialized DOM, so neither
can reach the panel content. The data-qm-href tab buttons used by
the old test also no longer exist - tabs are now shadow-DOM buttons
with role="tab".

Rewrite the test to fetch the raw server response over a same-
session XHR and assert against that. Scope narrowed to the three
Altis-specific panel outputters (Altis Config, ElasticPress,
AWS X-Ray) - QM owns its own UI rendering and is tested upstream;
the Hooks & Actions panel is QM's, not Altis dev-tools'.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@johnbillion
Copy link
Copy Markdown
Member

Query Monitor v4 mounts its UI in a React app inside a shadow DOM (#query-monitor-container) and moves the server-rendered panel HTML from <div id="query-monitor-fallbacks">

The server-rendered panel gets moved into the shadow DOM when a user clicks on the corresponding menu item, not when the QM component mounts. That should mean you can directly inspect the #qm-altis-config-container element without having to perform the ajax request as it's in the normal DOM with display:none applied until its menu item gets clicked.

@mikelittle
Copy link
Copy Markdown
Contributor Author

Claude mentioned that Codeception can't see anything display:none either. And as it originally simulated a click to then check the panels, the move happened at that point.

@johnbillion
Copy link
Copy Markdown
Member

Ah that's annoying

Copy link
Copy Markdown
Contributor

@vladislavhmn vladislavhmn left a comment

Choose a reason for hiding this comment

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

LGTM

@mikelittle mikelittle merged commit 3a4b1c4 into master May 21, 2026
1 of 2 checks passed
@mikelittle mikelittle deleted the fix/qm-v4-panel-test-source-assertion branch May 21, 2026 13:33
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.

3 participants