Skip to content

test: cut the jsdom style work that times out UI suites under load - #10285

Merged
cixzhang merged 3 commits into
meta:mainfrom
vjeux:ui-load-jsdom
Nov 6, 2026
Merged

cixzhang merged 3 commits into
meta:mainfrom
vjeux:ui-load-jsdom

Conversation

@vjeux

@vjeux vjeux commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

On a loaded machine, three UI test files fail on jsdom style work, not on the code under test. Under two CPUs with 12 busy loops, two DateTimeInputTouch cases timed out in every run, and a useTableRowExpansion case in 1 of 5. Table.perf's 100-row budget also fails when that case runs by itself, with no added load.

Intended invariant

Each case keeps its assertions, and its role queries stay as strict as getByRole. A render budget times the render it names, not one-off warm-up work.

Change

  • DateTimeInputTouch: the open sheet has about 300 buttons, most of them days in the month grids. A role query by name computes every button's accessible name, and jsdom reads styles to do so. Each query took about 6 s, and 13 of 46 cases took over 3 s alone. The shared fastRoleQueries.ts has fast lookups that take the first match. It gains getOnlyButton, which picks candidates with that module's name computation. It then runs Testing Library's own role, name and accessibility query on each and requires exactly one match.
  • useTableRowExpansion: the two zebra cases render without row dividers. With dividers, the panel's divider carry reads the striped row's computed style, and jsdom re-enters that read about 2,000 times. Striping does not depend on dividers. "carries the row's own divider onto the panel (Table FR14)" and two other row-divider cases still cover the carry, none of them striped.
  • Table.perf: an untimed render runs before each render budget. A run's first Table render also pays one-off module and compiler work, which the budgets do not measure. The warm-up unmounts and uses other rows, so the timed render is a fresh mount.

Evidence

  • Failure before the change: under load, main failed both DateTimeInputTouch cases in 5 of 5 runs. Each ran 131–151 s against the 30 s limit. Run by itself, the 100-row budget failed 5 of 5 under load, at 321–366 ms of CPU against 200. With no added load it failed 5 of 5, at 243–308 ms.
  • Success after the change: every case passed 10 of 10 runs under the same load. The DateTimeInputTouch cases took 8–15 s, and the zebra cases under 3 s.
  • Product/runtime behavior verified unchanged: the diff is in tests and a shared test helper only.
  • CI impact: none; no workflow or CI script changes.

Scope

  • 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

# Load: two pinned CPUs, 12 busy loops at the same priority, 2 workers
taskset -c <two cpus> pnpm exec vitest run --project ui \
  packages/core/src/DateTimeInput/DateTimeInputTouch.test.tsx \
  packages/core/src/Table/Table.perf.test.tsx \
  packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.test.tsx \
  -t "<the six cases>" --maxWorkers=2

Counts:

  • Load control: a fixed CPU loop takes 187 ms alone and 1.17–1.50 s under this load. It failed its 600 ms budget in every loaded run.
  • Main, 5 loaded runs: "Time Save closes the sheet without changing the value" passed 0 of 5. "Save after keyboard opening does not refocus-reopen the sheet" passed 0 of 5. Each run timed out. The 100-row budget, run by itself, passed 0 of 5. "counts stripes over data rows only" passed 4 of 5; one run timed out at 32 s. The panel-row case passed 5 of 5 at 15–18 s, and the 500-row budget 5 of 5.
  • This change, 10 loaded runs at this head: all six cases passed 10 of 10. The two DateTimeInputTouch cases took 8–14 s. The zebra cases took 0.5–3.0 s, and the 100-row budget passed every run.
  • Table.perf with the fresh-mount warm-up, 15 loaded runs interleaved: both budgets passed 10 of 10, the 100-row one at 93–112 ms of CPU. Main's 100-row budget passed 0 of 5, at 305–326 ms.
  • Whole files alone: DateTimeInputTouch 46 of 46 in 36 s, down from 128–165 s. The other users of fastRoleQueries.ts pass: Calendar 134, DateInput 134, DateRangeInput 64 and DateTimeInput 171. useTableRowExpansion 51 of 51 in 7 s, down from 11 s. Table.perf 15 of 15.
  • Planted regression: 9ebcf10dbf, not for landing, adds 2 ms of CPU to each Table row render. With the fresh-mount warm-up, both budgets still fail 3 of 3: 269–297 ms against 200, and 1,153–1,174 ms against 500.
  • tsc --noEmit for core passes, and ESLint reports nothing on the added lines.

Review notes

  • CodeBunny's wording note on fastRoleQueries.ts's header goes to the next change that touches that file; no call site hits the CSS-hidden-name case (29/29 return getByRole's element).

DateTimeInputTouch queried buttons by name on an open sheet of about
300 buttons. jsdom reads styles to compute each accessible name, so
each query took about 6 s, and 13 cases took over 3 s alone. A
buttonNamed helper gives the full role, name and accessibility check
only to the buttons whose label or text is the name.

useTableRowExpansion's two zebra cases rendered with row dividers. The
panel's divider carry reads the striped row's computed style, which
jsdom resolves in about 2,000 nested passes. Striping does not depend
on dividers, so both cases render without them.

Table.perf's render budgets timed a run's first Table render, which
also pays one-off module and compiler work. An untimed warm-up render
now runs first.
@vercel

vercel Bot commented Nov 6, 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 6, 2026 3:22pm UTC

Request Review

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

astracat-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 6, 2026, 3:29 PM UTC

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · b57f904

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
TableBody 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
TableFooter 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
TableHeader 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
6 more components
Component Size LoC Visual · A11y · RTL
TableRow 6.7 kB (0) · 3.9 kB CSS (0) — ✓ · ✓ · ✗
DateTimeInput · Storybook 195.1 kB (0) · 18.1 kB CSS (0) 3,567 (0) ✓ · ✓ · ✓
Table 99.9 kB (0) · 17.3 kB CSS (0) — ✓ · ✓ · —
TableCell 91.7 kB (0) · 17.0 kB CSS (0) — ✓ · ✓ · ✓
TableHeaderCell 91.3 kB (0) · 16.8 kB CSS (0) — ✓ · ✓ · ✓
TableSelectionToolbar 61.2 kB (0) · 12.4 kB CSS (0) — ✓ · ✓ · ✓

Package size: no published package changed; no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 19 rows, core 24 rows; run pnpm api:report.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 2ff0257

The warm-up render unmounts, and its rows now differ from the timed
ones. So the timed render is a fresh mount that reuses nothing.

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

Changes requested: the three test fixes work as described, and one change is needed before they land.

  • buttonNamed in DateTimeInputTouch.test.tsx re-implements the fast button lookup that packages/core/src/__tests__/fastRoleQueries.ts already provides and DateTimeInput.test.tsx already uses, so please move the stricter exactly-one lookup into that shared module and call it from here instead of keeping a local copy.

The Table.perf warm-up and the zebra cases' dividers="none" need no change, and the two slow DateTimeInputTouch cases drop from about 12 s to under 1 s with every case still passing. A smaller, non-blocking point: the helper's uniqueness check counts only buttons named by aria-label or text, so a duplicate named through aria-labelledby would slip past it; choosing candidates with the shared module's name computation would close that. CI has not run on this head yet: it starts once the pull request is marked ready for review and a maintainer adds the ci:run label.

[Automated review]

Comment on lines +108 to +123
// The open sheet holds about 300 buttons, most of them days in the month
// grids. jsdom reads styles to compute each accessible name, at several
// milliseconds per element, so a role query by name takes seconds. Only the
// buttons whose label or text is the name get the full check.
function buttonNamed(name: string): HTMLElement {
const matches = screen.getAllByRole('button', {hidden: true}).filter(
element =>
(element.getAttribute('aria-label') ?? element.textContent)?.trim() ===
name &&
within(element.parentElement as HTMLElement)
.queryAllByRole('button', {name})
.includes(element),
);
expect(matches, `accessible buttons named "${name}"`).toHaveLength(1);
return matches[0];
}

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.

This duplicates the fast lookup in packages/core/src/__tests__/fastRoleQueries.ts (getButton/queryButton), which DateTimeInput.test.tsx already uses for the same names (Open calendar, Clear Meeting). Moving this exactly-one, full-check variant into that module (for example getOnlyButton(name)) and calling it here keeps one helper for this jsdom cost. Choosing candidates by that module's stubbed-style name computation instead of aria-label/text would also catch a duplicate named through aria-labelledby, which this version misses.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in b57f904: the lookup moved into fastRoleQueries.ts as getOnlyButton. It picks candidates with that module's name computation, so an aria-labelledby name counts. Each candidate then goes through Testing Library's own role, name and accessibility query, and exactly one must match. The local helper is gone.

DateTimeInputTouch's local buttonNamed duplicated the fast lookup in
fastRoleQueries.ts. That module gains getOnlyButton. It picks
candidates with the module's own name computation, then runs RTL's full
role, name and accessibility query on each one's parent, and requires
exactly one match. A name from aria-labelledby now counts too.
@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

/approve-spec b57f904

@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, and it runs once the pull request is marked ready for review and a maintainer adds the ci:run label.

The shared getOnlyButton in fastRoleQueries.ts resolves the earlier request, and it returns the same element as getByRole at all 29 call sites in DateTimeInputTouch.test.tsx. One small, non-blocking point: its name prefilter ignores CSS hiding, so a duplicate whose name differs only by hidden text is not counted, and the header line saying it keeps getByRole's checks could say so.

[Automated review]

*
* Trade-off vs getByRole: first match wins — no tree-wide uniqueness check.
* Trade-off vs getByRole: getButton and queryButton take the first match —
* no tree-wide uniqueness check. getOnlyButton keeps getByRole's checks. Each

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.

Non-blocking: the prefilter computes names with the constant-visible stub, so text hidden by CSS still counts there. Beside a plain Save button, a Save<span style="display:none"> draft</span> button makes getByRole('button', {name: 'Save'}) throw for multiple matches, while getOnlyButton('Save') returns the plain one; alone, that button makes getOnlyButton throw where getByRole finds it. No call site in this pull request hits it. Suggested wording:

 * no tree-wide uniqueness check. getOnlyButton keeps getByRole's checks for
 * names that no CSS-hidden text changes. Each

@vjeux
vjeux marked this pull request as ready for review November 6, 2026 15:30
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 6, 2026
@cixzhang
cixzhang marked this pull request as draft November 6, 2026 15:40
@cixzhang
cixzhang marked this pull request as ready for review November 6, 2026 15:40
@cixzhang
cixzhang merged commit 089f7a0 into meta:main Nov 6, 2026
165 of 170 checks passed
@vjeux
vjeux deleted the ui-load-jsdom branch November 6, 2026 16:14
cixzhang pushed a commit that referenced this pull request Nov 7, 2026
…ove the date like UIDatePicker's (#8209)

* fix(DateInput, DateTimeInput): under a finger the month/year wheels move the date like UIDatePicker's

Under a finger, turning the month or year wheel behind the sheet
calendar's title moves a chosen date to the wheels' month and keeps its
day: October 15 becomes May 15, and a day the month lacks becomes its
last day (January 31 becomes February 28), inside min and max, by the
months of the calendar the sheet shows; DateTimeInput keeps the time. A
date dateConstraints refuses is not chosen, and with no date chosen the
wheels move only the calendar. With a mouse the wheels move the calendar
only, as today.

The month wheel does not loop.

DateInput FR22 records the rule under a coarse primary pointer, and
DateTimeInput FR14 does the same and keeps the time. Each has a
verification row.

* test(DateInput): the month/year wheels' proof waits on the sheet's own end, not on still frames before a deadline

`openWheels` waited for the sheet, and then for the wheels, with the
harness's `waitForRest`: three still frames within 5 s. On a loaded
runner the page can present no frame for 6 s right after the sheet
opens, so the wait ran out with nothing moving ("still moving", while
the page held no animation). The proof now checks the sheet's open
transform, and then the wheels' full opacity, once a frame with no
deadline of its own, and waits on each animation's `finished` promise.
A starved runner only makes it later.

* refactor(DateInput, DateTimeInput): the wheels' comments keep the reason

The comments above both sheets' handleWheelChange keep only the reason:
UIDatePicker moves a chosen date with the wheels. The day and bound
clamps read from dateInMonth itself, which moves the date by the
calendar's own months through calendarShiftMonths.

* Merge main into the month/year wheels

Main gained #10285, which adds a `getOnlyButton` import beside the
testing-library import this pull request widens in
DateTimeInputTouch.test.tsx. The merge keeps both imports; this pull
request's own changes are unchanged.

* Merge main into the month/year wheels

Main gained #10231, which adds DateInput FR22 for the touch sheet's
month arrows. This pull request's month/year wheel requirement moves
from FR22 to FR23, with its verification row, the Bottom-sheet
calendar row, the scope line and DateTimeInput FR14's two citations.
Only the numbers change; this pull request's own changes are otherwise
unchanged.

This branch was successfully deployed

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

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) 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