Repository navigation
test(Typeahead): the FR8 count test does not count the busy start - #11764
Conversation
The test watched every write to the polite region and expected none while a partial list showed and only "4 results" at settle. The busy start is announced once per query too (AST-092 FR8, AST-086 FR6), one frame after the search starts, through a channel that writes on the next frame. On a slow runner a frame passes inside the typing act, so "Loading" is written before the check and the test fails. It now records result announcements only; the busy start keeps its own tests.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec db7ea85 |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| BaseTypeahead | 78.2 kB (0) · 11.7 kB CSS (0) | — | — · ✓ · ✓ |
| Typeahead | 87.5 kB (0) · 13.3 kB CSS (0) | — | — · ✓ · ✓ |
| TypeaheadItem | 6.6 kB (0) · 3.6 kB CSS (0) | — | — · ✓ · ✓ |
Package size: no published package changed; no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approved.
The busy start of a pending query is meant to be announced once, so the FR8 count test should not count it: with one extra frame after typing, the old test fails with expected [ 'Loading' ] to deeply equal [], this version passes, and it still fails when the busy start is joined with the count.
Two non-blocking follow-ups in the same file, not caused by this change:
- The FR9 test "announces only the count when the answer fails before the busy start is written" has the same one-frame race: with one extra frame after typing it fails with
expected 'Loading | 2 results' not to match /Loading|Searching/. - The FR8 observer reads the live region's text when its callback runs, so it misses a count written and cleared within one frame; collecting
addedNodesfrom the mutation records would let it enforce "a partial list announces nothing".
Claims and files checked
Review mode: full; reason: recipe-changed (many rules)
- Claim: test-only, with no product code, so no changeset is needed. Verified: one test file changes.
- Claim: nothing changes for people using Typeahead. Verified: no shipped file changes, and the built API surface is unchanged.
- Claim: the old test expected no live-region write while a partial list shows, and only the four-result count at settle. Verified in the base test.
- Claim: the busy start is announced once per query, one frame after the search turns busy, through a channel that writes one frame later. Verified:
useBusyAnnouncement.ts:62,useAnnounce.ts:256. - Claim: normally the query settles first, and the busy start is withdrawn before it is written. Verified:
BaseTypeahead.tsx:1348,useBusyAnnouncement.ts:83-101. - Claim: one extra frame makes the current test fail with the reported error, and this head passes. Verified with a local probe.
- Claim: the observer now records result announcements only. Verified: line 195.
- Claim: the busy start keeps its own tests. Verified: the FR9 case, the busy-announcement hook tests and the adopter test pass, with the FR9 race noted above.
- Claim: the file's suite passes (22 tests). Verified.
- Claim: #11733 changes other assertions in this file, not this test. Verified from its patch.
- File:
packages/core/src/Typeahead/BaseTypeahead.incremental.test.tsx: clear.
| // too (AST-086); whether it is written before the query settles depends on | ||
| // frame timing, so it does not count here. | ||
| const observer = new MutationObserver(() => { | ||
| const text = liveRegion()?.textContent ?? ''; |
There was a problem hiding this comment.
Non-blocking, and already true before this change: this reads the region's text when the callback runs, so a count that is written and then cleared in the same frame is never recorded. For example, a count announced from context.update for the partial list is cleared by the busy start's announce in the same frame, and this test still passes. Collecting record.addedNodes text from the mutation records would let the test enforce "a partial list announces nothing".
Primary intent
Test-only: removes a flaky timing assumption from one BaseTypeahead test. No product code changes, so there is no Changeset.
User impact
BaseTypeahead.incremental.test.tsxlost a frame race. Nothing changes for people using Typeahead.Cause
The test records every write to the polite live region and expects none while a partial list shows, and only "4 results" when the query settles.
The busy start is also announced once per query (
spec:AST-092FR8,spec:AST-086FR6). It is announced one frame after the search starts, through a channel that writes on the following frame. Normally the query settles first, and the busy start is withdrawn before it is written. On a slow runner a frame passes inside the typingact, so "Loading" is written before the check:expected [ 'Loading' ] to deeply equal [], the error from the reported CI run.Change
The test's observer records result announcements only and skips the busy message. The busy start keeps its own tests, for example the FR9 case "announces only the count when the answer fails before the busy start is written".
Evidence
BaseTypeahead.incremental.test.tsxpasses (22).Owner and land path
Overlap checked: #11733 (it changes the empty-message assertions in the same test file, not this FR8 test; a flaky-test fix that should land on its own and ahead of a feature)