Skip to content

Fix failing E2E tests for PR #4061#4088

Merged
acicovic merged 2 commits into
fix/api-version-number-mismatchfrom
copilot/sub-pr-4061
Mar 25, 2026
Merged

Fix failing E2E tests for PR #4061#4088
acicovic merged 2 commits into
fix/api-version-number-mismatchfrom
copilot/sub-pr-4061

Conversation

Copilot AI commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes a mismatch where blocks/recommendations/edit.tsx declared apiVersion: 2 in its registerBlockType call while block.json declared apiVersion: 3. Updates edit.tsx to 3 and fixes E2E tests that broke as a result.

Block fix:

  • src/blocks/recommendations/edit.tsx: apiVersion: 23 in registerBlockType

E2E test fix:

apiVersion: 3 in registerBlockType causes WordPress to render the editor canvas inside an [name="editor-canvas"] iframe (vs. the non-iframed legacy canvas used with apiVersion: 2). Tests that used page.locator() / page.getByText() to query block-rendered elements were failing because those elements are now scoped to the iframe.

  • errors.spec.ts: page.getByText()admin.editor.canvas.getByText() for error messages rendered inside the block
  • settings.spec.ts: page.locator()editor.canvas.locator() for block content selectors; sidebar elements (labels, sliders) remain on page; Utils class updated to accept FrameLocator instead of Page
// Before — fails with iframed canvas
await expect( page.getByText( 'Access denied...', { exact: true } ) ).toBeVisible();

// After
await expect( admin.editor.canvas.getByText( 'Access denied...', { exact: true } ) ).toBeVisible();

Motivation and context

Mismatched apiVersion values are a latent bug: the effective API version is controlled by registerBlockType, not block.json, so the block was silently running as v2 despite the metadata claiming v3. Aligning them to v3 changes the editor rendering path (iframed canvas), which the E2E tests must account for.

How has this been tested?

Existing E2E tests updated to work with the iframed editor canvas introduced by apiVersion: 3.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • developer.wordpress.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix apiVersion number mismatch Fix apiVersion number mismatch Mar 23, 2026
Copilot AI requested a review from acicovic March 23, 2026 09:10
@acicovic acicovic changed the title Fix apiVersion number mismatch Fix failing E2E tests for PR #4061 Mar 25, 2026
@acicovic acicovic modified the milestone: 3.22.1 Mar 25, 2026
@acicovic acicovic marked this pull request as ready for review March 25, 2026 10:58
@acicovic acicovic requested a review from a team as a code owner March 25, 2026 10:58
@acicovic acicovic removed this from the 3.22.1 milestone Mar 25, 2026
@acicovic acicovic merged commit 4c62d95 into fix/api-version-number-mismatch Mar 25, 2026
35 checks passed
@acicovic acicovic deleted the copilot/sub-pr-4061 branch March 25, 2026 11:00
@acicovic acicovic added this to the 3.22.1 milestone Mar 25, 2026
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