Repository navigation
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
|
/approve-spec 8adb8bd |
There was a problem hiding this comment.
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:508and: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.
| ); | ||
| screen.getByRole('link', {name: 'Go to next page'}).focus(); | ||
| await user.keyboard('{Enter}'); | ||
| await act(async () => { |
There was a problem hiding this comment.
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();
The late-page focus case in
Pagination.test.tsxnow 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
useOptimisticuntil its change transition settles.act()before it asserts.Evidence
aria-disabled="true".Scope
Components: Pagination (tests only)
Testing
At 8adb8bd, on main 9901f0b:
check:changesetspasses, andreview:prereports 17 authored lines and 0 findings.