Skip to content

test(Pagination): settle the change action before the late-page check - #11920

Draft
vjeux wants to merge 1 commit into
meta:mainfrom
vjeux:test/pagination-late-page-settle
Draft

vjeux wants to merge 1 commit into
meta:mainfrom
vjeux:test/pagination-late-page-settle

Conversation

@vjeux

@vjeux vjeux commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

The late-page focus case in Pagination.test.tsx now settles its change action before it asserts, so a slow runner no longer fails it. Only the test changes.

Maintainer impact

"Keeps focus while the page arrives later than the click" can fail on a slow runner. Its link query runs while the clicked page still shows optimistically. Next is then the last page's disabled button, so no link named "Go to next page" exists. It failed this way in #11905's test-ui (4/4) job, on code that does not touch Pagination.

Intended invariant

The case checks that Next keeps the focus when a link click's page does not arrive. That behavior, and Pagination's code, stay unchanged.

Change

  • Pagination shows the clicked page through useOptimistic until its change transition settles.
  • The case now passes a change action that it holds, and it settles that action inside act() before it asserts.
  • No timeout, retry or product code changes.

Evidence

  • Failure before the change: with the held action and the old order, the case fails in 2 of 2 runs. The error is the one CI showed: no link named "Go to next page", and Next has aria-disabled="true".
  • Success after the change: the case passes, and the whole file passes 152 of 152.
  • Product/runtime behavior verified unchanged: only the test file changes.
  • CI impact: none.

Scope

Components: Pagination (tests only)

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

At 8adb8bd, on main 9901f0b:

  • Red first. The held action with the old assertion order fails the case, 2 of 2 runs, with CI's error.
  • Green. The whole file passes 152 of 152 on each of 5 runs.
  • Checks. ESLint with no warnings and Prettier pass on the file. check:changesets passes, and review:pre reports 17 authored lines and 0 findings.

The late-page focus case asserted right after the Enter key. Pagination
shows the clicked page optimistically until its change transition
settles. On a slow runner that transition had not settled yet, so Next
was still the last page's disabled button and the link query failed.

The case now holds its change action and settles it inside act()
before it asserts. With the old order, the held action fails the case
the same way every time.
@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 15, 2026 8:21pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 15, 2026
@astracat-bot

astracat-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 15, 2026, 8:28 PM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 8adb8bd

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: CI has not run on this head yet. The pull request is a draft from a fork, so CI runs once it is marked ready and a maintainer adds the ci:run label.

The change makes the late-page focus case deterministic without touching Pagination: with the settle step removed the case fails with the reported error every time, and with it the whole file passes.

  • Optional: asserting that Next is the focused, disabled button before settle() would also pin the pending state the case is named for (see the inline comment).
Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: only the test file changes, with no timeout, retry or product code change. Verified: the diff touches only Pagination.test.tsx.
  • Claim: Pagination shows the clicked page optimistically until its change transition settles. Verified: Pagination.tsx:508 and :575-578.
  • Claim: the old case could query the Next link while the optimistic last page showed, when Next is a disabled button. Verified: the variant without the settle step fails with that error and aria-disabled="true".
  • Claim: it failed that way in another pull request's UI test shard that does not touch Pagination. Partly verified: that pull request changes no Pagination file; its job log was not available to this review.
  • Claim: the case now holds its change action and settles it inside act() before it asserts. Verified: Pagination.test.tsx:2576-2589.
  • Claim: with the held action and the old order, the case fails every run with the CI error. Verified: 2 of 2 runs.
  • Claim: the whole file passes 152 of 152. Verified: 3 runs, at the head and merged with main.
  • Claim: the intended invariant and Pagination's code are unchanged, and CI is not affected. Verified: no product, workflow or CI file in the diff.
  • Claim: ESLint with no warnings, Prettier and the changeset check pass. Verified.
  • Claim: the pre-review tool reports 17 authored lines. Verified: +15 and −2; its zero-findings result was not re-run.
  • Claim: no public API, product behavior, visual or policy change, and no internal context in public text. Verified: the built API surfaces are unchanged.
  • File: packages/core/src/Pagination/Pagination.test.tsx. Clear, with one optional suggestion.

Automated review (maintainer link)

);
screen.getByRole('link', {name: 'Go to next page'}).focus();
await user.keyboard('{Enter}');
await act(async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional: the case never checks the pending state it is named for, so it would still pass if the optimistic swap stopped happening. Asserting it before settling holds at this head:

const pending = screen.getByRole('button', {name: 'Go to next page'});
expect(pending).toHaveAttribute('aria-disabled', 'true');
expect(pending).toHaveFocus();

This branch was successfully deployed

1 active deployment
Preview — 8adb8bd3 Deployed Nov 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants