Skip to content

Fix: flaky revisions pagination e2e cross-page diff assertion - #81119

Merged
jorgefilipecosta merged 3 commits into
trunkfrom
fix/flaky-revisions-pagination-boundary-diff
Aug 4, 2026
Merged

Fix: flaky revisions pagination e2e cross-page diff assertion#81119
jorgefilipecosta merged 3 commits into
trunkfrom
fix/flaky-revisions-pagination-boundary-diff

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Aug 3, 2026

Copy link
Copy Markdown
Member

Fixes #80154

Fixes the flaky "should paginate, navigate pages, and diff across page boundaries" e2e test.

After pressing Home the test read the two diff marks with one-shot textContent() calls, racing the canvas re-renders. Right after the keypress the canvas can still show the previously selected revision's diff, so the first read returns the stale added mark ("105"). While the adjacent page loads, the previous revision is unknown and the paragraph is briefly rendered as wholly added, with no removed mark in the DOM — so the second read auto-waits and lands on the settled cross-page diff ("5"). That produces Expected: 1, Received: 100 (105 − 5, always exactly the page size), the signature of every failure recorded in #80154.

The reads and the assertion are now wrapped in a polling expect( async () => { ... } ).toPass() block, so both marks are sampled together and retried until they show a consistent adjacent pair — a straddled sample fails the attempt and is retried instead of failing the test.

Testing Instructions

  1. Run npm run test:e2e -- test/e2e/specs/editor/various/revisions.spec.js --grep "paginate" and verify it passes, e.g. with --repeat-each=10.
  2. To reproduce the flake on trunk, widen the two race windows like a busy CI runner by applying the following patch, then run the test a few times without this PR's assertion change — it fails with Expected: 1, Received: 100. With this PR's change the same widened runs pass.
diff --git a/test/e2e/specs/editor/various/revisions.spec.js b/test/e2e/specs/editor/various/revisions.spec.js
--- a/test/e2e/specs/editor/various/revisions.spec.js
+++ b/test/e2e/specs/editor/various/revisions.spec.js
@@ -596,6 +596,20 @@
 		const slider = page.getByRole( 'slider', { name: 'Revision' } );
 		await expect( slider ).toHaveAttribute( 'max', '99' );
 
+		// Widen the race windows: delay the adjacent-page fetch and slow the
+		// canvas re-render, like a loaded CI runner.
+		await page.route(
+			( url ) =>
+				url.pathname.includes( '/revisions' ) &&
+				url.searchParams.get( 'page' ) === '2',
+			async ( route ) => {
+				await new Promise( ( r ) => setTimeout( r, 1500 ) );
+				await route.continue();
+			}
+		);
+		const cdp = await page.context().newCDPSession( page );
+		await cdp.send( 'Emulation.setCPUThrottlingRate', { rate: 6 } );
+
 		// Slide to the leftmost (oldest revision on page 1). Computing the
 		// previous-revision diff requires fetching the adjacent page.
 		await slider.focus();

The change was developed with the assistance of AI tooling.

@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.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.81 MB

compressed-size-action

@jorgefilipecosta
jorgefilipecosta force-pushed the fix/flaky-revisions-pagination-boundary-diff branch from 8c34b8c to 1940993 Compare August 4, 2026 09:58
@jorgefilipecosta
jorgefilipecosta merged commit 70680fb into trunk Aug 4, 2026
44 checks passed
@jorgefilipecosta
jorgefilipecosta deleted the fix/flaky-revisions-pagination-boundary-diff branch August 4, 2026 11:23
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 4, 2026
@sirreal sirreal added [Type] Flaky Test Auto-generated flaky test report issue [Package] E2E Tests /packages/e2e-tests and removed [Package] E2E Tests /packages/e2e-tests labels 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 paginate, navigate pages, and diff across page boundaries

2 participants