Skip to content

Fix: flaky list view paste block styles e2e test - #81229

Merged
jorgefilipecosta merged 1 commit into
trunkfrom
fix/flaky-list-view-paste-styles-e2e
Aug 10, 2026
Merged

Fix: flaky list view paste block styles e2e test#81229
jorgefilipecosta merged 1 commit into
trunkfrom
fix/flaky-list-view-paste-styles-e2e

Conversation

@jorgefilipecosta

Copy link
Copy Markdown
Member

Fixes #78759

Fixes the flaky "should paste block styles using keyboard" e2e test in list-view.spec.js.

The test clicks "Copy styles" on the second block and immediately opens the list view and pastes onto the first block with primaryAlt+v. Copying styles writes to the clipboard through the asynchronous navigator.clipboard.writeText(), and the click resolves before that write settles. On a busy CI runner the paste can then read the clipboard before the styles are in it: the paste aborts with the "Unable to paste styles" warning, the first block never changes, and the expect.poll times out with exactly the diff recorded in the issue (first block missing the pasted style, second block untouched).

To fix this we wait for the "Styles copied to clipboard." snackbar before opening the list view. The confirmation is only created once the clipboard write has settled, so the paste can no longer read a stale clipboard.

Testing Instructions

  1. Run npm run test:e2e -- test/e2e/specs/editor/various/list-view.spec.js --grep "paste block styles" --repeat-each=10 and verify it passes.
  2. To reproduce the flake on trunk, widen the race window like a busy CI runner by delaying the clipboard write: apply the following patch without this PR's change and the test fails with the same diff as the issue. With this PR's change the same widened runs pass.
diff --git a/test/e2e/specs/editor/various/list-view.spec.js b/test/e2e/specs/editor/various/list-view.spec.js
--- a/test/e2e/specs/editor/various/list-view.spec.js
+++ b/test/e2e/specs/editor/various/list-view.spec.js
@@ -632,6 +632,17 @@
 		} );
 
 		// Copy the styles from the second block.
+		// Simulate a slow clipboard write, like on a loaded CI runner.
+		await page.evaluate( () => {
+			const original = navigator.clipboard.writeText.bind(
+				navigator.clipboard
+			);
+			navigator.clipboard.writeText = async ( text ) => {
+				await new Promise( ( resolve ) => setTimeout( resolve, 800 ) );
+				return original( text );
+			};
+		} );
 		await editor.clickBlockToolbarButton( 'Options' );

AI usage disclosure: fix and description drafted with AI assistance and reviewed by me.

@github-actions

github-actions Bot commented Aug 5, 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.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.65 MB

compressed-size-action

@jorgefilipecosta
jorgefilipecosta force-pushed the fix/flaky-list-view-paste-styles-e2e branch from fd35bbb to 411449a Compare August 5, 2026 20:43
@jorgefilipecosta
jorgefilipecosta force-pushed the fix/flaky-list-view-paste-styles-e2e branch from 411449a to 7adc622 Compare August 10, 2026 14:10
@jorgefilipecosta
jorgefilipecosta enabled auto-merge (squash) August 10, 2026 19:00
@jorgefilipecosta
jorgefilipecosta merged commit 1980b08 into trunk Aug 10, 2026
44 checks passed
@jorgefilipecosta
jorgefilipecosta deleted the fix/flaky-list-view-paste-styles-e2e branch August 10, 2026 19:01
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 10, 2026
@sirreal sirreal added the [Type] Flaky Test Auto-generated flaky test report issue label Aug 12, 2026
shail-mehta pushed a commit that referenced this pull request Aug 12, 2026
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Flaky Test Auto-generated flaky test report issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flaky Test] should paste block styles using keyboard

2 participants

Sponsor
SponsoredKunjungi sekarang
Promo