Skip to content

Fix e2e tests that break when shard rebalancing changes their neighbors - #81117

Merged
jorgefilipecosta merged 2 commits into
WordPress:trunkfrom
jorgefilipecosta:fix/font-appearance-control-e2e-open-sidebar
Aug 3, 2026
Merged

Fix e2e tests that break when shard rebalancing changes their neighbors#81117
jorgefilipecosta merged 2 commits into
WordPress:trunkfrom
jorgefilipecosta:fix/font-appearance-control-e2e-open-sidebar

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Aug 3, 2026

Copy link
Copy Markdown
Member

Trunk's e2e suite has been red since #80314 landed, but not because that PR broke the editor: it added new e2e tests, and shard balancing is duration-based, so the suite's shards recomposed and two latent order-dependent specs started failing deterministically. This PR hardens both. The failing tests moved with each subsequent reshuffle — font-appearance-control.spec.js on Playwright shard 5 in the first two red runs, site-editor-inserter.spec.js on shard 7 after #79934 added more tests — which is the signature of order dependence rather than a product regression.

Font appearance control: the two tests read the block inspector but never open it, relying on the sidebar's default-visible state. Sidebar visibility is a persisted user preference: preferences are reset once per CI run in the global setup, then shared by every test in the shard, with writes flushed on a debounce. Any earlier test that leaves the sidebar hidden therefore starves these tests of an inspector, and the failure screenshots show exactly that: the Typography options click timing out with the sidebar closed. With a seeded isComplementaryAreaVisible: false preference the failure reproduces on trunk before #80314 too, and both development and production builds pass with a clean profile — the editor itself is fine. Fix: call editor.openDocumentSettingsSidebar() in beforeEach, like sibling specs do (a no-op when the sidebar is already open).

Site editor inserter: the InserterUtils tab locator used getByRole's default substring matching, so 'Patterns' also matches the My patterns pattern-category tab, which renders inside the Patterns panel whenever the site has user patterns — for example ones left behind by an earlier spec in the same run (deleteAllBlocks() also only runs once, in the global setup). The zoomed-out inserter opens straight to the Patterns tab, so expectActiveTab( 'Patterns' ) dies on a strict mode violation: with a user pattern present, the substring locator resolves to both tabs while the exact locator resolves to the one selected top-level tab. Fix: match tab names exactly.

Testing Instructions

  1. npm run test:e2e -- test/e2e/specs/editor/various/font-appearance-control.spec.js test/e2e/specs/site-editor/site-editor-inserter.spec.js passes.
  2. Font appearance, poisoned state: seed the closed sidebar an earlier test can leave behind — wp user meta update admin wp_persisted_preferences --format=json '{"core":{"isComplementaryAreaVisible":false},"_modified":"2026-08-03T00:00:00.000Z"}' — then drive the spec's steps manually (insert a paragraph, click Typography options): without this change the button never renders; with it the sidebar is opened explicitly. (Running the suite re-resets preferences in global setup, which is why mid-run state must be simulated.)
  3. Inserter, poisoned state: create a user pattern (any reusable block), enter Zoom Out in the site editor and open the inserter: getByRole( 'tab', { name: 'Patterns' } ) now resolves to two tabs (Patterns, My patterns) which is the CI strict mode violation, while the exact-match locator used by this change resolves to the single selected tab.

AI usage disclosure: investigation and fixes drafted with AI assistance and reviewed by me.

The two tests in font-appearance-control.spec.js read the block
inspector but never opened it, relying on the sidebar's
default-visible state. Sidebar visibility is a persisted user
preference shared across every test in a CI shard, so any earlier
test that closes the sidebar (or whose debounced preference write
lands that way) leaves these tests without an inspector, and the
'Typography options' click times out.

This surfaced when WordPress#80314 added new revisions e2e tests: shard
balancing uses historical test durations, so the added tests
reshuffled shard 5 and these two started running after specs that
leave the sidebar hidden. Open the sidebar explicitly in beforeEach,
like sibling specs do.
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

The InserterUtils tab locator used getByRole's default substring
matching, so 'Patterns' also matches the 'My patterns' pattern
category tab, which renders inside the Patterns panel whenever the
site has user patterns — for example ones left behind by an earlier
spec in the same CI run. The zoomed-out inserter opens straight to
the Patterns tab, so expectActiveTab( 'Patterns' ) hits a strict mode
violation. Match the tab name exactly instead.
@jorgefilipecosta jorgefilipecosta changed the title Fix font appearance control e2e tests: open the settings sidebar explicitly Fix e2e tests that break when shard rebalancing changes their neighbors Aug 3, 2026
@jorgefilipecosta
jorgefilipecosta merged commit 402d519 into WordPress:trunk Aug 3, 2026
42 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 3, 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.

1 participant